Spaces:
Sleeping
Sleeping
mchinea
commited on
Commit
·
86b31ff
1
Parent(s):
bb157b2
Update agent and tools
Browse files
agent.py
CHANGED
@@ -17,7 +17,7 @@ load_dotenv()
|
|
17 |
def build_agent_graph():
|
18 |
"""Build the graph"""
|
19 |
# Load environment variables from .env file
|
20 |
-
llm = ChatOpenAI(model="gpt-4o")
|
21 |
|
22 |
# Bind tools to LLM
|
23 |
llm_with_tools = llm.bind_tools(level1_tools)
|
@@ -64,14 +64,17 @@ class MyGAIAAgent:
|
|
64 |
def __call__(self, question: str) -> str:
|
65 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
66 |
# Wrap the question in a HumanMessage from langchain_core
|
67 |
-
|
68 |
messages = [HumanMessage(content=question)]
|
69 |
messages = self.graph.invoke({"messages": messages})
|
70 |
answer = messages['messages'][-1].content
|
|
|
71 |
'''
|
72 |
user_input = {"messages": [("user", question)]}
|
73 |
-
|
74 |
-
|
|
|
|
|
75 |
|
76 |
def _clean_answer(self, answer: any) -> str:
|
77 |
"""
|
@@ -137,5 +140,6 @@ class MyGAIAAgent:
|
|
137 |
if __name__ == "__main__":
|
138 |
question1 = "How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)?"
|
139 |
question2 = "Convert 10 miles to kilometers."
|
|
|
140 |
agent = MyGAIAAgent()
|
141 |
print(agent(question1))
|
|
|
17 |
def build_agent_graph():
|
18 |
"""Build the graph"""
|
19 |
# Load environment variables from .env file
|
20 |
+
llm = ChatOpenAI(model="gpt-4o-mini")
|
21 |
|
22 |
# Bind tools to LLM
|
23 |
llm_with_tools = llm.bind_tools(level1_tools)
|
|
|
64 |
def __call__(self, question: str) -> str:
|
65 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
66 |
# Wrap the question in a HumanMessage from langchain_core
|
67 |
+
|
68 |
messages = [HumanMessage(content=question)]
|
69 |
messages = self.graph.invoke({"messages": messages})
|
70 |
answer = messages['messages'][-1].content
|
71 |
+
|
72 |
'''
|
73 |
user_input = {"messages": [("user", question)]}
|
74 |
+
answer1 = self.graph.invoke(user_input)["messages"][-1].content
|
75 |
+
print (answer1)
|
76 |
+
'''
|
77 |
+
return answer
|
78 |
|
79 |
def _clean_answer(self, answer: any) -> str:
|
80 |
"""
|
|
|
140 |
if __name__ == "__main__":
|
141 |
question1 = "How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)?"
|
142 |
question2 = "Convert 10 miles to kilometers."
|
143 |
+
question3 = "Examine the video at https://www.youtube.com/watch?v=1htKBjuUWec. What does Teal'c say in response to the question ""Isn't that hot?"
|
144 |
agent = MyGAIAAgent()
|
145 |
print(agent(question1))
|
tools.py
CHANGED
@@ -6,7 +6,7 @@ import re
|
|
6 |
|
7 |
from typing import Dict
|
8 |
from pathlib import Path
|
9 |
-
from markitdown import MarkItDown
|
10 |
from urllib.parse import urlparse
|
11 |
|
12 |
from langchain_core.tools import tool
|
|
|
6 |
|
7 |
from typing import Dict
|
8 |
from pathlib import Path
|
9 |
+
#from markitdown import MarkItDown
|
10 |
from urllib.parse import urlparse
|
11 |
|
12 |
from langchain_core.tools import tool
|