Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
342e23b
feat(config): add parsing function from args
ReturnToFirst Mar 24, 2025
e908c51
feat(config): add cli argparse
ReturnToFirst Mar 25, 2025
1c77707
fix(config): change default value of args
ReturnToFirst Mar 25, 2025
c90c880
chore: add .gitignore
ReturnToFirst Mar 25, 2025
9bb1a59
feat(config): add CLI arg loader
ReturnToFirst Mar 25, 2025
b9ed4ed
refactor(prompt): integrate prompt into config
ReturnToFirst Mar 25, 2025
8e32ba0
feat(config): add prompt cli args
ReturnToFirst Mar 25, 2025
e23da26
fix(main): load args if no config file
ReturnToFirst Mar 25, 2025
3142054
feat(db): added config for postgres support
ReturnToFirst Mar 25, 2025
6502488
feat(db): add postgres support
ReturnToFirst Mar 25, 2025
7cf08e9
fix(db): change underscore to dash on cli args
ReturnToFirst Mar 25, 2025
0a9dcb8
chore: add type hint
ReturnToFirst Mar 25, 2025
5fcff70
deps: remove unused prompt
ReturnToFirst Mar 25, 2025
0260ac1
feat: add start.sh script
ReturnToFirst Mar 25, 2025
4585cd8
deploy: add Dockerfile
ReturnToFirst Mar 25, 2025
f1603bc
deploy: update docker default envs
ReturnToFirst Mar 25, 2025
3d9e7e0
fix(config): change default language template
ReturnToFirst Mar 25, 2025
235ba4e
deps: Update requirements.txt
ReturnToFirst Mar 25, 2025
7c0694e
fix(start.sh): fix typo
ReturnToFirst Mar 25, 2025
87b69b1
action: add docker build
ReturnToFirst Mar 25, 2025
32a92bb
chore: change default latest record initaliztion
ReturnToFirst Mar 25, 2025
4a400f5
deploy: add kubenetes example
ReturnToFirst Mar 25, 2025
edd0d11
deploy: add docker compose example
ReturnToFirst Mar 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
on:
push:
branches:
- "*"
tags:
- "*"

jobs:
build:
runs-on: ubuntu-22.04
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: linux/amd64, linux/arm64
push: true
tags: ghcr.io/returntofirst/xunity-autotranslator-openai:latest
174 changes: 174 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# UV
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
#uv.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# Ruff stuff:
.ruff_cache/

# PyPI configuration file
.pypirc
46 changes: 46 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
FROM python:3.12-slim

ENV BASE_URL="https://api.openai.com/v1"
ENV API_KEY=""

Check warning on line 4 in Dockerfile

View workflow job for this annotation

GitHub Actions / build

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "API_KEY") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
ENV MODEL_NAME="gpt-3.5-turbo"
ENV TEMPERATURE="0.0"
ENV MAX_TOKENS="2048"
ENV FREQUENCY_PENALTY="1.1"
ENV PRESENCE_PENALTY="1.1"
ENV HOST="0.0.0.0"
ENV PORT="5000"
ENV USE_HISTORY="1"
ENV MAX_HISTORY="20"
ENV USE_LATEST_HISTORY="1"
ENV DB_TYPE="sqlite"
ENV CACHE_TRANSLATION="1"
ENV USE_CACHED_TRANSLATION="1"
ENV USE_LATEST_RECORDS="1"
ENV INIT_LATEST_RECORDS="10"
ENV POSTGRES_HOST="localhost"
ENV POSTGRES_PORT="5432"
ENV POSTGRES_USER=""
ENV POSTGRES_PASSWORD=""

Check warning on line 23 in Dockerfile

View workflow job for this annotation

GitHub Actions / build

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "POSTGRES_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
ENV POSTGRES_DB="xunity"
ENV SQLITE_DB_PATH="translation.db"
ENV LOG_FILE=""
ENV LOG_LEVEL=""
ENV TASK_TEMPLATE=""
ENV SPECIFY_LANGUAGE="1"
ENV LANGUAGE_TEMPLATE=""
ENV SRC_START=""
ENV SRC_END=""
ENV TGT_START=""
ENV TGT_END=""
ENV USE_SYSTEM_PROMPT="1"
ENV SYSTEM_PROMPT=""
ENV CONFIG=""

RUN mkdir -p /app
WORKDIR /app
COPY . /app

RUN pip install --no-cache-dir -r requirements.txt

RUN chmod +x start.sh
CMD ["./start.sh"]
Loading