Spaces:
Sleeping
Sleeping
Update agent.py
Browse files
agent.py
CHANGED
|
@@ -16,6 +16,18 @@ from langchain_core.tools import tool
|
|
| 16 |
from langchain.tools.retriever import create_retriever_tool
|
| 17 |
from supabase.client import Client, create_client
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
load_dotenv()
|
| 20 |
|
| 21 |
@tool
|
|
|
|
| 16 |
from langchain.tools.retriever import create_retriever_tool
|
| 17 |
from supabase.client import Client, create_client
|
| 18 |
|
| 19 |
+
class BasicAgent:
|
| 20 |
+
def __init__(self, provider="groq"):
|
| 21 |
+
self.graph = build_graph(provider=provider)
|
| 22 |
+
|
| 23 |
+
def run(self, question: str) -> str:
|
| 24 |
+
messages = [HumanMessage(content=question)]
|
| 25 |
+
response = self.graph.invoke({"messages": messages})
|
| 26 |
+
# Return the last message from the assistant node (the answer)
|
| 27 |
+
return response["messages"][-1].content
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
|
| 31 |
load_dotenv()
|
| 32 |
|
| 33 |
@tool
|