1) apply multi stage build, 2) rm gemini
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
__pycache__
|
__pycache__
|
||||||
.ruff_cache
|
.ruff_cache
|
||||||
.venv
|
.venv
|
||||||
|
*.tar
|
40
Dockerfile
40
Dockerfile
@ -1,29 +1,25 @@
|
|||||||
FROM python:3.13-slim
|
# Stage1
|
||||||
|
FROM python:3.13-slim-bullseye AS builder
|
||||||
|
|
||||||
# Set timezone
|
RUN apt update && apt install -y curl
|
||||||
ARG WTH
|
RUN curl -sSL https://install.python-poetry.org | python3 -
|
||||||
ENV WTH=$WTH
|
ENV PATH="/root/.local/bin:$PATH"
|
||||||
ENV TZ="Asia/Taipei"
|
RUN poetry config virtualenvs.create false
|
||||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
|
||||||
|
|
||||||
# Init workspace
|
|
||||||
RUN mkdir -p /app
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
COPY pyproject.toml poetry.lock ./
|
||||||
|
RUN poetry install --with main
|
||||||
|
|
||||||
# Install dependencies
|
# Stage2
|
||||||
# Poetry exportation cmd: poetry export --without-hashes --without dev -f requirements.txt -o requirements.tx
|
FROM python:3.13-slim-bullseye AS final
|
||||||
COPY ./requirements.txt .
|
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
|
||||||
|
|
||||||
# Copy source copy
|
ENV TZ="Asia/Taipei"
|
||||||
|
RUN apt update && apt install -y curl
|
||||||
|
COPY --from=builder /usr/local/lib/python3.13/site-packages /usr/local/lib/python3.13/site-packages
|
||||||
|
WORKDIR /app
|
||||||
COPY ./translator .
|
COPY ./translator .
|
||||||
|
EXPOSE 8501
|
||||||
# Install tools
|
CMD ["python", "-m", "streamlit", "run", "app.py", "--server.port=8501", "--server.enableCORS=false", "--server.enableXsrfProtection=false"]
|
||||||
RUN apt update
|
|
||||||
RUN apt install -y curl
|
|
||||||
|
|
||||||
# Run app
|
|
||||||
CMD streamlit run app.py --server.port=8501 --server.enableCORS=false --server.enableXsrfProtection=false
|
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
# docker build -t translator:latest .
|
# docker build --platform=linux/amd64 -t translator:latest .
|
||||||
|
# docker save -o translator.tar translator:latest
|
@ -1,97 +0,0 @@
|
|||||||
aiohappyeyeballs==2.6.1 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
aiohttp==3.12.8 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
aiosignal==1.3.2 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
altair==5.5.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
annotated-types==0.7.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
anyio==4.9.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
attrs==25.3.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
blinker==1.9.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
cachetools==5.5.2 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
certifi==2025.4.26 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
cffi==1.17.1 ; python_version >= "3.13" and python_version < "4.0" and platform_python_implementation == "PyPy"
|
|
||||||
charset-normalizer==3.4.2 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
click==8.2.1 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
colorama==0.4.6 ; python_version >= "3.13" and python_version < "4.0" and platform_system == "Windows"
|
|
||||||
dataclasses-json==0.6.7 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
distro==1.9.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
filetype==1.2.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
frozenlist==1.6.2 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
gitdb==4.0.12 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
gitpython==3.1.44 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
google-ai-generativelanguage==0.6.18 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
google-api-core==2.25.1 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
google-auth==2.40.3 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
googleapis-common-protos==1.70.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
greenlet==3.2.2 ; python_version == "3.13" and (platform_machine == "aarch64" or platform_machine == "ppc64le" or platform_machine == "x86_64" or platform_machine == "amd64" or platform_machine == "AMD64" or platform_machine == "win32" or platform_machine == "WIN32")
|
|
||||||
grpcio-status==1.73.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
grpcio==1.73.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
h11==0.16.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
httpcore==1.0.9 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
httpx-sse==0.4.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
httpx==0.28.1 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
idna==3.10 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
jinja2==3.1.6 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
jiter==0.10.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
jsonpatch==1.33 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
jsonpointer==3.0.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
jsonschema-specifications==2025.4.1 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
jsonschema==4.24.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
langchain-community==0.3.24 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
langchain-core==0.3.65 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
langchain-google-genai==2.1.5 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
langchain-ollama==0.3.3 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
langchain-openai==0.3.24 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
langchain-text-splitters==0.3.8 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
langchain==0.3.25 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
langsmith==0.3.45 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
markupsafe==3.0.2 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
marshmallow==3.26.1 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
multidict==6.4.4 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
mypy-extensions==1.1.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
narwhals==1.41.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
numpy==2.2.6 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
ollama==0.5.1 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
openai==1.88.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
orjson==3.10.18 ; python_version >= "3.13" and python_version < "4.0" and platform_python_implementation != "PyPy"
|
|
||||||
packaging==24.2 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
pandas==2.2.3 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
pillow==11.2.1 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
propcache==0.3.1 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
proto-plus==1.26.1 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
protobuf==6.31.1 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
pyarrow==20.0.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
pyasn1-modules==0.4.2 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
pyasn1==0.6.1 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
pycparser==2.22 ; python_version >= "3.13" and python_version < "4.0" and platform_python_implementation == "PyPy"
|
|
||||||
pydantic-core==2.33.2 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
pydantic-settings==2.9.1 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
pydantic==2.11.5 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
pydeck==0.9.1 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
python-dateutil==2.9.0.post0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
python-dotenv==1.1.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
pytz==2025.2 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
pyyaml==6.0.2 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
referencing==0.36.2 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
regex==2024.11.6 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
requests-toolbelt==1.0.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
requests==2.32.3 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
rpds-py==0.25.1 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
rsa==4.9.1 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
six==1.17.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
smmap==5.0.2 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
sniffio==1.3.1 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
sqlalchemy==2.0.41 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
streamlit==1.45.1 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
tenacity==9.1.2 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
tiktoken==0.9.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
toml==0.10.2 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
tornado==6.5.1 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
tqdm==4.67.1 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
typing-extensions==4.14.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
typing-inspect==0.9.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
typing-inspection==0.4.1 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
tzdata==2025.2 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
urllib3==2.4.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
watchdog==6.0.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
yarl==1.20.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
||||||
zstandard==0.23.0 ; python_version >= "3.13" and python_version < "4.0"
|
|
@ -36,13 +36,6 @@ class TranslatorApp:
|
|||||||
keep_alive=self._config['app']['ollama']['keep_alive'],
|
keep_alive=self._config['app']['ollama']['keep_alive'],
|
||||||
stop=None
|
stop=None
|
||||||
)
|
)
|
||||||
elif self._config['app']['llm_mode'] == 'gemini':
|
|
||||||
llm = ChatGoogleGenerativeAI(
|
|
||||||
model=self._config['app']['gemini']['model_name'],
|
|
||||||
temperature=self._config['app']['gemini']['temperature'],
|
|
||||||
max_tokens=self._config['app']['gemini']['max_tokens'],
|
|
||||||
top_p=self._config['app']['gemini']['top_p']
|
|
||||||
)
|
|
||||||
elif self._config['app']['llm_mode'] == 'openai':
|
elif self._config['app']['llm_mode'] == 'openai':
|
||||||
llm = ChatOpenAI(
|
llm = ChatOpenAI(
|
||||||
model=self._config['app']['openai']['model_name'],
|
model=self._config['app']['openai']['model_name'],
|
||||||
|
@ -5,18 +5,13 @@ app:
|
|||||||
ollama:
|
ollama:
|
||||||
url: http://localhost:11434
|
url: http://localhost:11434
|
||||||
model_name: gemma3:12b-it-qat
|
model_name: gemma3:12b-it-qat
|
||||||
max_tokens: 256
|
max_tokens: 512
|
||||||
temperature: 0.2
|
temperature: 0.2
|
||||||
top_p: 0.9
|
top_p: 0.9
|
||||||
keep_alive: 2m
|
keep_alive: 2m
|
||||||
gemini:
|
|
||||||
model_name: gemini-2.5-flash
|
|
||||||
max_tokens: 512
|
|
||||||
temperature: 0.2
|
|
||||||
top_p: 0.9
|
|
||||||
openai:
|
openai:
|
||||||
model_name: gpt-4.1-nano
|
model_name: gpt-4.1-nano
|
||||||
max_tokens: 512
|
max_tokens: 1024
|
||||||
temperature: 0.2
|
temperature: 0.2
|
||||||
top_p: 0.9
|
top_p: 0.9
|
||||||
lang_directions:
|
lang_directions:
|
||||||
|
Reference in New Issue
Block a user