hetvaghasia39 commited on
Commit
b7a96ac
1 Parent(s): 5aa8027

Update Dockerfile to use pip cache for faster installation

Browse files
Files changed (3) hide show
  1. Dockerfile +3 -2
  2. main.py +12 -1
  3. requirements.txt +2 -0
Dockerfile CHANGED
@@ -5,7 +5,7 @@ FROM python:3.12.0
5
  # && rm -rf /var/lib/apt/lists/*
6
  COPY requirements.txt /app/requirements.txt
7
  WORKDIR /app
8
- RUN pip install -r requirements.txt
9
  RUN playwright install-deps
10
  RUN useradd -m -u 1000 user
11
  USER user
@@ -27,4 +27,5 @@ RUN mv frpc_linux_amd64_v0.2 /usr/local/lib/python3.12/site-packages/gradio/
27
  RUN chmod +x /usr/local/lib/python3.12/site-packages/gradio/frpc_linux_amd64_v0.2
28
  EXPOSE 7860
29
  USER user
30
- CMD ["python", "main.py"]
 
 
5
  # && rm -rf /var/lib/apt/lists/*
6
  COPY requirements.txt /app/requirements.txt
7
  WORKDIR /app
8
+ RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt
9
  RUN playwright install-deps
10
  RUN useradd -m -u 1000 user
11
  USER user
 
27
  RUN chmod +x /usr/local/lib/python3.12/site-packages/gradio/frpc_linux_amd64_v0.2
28
  EXPOSE 7860
29
  USER user
30
+ # CMD ["python", "main.py"]
31
+ CMD ["gradio", "main.py"]
main.py CHANGED
@@ -9,6 +9,7 @@ from utils import HuggingChat
9
  from langchain_core.prompts import PromptTemplate
10
  from langchain_community.embeddings import HuggingFaceEmbeddings
11
  import langchain
 
12
 
13
  # import json
14
  # import shutil
@@ -68,7 +69,16 @@ Answer:
68
  self.db = Chroma(persist_directory="./pragetx_chroma", embedding_function=HuggingFaceEmbeddings(), collection_name="pragetx")
69
  # self.llm = ChatOllama(model="phi3:3.8b", base_url="http://localhost:11434", num_gpu=16)
70
  # self.llm = HuggingChat(email = os.getenv("HF_EMAIL") , psw = os.getenv("HF_PASS") )
71
- self.llm = HuggingChat(email = "brij1808" , psw = "Brijesh321@R" )
 
 
 
 
 
 
 
 
 
72
  self.chain = (
73
  {"chat_history": self.chat_history, "context": self.db.as_retriever(search_kwargs={"k":3}), "question": RunnablePassthrough()} |
74
  self.prompt |
@@ -87,6 +97,7 @@ Answer:
87
  print(history)
88
  prompt = history[-1][0] or ""
89
  for chunks in self.chain.stream(prompt):
 
90
  history[-1][1] = history[-1][1] or ""
91
  history[-1][1] += chunks
92
  yield history
 
9
  from langchain_core.prompts import PromptTemplate
10
  from langchain_community.embeddings import HuggingFaceEmbeddings
11
  import langchain
12
+ from langchain_groq.chat_models import ChatGroq
13
 
14
  # import json
15
  # import shutil
 
69
  self.db = Chroma(persist_directory="./pragetx_chroma", embedding_function=HuggingFaceEmbeddings(), collection_name="pragetx")
70
  # self.llm = ChatOllama(model="phi3:3.8b", base_url="http://localhost:11434", num_gpu=16)
71
  # self.llm = HuggingChat(email = os.getenv("HF_EMAIL") , psw = os.getenv("HF_PASS") )
72
+ # self.llm = HuggingChat(email = "brij1808" , psw = "Brijesh321@R" )
73
+ os.environ["GROQ_API_KEY"] = os.getenv("GROQ_API_KEY")
74
+ self.llm = ChatGroq(
75
+ model="gemma2-9b-it",
76
+ temperature=1,
77
+ max_tokens=512,
78
+ timeout=5,
79
+ max_retries=2,
80
+ )
81
+
82
  self.chain = (
83
  {"chat_history": self.chat_history, "context": self.db.as_retriever(search_kwargs={"k":3}), "question": RunnablePassthrough()} |
84
  self.prompt |
 
97
  print(history)
98
  prompt = history[-1][0] or ""
99
  for chunks in self.chain.stream(prompt):
100
+ print('chunks: ', chunks)
101
  history[-1][1] = history[-1][1] or ""
102
  history[-1][1] += chunks
103
  yield history
requirements.txt CHANGED
@@ -42,6 +42,7 @@ googleapis-common-protos==1.63.0
42
  gradio==4.31.5
43
  gradio_client==0.16.4
44
  greenlet==3.0.3
 
45
  grpcio==1.64.0
46
  h11==0.14.0
47
  httpcore==1.0.5
@@ -70,6 +71,7 @@ langchain==0.2.1
70
  langchain-chroma==0.1.1
71
  langchain-community==0.2.1
72
  langchain-core==0.2.1
 
73
  langchain-text-splitters==0.2.0
74
  langsmith==0.1.63
75
  lxml==5.2.2
 
42
  gradio==4.31.5
43
  gradio_client==0.16.4
44
  greenlet==3.0.3
45
+ # groq==0.11.0
46
  grpcio==1.64.0
47
  h11==0.14.0
48
  httpcore==1.0.5
 
71
  langchain-chroma==0.1.1
72
  langchain-community==0.2.1
73
  langchain-core==0.2.1
74
+ langchain-groq
75
  langchain-text-splitters==0.2.0
76
  langsmith==0.1.63
77
  lxml==5.2.2