diff --git a/.github/workflows/build-backend-docker.yml b/.github/workflows/build-backend-docker.yml new file mode 100644 index 00000000..c2893376 --- /dev/null +++ b/.github/workflows/build-backend-docker.yml @@ -0,0 +1,19 @@ +name: Build Backend Docker Image + +on: [push, pull_request] + +jobs: + build-backend-docker: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build image + uses: docker/build-push-action@v6 + with: + context: backend + file: backend/Dockerfile + push: false + tags: ${{ github.sha }} diff --git a/.gitignore b/.gitignore index 5d5bb080..d3e27ae8 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ venv/ .ruff_cache/ .mypy_cache/ +# docs +documents.txt diff --git a/backend/.env.example b/backend/.env.example index 508da530..d9df5de0 100644 --- a/backend/.env.example +++ b/backend/.env.example @@ -1,4 +1,4 @@ -GOOGLE_API_KEY= +GOOGLE_API_KEY={{GOOGLE_API_KEY}} LANGCHAIN_TRACING_V2= LANGCHAIN_ENDPOINT= diff --git a/backend/Dockerfile b/backend/Dockerfile index b7f5c74d..c3705728 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,10 +1,5 @@ FROM python:3.12.3-slim -RUN apt-get update && \ - apt-get install -y gcc python3-dev && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - WORKDIR /ORAssistant-backend COPY ./requirements.txt /ORAssistant-backend/requirements.txt diff --git a/backend/requirements-test.txt b/backend/requirements-test.txt index 2231f565..8e970672 100644 --- a/backend/requirements-test.txt +++ b/backend/requirements-test.txt @@ -1,231 +1,15 @@ -aiohttp==3.9.5 -aiosignal==1.3.1 -annotated-types==0.7.0 -anyio==4.4.0 -asttokens==2.4.1 -attrs==23.2.0 -backoff==2.2.1 +langchain==0.2.6 +langchain-community==0.2.6 +langchain-huggingface==0.0.3 +langchain-google-genai==1.0.7 beautifulsoup4==4.12.3 -bs4==0.0.2 -cachetools==5.3.3 -certifi==2024.2.2 -cffi==1.16.0 -chardet==5.2.0 -charset-normalizer==3.3.2 -click==8.1.7 -comm==0.2.2 -cryptography==42.0.8 -dataclasses-json==0.6.6 -debugpy==1.6.7 -decorator==5.1.1 -deepdiff==7.0.1 -deprecation==2.1.0 -dnspython==2.6.1 -docstring_parser==0.16 -email_validator==2.1.1 -emoji==2.12.1 -exceptiongroup==1.2.0 -executing==2.0.1 -faiss-cpu==1.8.0 fastapi==0.111.0 -fastapi-cli==0.0.4 -filelock==3.14.0 -filetype==1.2.0 -frozenlist==1.4.1 -fsspec==2024.5.0 -google-ai-generativelanguage==0.6.4 -google-api-core==2.19.0 -google-api-python-client==2.131.0 -google-auth==2.29.0 -google-auth-httplib2==0.2.0 -google-cloud-aiplatform==1.49.0 -google-cloud-bigquery==3.24.0 -google-cloud-core==2.4.1 -google-cloud-resource-manager==1.12.3 -google-cloud-storage==2.17.0 -google-crc32c==1.5.0 -google-generativeai==0.5.4 -google-resumable-media==2.7.1 -googleapis-common-protos==1.63.0 -greenlet==3.0.3 -grpc-google-iam-v1==0.13.0 -grpcio==1.64.0 -grpcio-status==1.62.2 -h11==0.14.0 -httpcore==1.0.5 -httplib2==0.22.0 -httptools==0.6.1 -httpx==0.27.0 -huggingface-hub==0.23.4 -idna==3.7 -importlib_metadata==7.1.0 -ipykernel==6.29.4 -ipython==8.25.0 -jedi==0.19.1 -Jinja2==3.1.4 -joblib==1.4.2 -jsonpatch==1.33 -jsonpath-python==1.0.6 -jsonpointer==2.4 -jsonschema==4.22.0 -jsonschema-specifications==2023.12.1 -jupyter_client==8.6.2 -jupyter_core==5.5.0 -langchain==0.2.5 -langchain-community==0.2.5 -langchain-core==0.2.9 -langchain-google-genai==1.0.5 -langchain-google-vertexai==1.0.5 -langchain-huggingface==0.0.3 -langchain-text-splitters==0.2.0 -langdetect==1.0.9 -langgraph==0.1.4 -langserve==0.2.1 -langsmith==0.1.77 -lxml==5.2.2 -lxml-stubs==0.5.1 -Markdown==3.6 -markdown-it-py==3.0.0 -MarkupSafe==2.1.5 -marshmallow==3.21.2 -matplotlib-inline==0.1.7 -mdurl==0.1.2 -mpmath==1.3.0 -multidict==6.0.5 -mypy==1.10.0 -mypy-extensions==1.0.0 -nest_asyncio==1.6.0 -networkx==3.3 -numpy==1.26.4 -nvidia-cublas-cu12==12.1.3.1 -nvidia-cuda-cupti-cu12==12.1.105 -nvidia-cuda-nvrtc-cu12==12.1.105 -nvidia-cuda-runtime-cu12==12.1.105 -nvidia-cudnn-cu12==8.9.2.26 -nvidia-cufft-cu12==11.0.2.54 -nvidia-curand-cu12==10.3.2.106 -nvidia-cusolver-cu12==11.4.5.107 -nvidia-cusparse-cu12==12.1.0.106 -nvidia-nccl-cu12==2.20.5 -nvidia-nvjitlink-cu12==12.5.40 -nvidia-nvtx-cu12==12.1.105 -ordered-set==4.1.0 -orjson==3.10.3 -overrides==7.7.0 -packaging==23.2 -pandas-stubs==2.2.2.240603 -parso==0.8.4 -pexpect==4.9.0 -pickleshare==0.7.5 -pillow==10.3.0 -pip==24.0 -platformdirs==4.2.2 -prompt_toolkit==3.0.46 -proto-plus==1.23.0 -protobuf==4.25.3 -psutil==5.9.0 -ptyprocess==0.7.0 -pure-eval==0.2.2 -py==1.11.0 -pyarrow==15.0.0 -pyasn1==0.6.0 -pyasn1_modules==0.4.0 -pycparser==2.22 -pydantic==2.7.2 -pydantic_core==2.18.3 -Pygments==2.18.0 -pylance==0.12.1 -pyparsing==3.1.2 -pypdf==4.2.0 -pyproject-toml==0.0.10 -python-dateutil==2.9.0.post0 -python-dotenv==1.0.1 -python-iso639==2024.4.27 -python-magic==0.4.27 -python-multipart==0.0.9 -PyYAML==6.0.1 -pyzmq==25.1.2 +faiss-cpu==1.8.0 +markdown==3.0.0 rank-bm25==0.2.2 -rapidfuzz==3.9.2 -ratelimiter==1.2.0.post0 -referencing==0.35.1 -regex==2024.5.15 -requests==2.32.3 -retry==0.9.2 -rich==13.7.1 -rpds-py==0.18.1 -rsa==4.9 -ruff==0.4.8 -safetensors==0.4.3 -scikit-learn==1.5.0 -scipy==1.13.1 -sentence-transformers==3.0.0 -setuptools==69.5.1 -shapely==2.0.4 -shellingham==1.5.4 -six==1.16.0 -sniffio==1.3.1 -soupsieve==2.5 -SQLAlchemy==2.0.30 -sse-starlette==2.1.0 -stack-data==0.6.2 -starlette==0.37.2 -sympy==1.12.1 -tabulate==0.9.0 -tenacity==8.3.0 -threadpoolctl==3.5.0 -tokenizers==0.19.1 -toml==0.10.2 -torch==2.3.0 -tornado==6.4.1 -tqdm==4.66.4 -traitlets==5.14.3 -transformers==4.41.1 -tree-sitter==0.22.3 -typer==0.12.3 -types-beautifulsoup4==4.12.0.20240511 -types-cffi==1.16.0.20240331 -types-colorama==0.4.15.20240311 -types-decorator==5.1.8.20240310 -types-docutils==0.21.0.20240423 -types-hdbcli==2.21.0.20240621 -types-html5lib==1.1.11.20240228 -types-jsonschema==4.22.0.20240610 +mypy==1.0.1 types-Markdown==3.6.0.20240316 -types-protobuf==5.27.0.20240626 -types-psutil==6.0.0.20240621 -types-psycopg2==2.9.21.20240417 -types-Pygments==2.18.0.20240506 -types-PyMySQL==1.1.0.20240524 -types-pyOpenSSL==24.1.0.20240425 -types-python-dateutil==2.9.0.20240316 -types-pytz==2024.1.0.20240417 -types-PyYAML==6.0.12.20240311 -types-redis==4.6.0.20240425 -types-regex==2024.5.15.20240519 types-requests==2.32.0.20240622 -types-setuptools==70.1.0.20240627 -types-six==1.16.21.20240513 -types-tabulate==0.9.0.20240106 types-tqdm==4.66.0.20240417 -types-tree-sitter==0.20.1.20240311 -types-tree-sitter-languages==1.10.0.20240612 -types-ujson==5.10.0.20240515 -types-xmltodict==0.13.0.3 -typing_extensions==4.12.2 -typing-inspect==0.9.0 -ujson==5.10.0 -unstructured==0.14.3 -unstructured-client==0.22.0 -uritemplate==4.1.1 -urllib3==2.2.2 -uvicorn==0.30.0 -uvloop==0.19.0 -vertexai==1.49.0 -watchfiles==0.22.0 -wcwidth==0.2.13 -websockets==12.0 -wheel==0.43.0 -wrapt==1.16.0 -yarl==1.9.4 -zipp==3.18.1 +types-beautifulsoup4==4.12.0.20240511 +ruff==0.5.1 diff --git a/backend/requirements.txt b/backend/requirements.txt index ac81dd90..f21b399b 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -1,119 +1,9 @@ -aiohttp==3.9.5 -aiosignal==1.3.1 -annotated-types==0.7.0 -anyio==4.4.0 -attrs==23.2.0 -beautifulsoup4==4.12.3 -bs4==0.0.2 -cachetools==5.3.3 -certifi==2024.6.2 -charset-normalizer==3.3.2 -click==8.1.7 -dataclasses-json==0.6.7 -dnspython==2.6.1 -email_validator==2.2.0 -faiss-cpu==1.8.0.post1 -fastapi==0.111.0 -fastapi-cli==0.0.4 -filelock==3.15.4 -frozenlist==1.4.1 -fsspec==2024.6.1 -google-ai-generativelanguage==0.6.6 -google-api-core==2.19.1 -google-api-python-client==2.135.0 -google-auth==2.31.0 -google-auth-httplib2==0.2.0 -google-generativeai==0.7.1 -googleapis-common-protos==1.63.2 -greenlet==3.0.3 -grpcio==1.64.1 -grpcio-status==1.62.2 -h11==0.14.0 -httpcore==1.0.5 -httplib2==0.22.0 -httptools==0.6.1 -httpx==0.27.0 -huggingface-hub==0.23.4 -idna==3.7 -Jinja2==3.1.4 -joblib==1.4.2 -jsonpatch==1.33 -jsonpointer==3.0.0 langchain==0.2.6 langchain-community==0.2.6 -langchain-core==0.2.10 -langchain-google-genai==1.0.7 langchain-huggingface==0.0.3 -langchain-text-splitters==0.2.2 -langsmith==0.1.83 -Markdown==3.6 -markdown-it-py==3.0.0 -MarkupSafe==2.1.5 -marshmallow==3.21.3 -mdurl==0.1.2 -mpmath==1.3.0 -multidict==6.0.5 -mypy-extensions==1.0.0 -networkx==3.3 -numpy==1.26.4 -nvidia-cublas-cu12==12.1.3.1 -nvidia-cuda-cupti-cu12==12.1.105 -nvidia-cuda-nvrtc-cu12==12.1.105 -nvidia-cuda-runtime-cu12==12.1.105 -nvidia-cudnn-cu12==8.9.2.26 -nvidia-cufft-cu12==11.0.2.54 -nvidia-curand-cu12==10.3.2.106 -nvidia-cusolver-cu12==11.4.5.107 -nvidia-cusparse-cu12==12.1.0.106 -nvidia-nccl-cu12==2.20.5 -nvidia-nvjitlink-cu12==12.5.82 -nvidia-nvtx-cu12==12.1.105 -orjson==3.10.5 -packaging==24.1 -pillow==10.4.0 -pip==24.0 -proto-plus==1.24.0 -protobuf==4.25.3 -pyasn1==0.6.0 -pyasn1_modules==0.4.0 -pydantic==2.8.0 -pydantic_core==2.20.0 -Pygments==2.18.0 -pyparsing==3.1.2 -python-dotenv==1.0.1 -python-multipart==0.0.9 -PyYAML==6.0.1 +langchain-google-genai==1.0.7 +beautifulsoup4==4.12.3 +fastapi==0.111.0 +faiss-cpu==1.8.0 +markdown==3.0.0 rank-bm25==0.2.2 -regex==2024.5.15 -requests==2.32.3 -rich==13.7.1 -rsa==4.9 -safetensors==0.4.3 -scikit-learn==1.5.0 -scipy==1.14.0 -sentence-transformers==3.0.1 -setuptools==69.5.1 -shellingham==1.5.4 -sniffio==1.3.1 -soupsieve==2.5 -SQLAlchemy==2.0.31 -starlette==0.37.2 -sympy==1.12.1 -tenacity==8.4.2 -threadpoolctl==3.5.0 -tokenizers==0.19.1 -torch==2.3.1 -tqdm==4.66.4 -transformers==4.42.3 -typer==0.12.3 -typing_extensions==4.12.2 -typing-inspect==0.9.0 -ujson==5.10.0 -uritemplate==4.1.1 -urllib3==2.2.2 -uvicorn==0.30.1 -uvloop==0.19.0 -watchfiles==0.22.0 -websockets==12.0 -wheel==0.43.0 -yarl==1.9.4 diff --git a/backend/src/api/routers/chains.py b/backend/src/api/routers/chains.py index 0006ac4d..b9ef1df1 100644 --- a/backend/src/api/routers/chains.py +++ b/backend/src/api/routers/chains.py @@ -21,7 +21,7 @@ class UserInput(BaseModel): load_dotenv() -use_cuda = os.getenv("USE_CUDA") +use_cuda = True if os.getenv("USE_CUDA", "") == "true" else False llm = ChatGoogleGenerativeAI(model="gemini-pro", temperature=1) hf_embdeddings = "BAAI/bge-large-en-v1.5"