Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
from huggingface_hub import login
|
|
@@ -10,7 +14,7 @@ from chat.hermes_llm import ChatManager
|
|
| 10 |
load_dotenv()
|
| 11 |
|
| 12 |
# Login to Hugging Face
|
| 13 |
-
login(token=os.getenv("HUGGINGFACEHUB_API_TOKEN"), add_to_git_credential=True)
|
| 14 |
|
| 15 |
# Initialize components
|
| 16 |
VECTOR_DB_PATH = os.getenv("VECTOR_DB_PATH")
|
|
@@ -25,10 +29,11 @@ def process_query(query, chat_history):
|
|
| 25 |
if len(results)>0:
|
| 26 |
# Get response from chat manager
|
| 27 |
response = legal_chat.get_response(results[0]['content'], query=query)
|
|
|
|
| 28 |
else :
|
| 29 |
-
|
| 30 |
# Update chat history
|
| 31 |
-
chat_history.append((query,
|
| 32 |
return "", chat_history
|
| 33 |
except Exception as e:
|
| 34 |
return "", chat_history + [(query, f"Error: {str(e)}")]
|
|
|
|
| 1 |
+
<<<<<<< HEAD
|
| 2 |
+
|
| 3 |
+
=======
|
| 4 |
+
>>>>>>> 2c4af7da413c1e35cee9d0757790fe2b61319a1e
|
| 5 |
import gradio as gr
|
| 6 |
import os
|
| 7 |
from huggingface_hub import login
|
|
|
|
| 14 |
load_dotenv()
|
| 15 |
|
| 16 |
# Login to Hugging Face
|
| 17 |
+
# login(token=os.getenv("HUGGINGFACEHUB_API_TOKEN"), add_to_git_credential=True)
|
| 18 |
|
| 19 |
# Initialize components
|
| 20 |
VECTOR_DB_PATH = os.getenv("VECTOR_DB_PATH")
|
|
|
|
| 29 |
if len(results)>0:
|
| 30 |
# Get response from chat manager
|
| 31 |
response = legal_chat.get_response(results[0]['content'], query=query)
|
| 32 |
+
response_final = f"""{response}\n\nsource:[case_id:{results[0]['metadata']['case_id']}]"""
|
| 33 |
else :
|
| 34 |
+
response_final = "No Document match"
|
| 35 |
# Update chat history
|
| 36 |
+
chat_history.append((query, response_final))
|
| 37 |
return "", chat_history
|
| 38 |
except Exception as e:
|
| 39 |
return "", chat_history + [(query, f"Error: {str(e)}")]
|