Update agent.py
Browse files
agent.py
CHANGED
|
@@ -162,8 +162,6 @@ def wikipedia_search(query: str) -> str:
|
|
| 162 |
|
| 163 |
if not search_results:
|
| 164 |
return f"No Wikipedia results found for {query}. Consider another query or try a web search."
|
| 165 |
-
print("Result from wikipedia:")
|
| 166 |
-
print(search_results)
|
| 167 |
return "---\n".join(
|
| 168 |
f"Title: {doc.metadata.get('title', 'Unknown')}\n"
|
| 169 |
f"Content: {doc.page_content}"
|
|
@@ -174,6 +172,17 @@ def wikipedia_search(query: str) -> str:
|
|
| 174 |
return f"Wikipedia search failed for {query} due to {e}."
|
| 175 |
|
| 176 |
search_web = DuckDuckGoSearchRun()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
model = build_gemini_llm()
|
| 178 |
tools = [
|
| 179 |
search_web,
|
|
|
|
| 162 |
|
| 163 |
if not search_results:
|
| 164 |
return f"No Wikipedia results found for {query}. Consider another query or try a web search."
|
|
|
|
|
|
|
| 165 |
return "---\n".join(
|
| 166 |
f"Title: {doc.metadata.get('title', 'Unknown')}\n"
|
| 167 |
f"Content: {doc.page_content}"
|
|
|
|
| 172 |
return f"Wikipedia search failed for {query} due to {e}."
|
| 173 |
|
| 174 |
search_web = DuckDuckGoSearchRun()
|
| 175 |
+
try:
|
| 176 |
+
result = search_web.invoke(
|
| 177 |
+
'site:en.wikipedia.org "Mercedes Sosa" "Discography" "Studio albums"'
|
| 178 |
+
)
|
| 179 |
+
|
| 180 |
+
print("TYPE:", type(result))
|
| 181 |
+
print("RESULT:", repr(result))
|
| 182 |
+
|
| 183 |
+
except Exception as e:
|
| 184 |
+
print("ERROR TYPE:", type(e))
|
| 185 |
+
print("ERROR:", repr(e))
|
| 186 |
model = build_gemini_llm()
|
| 187 |
tools = [
|
| 188 |
search_web,
|