Neurolingua
commited on
Commit
•
d9b7a74
1
Parent(s):
21b1bc4
Update app.py
Browse files
app.py
CHANGED
@@ -192,6 +192,19 @@ def download_and_save_as_txt(url, account_sid, auth_token):
|
|
192 |
except Exception as err:
|
193 |
print(f"An error occurred: {err}")
|
194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
def query_rag(query_text: str):
|
196 |
embedding_function = get_embedding_function()
|
197 |
db = Chroma(persist_directory=CHROMA_PATH, embedding_function=embedding_function)
|
@@ -214,6 +227,7 @@ def query_rag(query_text: str):
|
|
214 |
response += chunk.choices[0].delta.content
|
215 |
|
216 |
return response.replace("###", '').replace('\nUser:', '')
|
|
|
217 |
def download_file(url, extension):
|
218 |
try:
|
219 |
response = requests.get(url)
|
|
|
192 |
except Exception as err:
|
193 |
print(f"An error occurred: {err}")
|
194 |
|
195 |
+
|
196 |
+
def initialize_chroma():
|
197 |
+
try:
|
198 |
+
# Initialize Chroma
|
199 |
+
db = Chroma(persist_directory=CHROMA_PATH, embedding_function=get_embedding_function())
|
200 |
+
# Perform an initial operation to ensure it works
|
201 |
+
db.similarity_search_with_score("test query", k=1)
|
202 |
+
print("Chroma initialized successfully.")
|
203 |
+
except Exception as e:
|
204 |
+
print(f"Error initializing Chroma: {e}")
|
205 |
+
|
206 |
+
initialize_chroma()
|
207 |
+
|
208 |
def query_rag(query_text: str):
|
209 |
embedding_function = get_embedding_function()
|
210 |
db = Chroma(persist_directory=CHROMA_PATH, embedding_function=embedding_function)
|
|
|
227 |
response += chunk.choices[0].delta.content
|
228 |
|
229 |
return response.replace("###", '').replace('\nUser:', '')
|
230 |
+
|
231 |
def download_file(url, extension):
|
232 |
try:
|
233 |
response = requests.get(url)
|