Spaces:
Sleeping
Sleeping
Update agent.py
Browse files
agent.py
CHANGED
|
@@ -7,7 +7,7 @@ from langchain_core.messages import HumanMessage
|
|
| 7 |
from langchain_core.prompts import ChatPromptTemplate
|
| 8 |
|
| 9 |
# 1. Web Browsing
|
| 10 |
-
from langchain_community.tools import
|
| 11 |
from langchain_community.document_loaders import ImageCaptionLoader
|
| 12 |
import requests, time
|
| 13 |
import pandas as pd
|
|
@@ -22,7 +22,7 @@ def web_search(query: str) -> str:
|
|
| 22 |
Args:
|
| 23 |
query: what you want to search
|
| 24 |
"""
|
| 25 |
-
search =
|
| 26 |
results = search.invoke(query)
|
| 27 |
return "\n".join(results)
|
| 28 |
|
|
@@ -158,7 +158,7 @@ class BasicAgent:
|
|
| 158 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 159 |
# response = self.agent_exe.invoke({"input": f"Question: {question}"})
|
| 160 |
# fixed_answer = response['message'][-1].content
|
| 161 |
-
time.sleep(15)
|
| 162 |
fixed_answer = self.agent.run(f"Answer this question: {question}")
|
| 163 |
# fixed_answer = "This is a default answer."
|
| 164 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
|
|
|
| 7 |
from langchain_core.prompts import ChatPromptTemplate
|
| 8 |
|
| 9 |
# 1. Web Browsing
|
| 10 |
+
from langchain_community.tools import DuckDuckGoSearchResults
|
| 11 |
from langchain_community.document_loaders import ImageCaptionLoader
|
| 12 |
import requests, time
|
| 13 |
import pandas as pd
|
|
|
|
| 22 |
Args:
|
| 23 |
query: what you want to search
|
| 24 |
"""
|
| 25 |
+
search = DuckDuckGoSearchResults()
|
| 26 |
results = search.invoke(query)
|
| 27 |
return "\n".join(results)
|
| 28 |
|
|
|
|
| 158 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 159 |
# response = self.agent_exe.invoke({"input": f"Question: {question}"})
|
| 160 |
# fixed_answer = response['message'][-1].content
|
| 161 |
+
# time.sleep(15)
|
| 162 |
fixed_answer = self.agent.run(f"Answer this question: {question}")
|
| 163 |
# fixed_answer = "This is a default answer."
|
| 164 |
print(f"Agent returning fixed answer: {fixed_answer}")
|