Spaces:
Running
Running
Patrick Walukagga
commited on
Commit
·
632bf0d
1
Parent(s):
2089531
Dependency updates
Browse files- Dockerfile.gradio.prod +6 -2
- README.md +2 -2
- bin/cfn/ecs-deploy +1 -1
- rag/rag_pipeline.py +8 -2
- requirements.txt +10 -10
Dockerfile.gradio.prod
CHANGED
@@ -2,8 +2,10 @@
|
|
2 |
# BUILDER #
|
3 |
###########
|
4 |
|
|
|
|
|
5 |
# pull official base image
|
6 |
-
FROM
|
7 |
|
8 |
# set work directory
|
9 |
WORKDIR /app
|
@@ -27,8 +29,10 @@ RUN pip wheel --no-cache-dir --no-deps --wheel-dir /app/wheels -r requirements.t
|
|
27 |
# FINAL #
|
28 |
#########
|
29 |
|
|
|
|
|
30 |
# pull official base image
|
31 |
-
FROM
|
32 |
|
33 |
# create directory for the app user
|
34 |
RUN mkdir -p /home/backend-app
|
|
|
2 |
# BUILDER #
|
3 |
###########
|
4 |
|
5 |
+
ARG AWS_ACCOUNT_ID
|
6 |
+
|
7 |
# pull official base image
|
8 |
+
FROM ${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/gradio-python:3.11.10-slim as builder
|
9 |
|
10 |
# set work directory
|
11 |
WORKDIR /app
|
|
|
29 |
# FINAL #
|
30 |
#########
|
31 |
|
32 |
+
ARG AWS_ACCOUNT_ID
|
33 |
+
|
34 |
# pull official base image
|
35 |
+
FROM ${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/gradio-python:3.11.10-slim
|
36 |
|
37 |
# create directory for the app user
|
38 |
RUN mkdir -p /home/backend-app
|
README.md
CHANGED
@@ -121,7 +121,7 @@ export AWS_ACCOUNT_ID=aws_account_id # ie. 2243838xxxxxx
|
|
121 |
Login into the AWS ECR (Elastic Container Registry) via the commandline
|
122 |
|
123 |
```sh
|
124 |
-
aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin "$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
|
125 |
```
|
126 |
|
127 |
Create a python image and push to ECR. This image will be used as the base image for the application image deployed on AWS ECS.
|
@@ -181,7 +181,7 @@ echo $ECR_BACKEND_FASTAPI_URL
|
|
181 |
- Build the docker image for the production and push to ECR
|
182 |
|
183 |
```sh
|
184 |
-
docker build -f Dockerfile.api.prod -t fastapi-api-prod .
|
185 |
docker tag fastapi-api-prod:latest "${ECR_BACKEND_FASTAPI_URL}:latest"
|
186 |
docker push "${ECR_BACKEND_FASTAPI_URL}:latest"
|
187 |
```
|
|
|
121 |
Login into the AWS ECR (Elastic Container Registry) via the commandline
|
122 |
|
123 |
```sh
|
124 |
+
aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin "$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com"
|
125 |
```
|
126 |
|
127 |
Create a python image and push to ECR. This image will be used as the base image for the application image deployed on AWS ECS.
|
|
|
181 |
- Build the docker image for the production and push to ECR
|
182 |
|
183 |
```sh
|
184 |
+
docker build --build-arg AWS_ACCOUNT_ID=$AWS_ACCOUNT_ID -f Dockerfile.api.prod -t fastapi-api-prod .
|
185 |
docker tag fastapi-api-prod:latest "${ECR_BACKEND_FASTAPI_URL}:latest"
|
186 |
docker push "${ECR_BACKEND_FASTAPI_URL}:latest"
|
187 |
```
|
bin/cfn/ecs-deploy
CHANGED
@@ -22,4 +22,4 @@ aws cloudformation deploy \
|
|
22 |
--tags group=acres-rag \
|
23 |
--parameter-overrides $PARAMETERS \
|
24 |
--capabilities CAPABILITY_NAMED_IAM \
|
25 |
-
--profile
|
|
|
22 |
--tags group=acres-rag \
|
23 |
--parameter-overrides $PARAMETERS \
|
24 |
--capabilities CAPABILITY_NAMED_IAM \
|
25 |
+
--profile acres
|
rag/rag_pipeline.py
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
# rag/rag_pipeline.py
|
2 |
import json
|
3 |
import logging
|
|
|
4 |
import re
|
5 |
from typing import Any, Dict, List, Optional, Tuple
|
6 |
|
7 |
import chromadb
|
|
|
8 |
from llama_index.core import Document, PromptTemplate, VectorStoreIndex
|
9 |
from llama_index.core.node_parser import SentenceSplitter, SentenceWindowNodeParser
|
10 |
from llama_index.embeddings.openai import OpenAIEmbedding
|
@@ -14,6 +16,8 @@ from llama_index.vector_stores.chroma import ChromaVectorStore
|
|
14 |
logging.basicConfig(level=logging.INFO)
|
15 |
logger = logging.getLogger(__name__)
|
16 |
|
|
|
|
|
17 |
|
18 |
class RAGPipeline:
|
19 |
def __init__(
|
@@ -28,7 +32,9 @@ class RAGPipeline:
|
|
28 |
self.documents = None
|
29 |
self.client = chromadb.Client()
|
30 |
self.collection = self.client.get_or_create_collection(self.collection_name)
|
31 |
-
self.embedding_model = OpenAIEmbedding(
|
|
|
|
|
32 |
self.is_pdf = self._check_if_pdf_collection()
|
33 |
self.load_documents()
|
34 |
self.build_index()
|
@@ -175,7 +181,7 @@ class RAGPipeline:
|
|
175 |
text_qa_template=prompt_template,
|
176 |
similarity_top_k=n_documents if n_documents <= 17 else 15,
|
177 |
response_mode="tree_summarize",
|
178 |
-
llm=OpenAI(model="gpt-4o-mini"),
|
179 |
)
|
180 |
|
181 |
response = query_engine.query(context)
|
|
|
1 |
# rag/rag_pipeline.py
|
2 |
import json
|
3 |
import logging
|
4 |
+
import os
|
5 |
import re
|
6 |
from typing import Any, Dict, List, Optional, Tuple
|
7 |
|
8 |
import chromadb
|
9 |
+
from dotenv import load_dotenv
|
10 |
from llama_index.core import Document, PromptTemplate, VectorStoreIndex
|
11 |
from llama_index.core.node_parser import SentenceSplitter, SentenceWindowNodeParser
|
12 |
from llama_index.embeddings.openai import OpenAIEmbedding
|
|
|
16 |
logging.basicConfig(level=logging.INFO)
|
17 |
logger = logging.getLogger(__name__)
|
18 |
|
19 |
+
load_dotenv()
|
20 |
+
|
21 |
|
22 |
class RAGPipeline:
|
23 |
def __init__(
|
|
|
32 |
self.documents = None
|
33 |
self.client = chromadb.Client()
|
34 |
self.collection = self.client.get_or_create_collection(self.collection_name)
|
35 |
+
self.embedding_model = OpenAIEmbedding(
|
36 |
+
model_name="text-embedding-ada-002", api_key=os.getenv("OPENAI_API_KEY")
|
37 |
+
)
|
38 |
self.is_pdf = self._check_if_pdf_collection()
|
39 |
self.load_documents()
|
40 |
self.build_index()
|
|
|
181 |
text_qa_template=prompt_template,
|
182 |
similarity_top_k=n_documents if n_documents <= 17 else 15,
|
183 |
response_mode="tree_summarize",
|
184 |
+
llm=OpenAI(model="gpt-4o-mini", api_key=os.getenv("OPENAI_API_KEY")),
|
185 |
)
|
186 |
|
187 |
response = query_engine.query(context)
|
requirements.txt
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
-
chromadb
|
2 |
-
fastapi
|
3 |
-
gradio
|
4 |
-
gradio_client
|
5 |
-
llama-index
|
6 |
-
llama-index-vector-stores-chroma
|
7 |
nest-asyncio==1.6.0
|
8 |
-
openai
|
9 |
-
pandas
|
10 |
-
pydantic
|
11 |
python-dotenv
|
12 |
pyzotero
|
13 |
python-slugify
|
14 |
PyMuPDF==1.23.8
|
15 |
Pillow==10.2.0
|
16 |
-
sqlmodel
|
17 |
cachetools
|
|
|
1 |
+
chromadb==0.5.20
|
2 |
+
fastapi==0.115.5
|
3 |
+
gradio==5.6.0
|
4 |
+
gradio_client==1.4.3
|
5 |
+
llama-index==0.12.3
|
6 |
+
llama-index-vector-stores-chroma==0.4.0
|
7 |
nest-asyncio==1.6.0
|
8 |
+
openai==1.57.0
|
9 |
+
pandas==2.2.3
|
10 |
+
pydantic==2.9.2
|
11 |
python-dotenv
|
12 |
pyzotero
|
13 |
python-slugify
|
14 |
PyMuPDF==1.23.8
|
15 |
Pillow==10.2.0
|
16 |
+
sqlmodel==0.0.22
|
17 |
cachetools
|