Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,6 +6,7 @@ import requests
|
|
| 6 |
import pandas as pd
|
| 7 |
from langchain_core.messages import HumanMessage
|
| 8 |
from agent import build_graph
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
|
|
@@ -23,13 +24,17 @@ class BasicAgent:
|
|
| 23 |
print("BasicAgent initialized.")
|
| 24 |
self.graph = build_graph()
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
messages = [HumanMessage(content=question)]
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
|
| 35 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
|
|
| 6 |
import pandas as pd
|
| 7 |
from langchain_core.messages import HumanMessage
|
| 8 |
from agent import build_graph
|
| 9 |
+
from langchain_google_genai import ChatGoogleGenerativeAi
|
| 10 |
|
| 11 |
|
| 12 |
|
|
|
|
| 24 |
print("BasicAgent initialized.")
|
| 25 |
self.graph = build_graph()
|
| 26 |
|
| 27 |
+
def __call__(self, question: str) -> str:
|
| 28 |
+
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 29 |
+
try:
|
| 30 |
messages = [HumanMessage(content=question)]
|
| 31 |
+
response = self.graph.invoke({"messages": messages})
|
| 32 |
+
final_msg = response['messages'][-1].content
|
| 33 |
+
return final_msg[14:] if len(final_msg) > 14 else final_msg
|
| 34 |
+
except Exception as e:
|
| 35 |
+
print(f"Error during invocation: {e}")
|
| 36 |
+
return "Sorry, I encountered an error while processing your question."
|
| 37 |
+
|
| 38 |
|
| 39 |
|
| 40 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|