Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,8 @@ import gradio as gr
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
6 |
-
from
|
|
|
7 |
|
8 |
|
9 |
# (Keep Constants as is)
|
@@ -13,20 +14,22 @@ user_name = "rahulraj42"
|
|
13 |
|
14 |
# --- Basic Agent Definition ---
|
15 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
|
|
16 |
class BasicAgent:
|
|
|
17 |
def __init__(self):
|
18 |
-
print(f"{user_name}")
|
19 |
print("BasicAgent initialized.")
|
|
|
|
|
20 |
def __call__(self, question: str) -> str:
|
21 |
-
print(f"{user_name}")
|
22 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
|
31 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
32 |
"""
|
@@ -38,7 +41,6 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
38 |
|
39 |
if profile:
|
40 |
username= f"{profile.username}"
|
41 |
-
print(f"{user_name}")
|
42 |
print(f"User logged in: {username}")
|
43 |
else:
|
44 |
print(f"{user_name}")
|
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
6 |
+
from langchain_core.messages import HumanMessage
|
7 |
+
from agent import build_graph
|
8 |
|
9 |
|
10 |
# (Keep Constants as is)
|
|
|
14 |
|
15 |
# --- Basic Agent Definition ---
|
16 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
17 |
+
|
18 |
class BasicAgent:
|
19 |
+
"""A langgraph agent."""
|
20 |
def __init__(self):
|
|
|
21 |
print("BasicAgent initialized.")
|
22 |
+
self.graph = build_graph()
|
23 |
+
|
24 |
def __call__(self, question: str) -> str:
|
|
|
25 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
26 |
+
# Wrap the question in a HumanMessage from langchain_core
|
27 |
+
messages = [HumanMessage(content=question)]
|
28 |
+
messages = self.graph.invoke({"messages": messages})
|
29 |
+
answer = messages['messages'][-1].content
|
30 |
+
return answer[14:]
|
31 |
+
|
32 |
+
|
33 |
|
34 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
35 |
"""
|
|
|
41 |
|
42 |
if profile:
|
43 |
username= f"{profile.username}"
|
|
|
44 |
print(f"User logged in: {username}")
|
45 |
else:
|
46 |
print(f"{user_name}")
|