Spaces:
Runtime error
Runtime error
Shrirang20
commited on
Commit
•
057b7fe
1
Parent(s):
8e08702
Update app.py
Browse files
app.py
CHANGED
@@ -366,22 +366,20 @@ def process_user_query(user_query, retrieved_doc):
|
|
366 |
return processed_doc
|
367 |
|
368 |
#Context awareness
|
369 |
-
from collections import deque
|
370 |
|
371 |
-
class ContextManger:
|
372 |
-
|
373 |
-
|
374 |
|
375 |
-
|
376 |
-
|
377 |
|
378 |
-
|
379 |
-
|
380 |
|
381 |
-
context_manager = ContextManger()
|
382 |
|
383 |
-
# context = context_manager.get_context()
|
384 |
-
# contexulized_query = f"Previous context: {context} \n\nCurrent query: {indic_to_en}"
|
385 |
|
386 |
import traceback
|
387 |
|
@@ -395,20 +393,19 @@ def process_gradio_input(audio, user_lang):
|
|
395 |
print(f"Translating indic to en..")
|
396 |
indic_to_en = indic_translate(src_lang=user_lang, tgt_lang="english", sents_to_translate=[query_transcription])[0]
|
397 |
|
398 |
-
# context_manager = ContextManager()
|
399 |
|
400 |
-
context = context_manager.get_context()
|
401 |
-
contexulized_query = f"Previous context: {context} \n\nCurrent query: {indic_to_en}"
|
402 |
|
403 |
# Query the Vector DB to get the relevant document from the query
|
404 |
print(f"Querying vector db")
|
405 |
-
retrieved_doc = query_vector_db(
|
406 |
|
407 |
# Extract relevant information from the retrieved document
|
408 |
print(f"Processing user query")
|
409 |
-
processed_doc = process_user_query(user_query=
|
410 |
|
411 |
-
context_manager.add_interaction(indic_to_en, processed_doc)
|
412 |
|
413 |
# Break the document into chunks for faster batch processing
|
414 |
print(f"Breaking document into chunks..")
|
|
|
366 |
return processed_doc
|
367 |
|
368 |
#Context awareness
|
369 |
+
# from collections import deque
|
370 |
|
371 |
+
# class ContextManger:
|
372 |
+
# def __init__(self,max_history=7):
|
373 |
+
# self.history = deque(maxlen=max_history)
|
374 |
|
375 |
+
# def add_interaction(self,query,response):
|
376 |
+
# self.history.append((query,response))
|
377 |
|
378 |
+
# def get_context(self):
|
379 |
+
# return list(self.history)
|
380 |
|
381 |
+
# context_manager = ContextManger()
|
382 |
|
|
|
|
|
383 |
|
384 |
import traceback
|
385 |
|
|
|
393 |
print(f"Translating indic to en..")
|
394 |
indic_to_en = indic_translate(src_lang=user_lang, tgt_lang="english", sents_to_translate=[query_transcription])[0]
|
395 |
|
|
|
396 |
|
397 |
+
# context = context_manager.get_context()
|
398 |
+
# contexulized_query = f"Previous context: {context} \n\nCurrent query: {indic_to_en}"
|
399 |
|
400 |
# Query the Vector DB to get the relevant document from the query
|
401 |
print(f"Querying vector db")
|
402 |
+
retrieved_doc = query_vector_db(indic_to_en)
|
403 |
|
404 |
# Extract relevant information from the retrieved document
|
405 |
print(f"Processing user query")
|
406 |
+
processed_doc = process_user_query(user_query=indic_to_en, retrieved_doc=retrieved_doc)
|
407 |
|
408 |
+
# context_manager.add_interaction(indic_to_en, processed_doc)
|
409 |
|
410 |
# Break the document into chunks for faster batch processing
|
411 |
print(f"Breaking document into chunks..")
|