Yongkang ZOU
commited on
Commit
·
b7d2d3d
1
Parent(s):
8667b0a
update agent
Browse files- .gitignore +2 -0
- agent.py +9 -4
.gitignore
CHANGED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
venv/
|
2 |
+
.env
|
agent.py
CHANGED
@@ -53,8 +53,13 @@ def wiki_search(query: str) -> str:
|
|
53 |
@tool
|
54 |
def web_search(query: str) -> str:
|
55 |
"""Search the web using Tavily (max 3 results)."""
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
@tool
|
60 |
def arvix_search(query: str) -> str:
|
@@ -124,8 +129,8 @@ def build_graph(provider: str = "groq"):
|
|
124 |
# ------------------- LOCAL TEST -------------------
|
125 |
|
126 |
if __name__ == "__main__":
|
127 |
-
question = "
|
128 |
-
graph = build_graph(provider="
|
129 |
messages = graph.invoke({"messages": [HumanMessage(content=question)]})
|
130 |
print("=== AI Agent Response ===")
|
131 |
for m in messages["messages"]:
|
|
|
53 |
@tool
|
54 |
def web_search(query: str) -> str:
|
55 |
"""Search the web using Tavily (max 3 results)."""
|
56 |
+
results = TavilySearchResults(max_results=3).invoke(query)
|
57 |
+
texts = []
|
58 |
+
for doc in results:
|
59 |
+
if isinstance(doc, dict):
|
60 |
+
texts.append(doc.get("content", "") or doc.get("text", ""))
|
61 |
+
return "\n\n".join(texts)
|
62 |
+
|
63 |
|
64 |
@tool
|
65 |
def arvix_search(query: str) -> str:
|
|
|
129 |
# ------------------- LOCAL TEST -------------------
|
130 |
|
131 |
if __name__ == "__main__":
|
132 |
+
question = "When was a picture of St. Thomas Aquinas first added to the Wikipedia page on the Principle of double effect?"
|
133 |
+
graph = build_graph(provider="openai")
|
134 |
messages = graph.invoke({"messages": [HumanMessage(content=question)]})
|
135 |
print("=== AI Agent Response ===")
|
136 |
for m in messages["messages"]:
|