Commit
·
88f8d22
1
Parent(s):
b1cd264
async update
Browse files- app.py +1 -1
- langraph_agent.py +9 -9
app.py
CHANGED
|
@@ -27,7 +27,7 @@ class BasicAgent:
|
|
| 27 |
messages = [HumanMessage(content=question)]
|
| 28 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 29 |
try:
|
| 30 |
-
response = await self.agent.
|
| 31 |
print(f"Agent raw response: {response}")
|
| 32 |
if not response or 'messages' not in response or not response['messages']:
|
| 33 |
print("Agent response missing or empty 'messages'. Returning AGENT ERROR.")
|
|
|
|
| 27 |
messages = [HumanMessage(content=question)]
|
| 28 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 29 |
try:
|
| 30 |
+
response = await self.agent.ainvoke({"messages": messages}, config={"callbacks": [langfuse_handler]})
|
| 31 |
print(f"Agent raw response: {response}")
|
| 32 |
if not response or 'messages' not in response or not response['messages']:
|
| 33 |
print("Agent response missing or empty 'messages'. Returning AGENT ERROR.")
|
langraph_agent.py
CHANGED
|
@@ -85,13 +85,13 @@ def modulus(a: int, b: int) -> int:
|
|
| 85 |
return a % b
|
| 86 |
|
| 87 |
@tool
|
| 88 |
-
def wiki_search(
|
| 89 |
"""Search Wikipedia for a query and return maximum 2 results.
|
| 90 |
|
| 91 |
Args:
|
| 92 |
-
|
| 93 |
try:
|
| 94 |
-
search_docs = WikipediaLoader(query=
|
| 95 |
if not search_docs:
|
| 96 |
return {"wiki_results": "No Wikipedia results found for the query."}
|
| 97 |
formatted_search_docs = "\n\n---\n\n".join(
|
|
@@ -105,13 +105,13 @@ def wiki_search(query: str) -> str:
|
|
| 105 |
return {"wiki_results": f"Error searching Wikipedia: {e}"}
|
| 106 |
|
| 107 |
@tool
|
| 108 |
-
def web_search(
|
| 109 |
"""Search Tavily for a query and return maximum 3 results.
|
| 110 |
|
| 111 |
Args:
|
| 112 |
-
|
| 113 |
try:
|
| 114 |
-
search_docs = TavilySearchResults(max_results=3).invoke(query=
|
| 115 |
if not search_docs:
|
| 116 |
return {"web_results": "No web search results found for the query."}
|
| 117 |
formatted_search_docs = "\n\n---\n\n".join(
|
|
@@ -125,13 +125,13 @@ def web_search(query: str) -> str:
|
|
| 125 |
return {"web_results": f"Error searching web: {e}"}
|
| 126 |
|
| 127 |
@tool
|
| 128 |
-
def arvix_search(
|
| 129 |
"""Search Arxiv for a query and return maximum 3 result.
|
| 130 |
|
| 131 |
Args:
|
| 132 |
-
|
| 133 |
try:
|
| 134 |
-
search_docs = ArxivLoader(query=
|
| 135 |
if not search_docs:
|
| 136 |
return {"arvix_results": "No Arxiv results found for the query."}
|
| 137 |
formatted_search_docs = "\n\n---\n\n".join(
|
|
|
|
| 85 |
return a % b
|
| 86 |
|
| 87 |
@tool
|
| 88 |
+
def wiki_search(input: str) -> str:
|
| 89 |
"""Search Wikipedia for a query and return maximum 2 results.
|
| 90 |
|
| 91 |
Args:
|
| 92 |
+
input: The search query."""
|
| 93 |
try:
|
| 94 |
+
search_docs = WikipediaLoader(query=input, load_max_docs=2).load()
|
| 95 |
if not search_docs:
|
| 96 |
return {"wiki_results": "No Wikipedia results found for the query."}
|
| 97 |
formatted_search_docs = "\n\n---\n\n".join(
|
|
|
|
| 105 |
return {"wiki_results": f"Error searching Wikipedia: {e}"}
|
| 106 |
|
| 107 |
@tool
|
| 108 |
+
def web_search(input: str) -> str:
|
| 109 |
"""Search Tavily for a query and return maximum 3 results.
|
| 110 |
|
| 111 |
Args:
|
| 112 |
+
input: The search query."""
|
| 113 |
try:
|
| 114 |
+
search_docs = TavilySearchResults(max_results=3).invoke(query=input)
|
| 115 |
if not search_docs:
|
| 116 |
return {"web_results": "No web search results found for the query."}
|
| 117 |
formatted_search_docs = "\n\n---\n\n".join(
|
|
|
|
| 125 |
return {"web_results": f"Error searching web: {e}"}
|
| 126 |
|
| 127 |
@tool
|
| 128 |
+
def arvix_search(input: str) -> str:
|
| 129 |
"""Search Arxiv for a query and return maximum 3 result.
|
| 130 |
|
| 131 |
Args:
|
| 132 |
+
input: The search query."""
|
| 133 |
try:
|
| 134 |
+
search_docs = ArxivLoader(query=input, load_max_docs=3).load()
|
| 135 |
if not search_docs:
|
| 136 |
return {"arvix_results": "No Arxiv results found for the query."}
|
| 137 |
formatted_search_docs = "\n\n---\n\n".join(
|