WasifAKhan commited on
Commit
2171cbc
·
verified ·
1 Parent(s): 85094af

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -15
app.py CHANGED
@@ -59,7 +59,29 @@ client = Groq(api_key="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"
59
 
60
  # Predefined list of Google Drive links
61
  drive_links = [
62
- "https://drive.google.com/file/d/15ep4h17VFarb4coWAgqcEUDUTN7Ek6dr/view?usp=sharing"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  ]
64
 
65
  # Function to download PDF from Google Drive
@@ -103,20 +125,20 @@ def create_embeddings_and_store(chunks):
103
  return vector_db
104
 
105
  # Function to query the vector database and interact with Groq
106
- def query_vector_db(query, vector_db):
107
- # Retrieve relevant documents
108
- docs = vector_db.similarity_search(query, k=3)
109
- context = "\n".join([doc.page_content for doc in docs])
110
-
111
- # Interact with Groq API
112
- chat_completion = client.chat.completions.create(
113
- messages=[
114
- {"role": "system", "content": f"Use the following context:\n{context}"},
115
- {"role": "user", "content": query},
116
- ],
117
- model="llama3-8b-8192",
118
- )
119
- return chat_completion.choices[0].message.content
120
 
121
  # Streamlit app
122
  st.title("RAG-Based ChatBot (Already having Document)")
 
59
 
60
  # Predefined list of Google Drive links
61
  drive_links = [
62
+ "https://drive.google.com/file/d/15ep4h17VFarb4coWAgqcEUDUTN7Ek6dr/view?usp=sharing",
63
+ "https://drive.google.com/file/d/1ocxUsw4rVc9MNV_9wARvXg9D9SLe2vVi/view?usp=sharing",
64
+ "https://drive.google.com/file/d/1yrOTIlOYywjbfeMWcBG1kBK8-LLYGl3t/view?usp=sharing",
65
+ "https://drive.google.com/file/d/1otdel-JxaZBvitQQMiXtniTNAsmICrMT/view?usp=sharing",
66
+ "https://drive.google.com/file/d/16--HjKNn5Oz1cqX3b-8qvwnD0_yLvdy2/view?usp=sharing",
67
+ "https://drive.google.com/file/d/1lnBD-0H1mJJ8N-lNdrhomuzgm8nRFVxA/view?usp=sharing",
68
+ "https://drive.google.com/file/d/1ni7IxoI7j2wzCcWjQEEqrE1JO0HsRGrl/view?usp=sharing",
69
+ "https://drive.google.com/file/d/1s4QkcbTRsgT8Ju4O23gVpuh4Hy-dsHnb/view?usp=sharing",
70
+ "https://drive.google.com/file/d/1eRoAWgYqNsmYHVa90J2Tm0ejIMa_8qvZ/view?usp=sharing",
71
+ "https://drive.google.com/file/d/1r8SKClbsyAzYqOTfTEZXcQwf5YUEHPMG/view?usp=sharing",
72
+ "https://drive.google.com/file/d/1L-Lc_Yv14Tlu3waA3ufDwd4kzTkZfLHC/view?usp=sharing",
73
+ "https://drive.google.com/file/d/1bqz_eQkeo8Qc0OPaghIdQFMbDT9eFS77/view?usp=sharing",
74
+ "https://drive.google.com/file/d/1VSSNBc76yh_OtyBzuC_S43nrFMIc8Fw1/view?usp=sharing",
75
+ "https://drive.google.com/file/d/1NxQevabv6PPXxeXv5DZyeP8Q9GlHwD2r/view?usp=sharing",
76
+ "https://drive.google.com/file/d/1S_XKeDtPI_UBupnIURZTPiddmLbjqnRZ/view?usp=sharing",
77
+ "https://drive.google.com/file/d/1Bppf9VgUShBJWnYEw-4ZwDu5-A51nR9R/view?usp=sharing",
78
+ "https://drive.google.com/file/d/1s7z4TpFmMpvx1-PpYsaukACOSTrkbcOf/view?usp=sharing",
79
+ "https://drive.google.com/file/d/12Rrh0ixkQPvAAhExdnbMeol7c9aAzyTd/view?usp=sharing",
80
+ "https://drive.google.com/file/d/1BGq_aacZjmkEfAa2Oyzfw32piEQfBAmZ/view?usp=sharing",
81
+ "https://drive.google.com/file/d/1nxFqyFOa3C0TK8BLOYp-V6e_xjYGn0qV/view?usp=sharing",
82
+ "https://drive.google.com/file/d/1xsMYVFufaM2gzMPKADNCrDbGyq0rhSV2/view?usp=sharing"
83
+
84
+
85
  ]
86
 
87
  # Function to download PDF from Google Drive
 
125
  return vector_db
126
 
127
  # Function to query the vector database and interact with Groq
128
+ def query_vector_db(query, vector_db, selected_appliance):
129
+ # Filter documents based on appliance title
130
+ filtered_documents = [doc for doc in vector_db.documents if doc.title == selected_appliance]
131
+ context = "\n".join([doc.page_content for doc in filtered_documents])
132
+
133
+ # Interact with Groq API (unchanged)
134
+ chat_completion = client.chat.completions.create(
135
+ messages=[
136
+ {"role": "system", "content": f"Use the following context:\n{context}"},
137
+ {"role": "user", "content": query},
138
+ ],
139
+ model="llama3-8b-8192",
140
+ )
141
+ return chat_completion.choices[0].message.content
142
 
143
  # Streamlit app
144
  st.title("RAG-Based ChatBot (Already having Document)")