Skip to content

Commit 6f15ca4

Browse files
committed
feat: backend folder
1 parent d0d87e6 commit 6f15ca4

File tree

96 files changed

+12617
-22
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+12617
-22
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 22 deletions
This file was deleted.

backend/.env.example

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# General settings
2+
PROJECT_NAME=
3+
API_PREFIX=
4+
SECRET_KEY=
5+
ACCESS_TOKEN_EXPIRE_MINUTES=11520
6+
7+
# CORS Origins
8+
FRONTEND_HOST=http://localhost:3000
9+
10+
# Environment and logging
11+
ENVIRONMENT=local # Options: local, staging, production
12+
LOG_LEVEL=DEBUG # Options: DEBUG, INFO, ERROR, WARNING
13+
SENTRY_DSN= # Add your Sentry DSN if available
14+
15+
# Database configuration
16+
POSTGRES_SERVER=localhost
17+
POSTGRES_PORT=5432
18+
POSTGRES_USER=user
19+
POSTGRES_PASSWORD=password
20+
POSTGRES_DB=app_database
21+
22+
# LLM Configuration
23+
LLM_TEMPERATURE=0.5
24+
LLM_MAX_TOKENS=
25+
EMBEDDING_DIM=1024
26+
27+
# OpenAI Configuration
28+
LLM_OPENAI_MODEL=
29+
OPENAI_API_KEY=
30+
31+
# Optional Worker Configuration
32+
UVICORN_WORKER_COUNT=

backend/.flake8

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[flake8]
2+
max-line-length = 88
3+
exclude = .venv,.git,__pycache__,build,dist

backend/.gitignore

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib64/
18+
parts/
19+
sdist/
20+
var/
21+
wheels/
22+
share/python-wheels/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
MANIFEST
27+
28+
# PyInstaller
29+
# Usually these files are written by a python script from a template
30+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
41+
.nox/
42+
.coverage
43+
.coverage.*
44+
.cache
45+
nosetests.xml
46+
coverage.xml
47+
*.cover
48+
*.py,cover
49+
.hypothesis/
50+
.pytest_cache/
51+
cover/
52+
53+
# Translations
54+
*.mo
55+
*.pot
56+
57+
# Django stuff:
58+
*.log
59+
local_settings.py
60+
db.sqlite3
61+
db.sqlite3-journal
62+
63+
# Flask stuff:
64+
instance/
65+
.webassets-cache
66+
67+
# Scrapy stuff:
68+
.scrapy
69+
70+
# Sphinx documentation
71+
docs/_build/
72+
73+
# PyBuilder
74+
.pybuilder/
75+
target/
76+
77+
# Jupyter Notebook
78+
.ipynb_checkpoints
79+
80+
# IPython
81+
profile_default/
82+
ipython_config.py
83+
84+
# pyenv
85+
# For a library or package, you might want to ignore these files since the code is
86+
# intended to run in multiple environments; otherwise, check them in:
87+
# .python-version
88+
89+
# pipenv
90+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
91+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
92+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
93+
# install all needed dependencies.
94+
#Pipfile.lock
95+
96+
# poetry
97+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
98+
# This is especially recommended for binary packages to ensure reproducibility, and is more
99+
# commonly ignored for libraries.
100+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
101+
#poetry.lock
102+
103+
# pdm
104+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
105+
#pdm.lock
106+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
107+
# in version control.
108+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
109+
.pdm.toml
110+
.pdm-python
111+
.pdm-build/
112+
113+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
114+
__pypackages__/
115+
116+
# Celery stuff
117+
celerybeat-schedule
118+
celerybeat.pid
119+
120+
# SageMath parsed files
121+
*.sage.py
122+
123+
# Environments
124+
.env
125+
.venv
126+
env/
127+
venv/
128+
ENV/
129+
env.bak/
130+
venv.bak/
131+
132+
# Spyder project settings
133+
.spyderproject
134+
.spyproject
135+
136+
# Rope project settings
137+
.ropeproject
138+
139+
# mkdocs documentation
140+
/site
141+
142+
# mypy
143+
.mypy_cache/
144+
.dmypy.json
145+
dmypy.json
146+
147+
# Pyre type checker
148+
.pyre/
149+
150+
# pytype static type analyzer
151+
.pytype/
152+
153+
# Cython debug symbols
154+
cython_debug/
155+
156+
# PyCharm
157+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
158+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
159+
# and can be added to the global gitignore or merged into this file. For a more nuclear
160+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
161+
#.idea/
162+
.python-version
163+
/qdrant_storage
164+
/data/dev-test-*.txt

backend/Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Use a slim Python image for smaller size
2+
FROM python:3.11.3-slim-bullseye
3+
4+
# Set environment variables for non-buffered output and working directory
5+
ENV PYTHONUNBUFFERED=1 \
6+
APP_HOME=/app
7+
8+
WORKDIR $APP_HOME
9+
10+
# Install system dependencies in one step
11+
RUN apt-get update --no-cache && \
12+
apt-get install -y --no-install-recommends \
13+
libpq-dev \
14+
gcc \
15+
build-essential \
16+
wkhtmltopdf && \
17+
rm -rf /var/lib/apt/lists/* # Clean up APT cache
18+
19+
# Install Poetry
20+
RUN pip install --no-cache-dir poetry
21+
22+
# Copy dependency files first for better caching
23+
COPY pyproject.toml poetry.lock ./
24+
25+
# Install dependencies using Poetry
26+
RUN poetry install --no-root --no-interaction --no-ansi
27+
28+
# Copy the rest of the application
29+
COPY . .
30+
31+
ENV OPENAI_API_KEY=${OPENAI_API_KEY}
32+
33+
CMD ["poetry", "run", "start"]

backend/LINT.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Format code
2+
black qllm example tests
3+
4+
# Check import order
5+
isort --check-only qllm example tests
6+
7+
# Fix import order
8+
isort qllm example tests
9+
10+
# Lint with Flake8
11+
flake8 qllm example tests
12+
13+
# Type-check with Mypy
14+
mypy qllm example

backend/data/.gitkeep

Whitespace-only changes.

backend/example/dev.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from qllm.models import Base
2+
3+
print("All table: ", Base.metadata.tables)

0 commit comments

Comments
 (0)