Spaces:
Sleeping
Sleeping
graph test
Browse files
app.py
CHANGED
|
@@ -7,8 +7,9 @@ from typing import Any, Dict, List, Optional, TypedDict
|
|
| 7 |
import gradio as gr
|
| 8 |
import pandas as pd
|
| 9 |
import requests
|
| 10 |
-
|
| 11 |
-
from langchain_community.
|
|
|
|
| 12 |
|
| 13 |
from langchain_core import messages
|
| 14 |
from langchain_core.messages import (
|
|
@@ -48,7 +49,8 @@ Extract ALL Parameters Identify search terms, URLs, code, file paths
|
|
| 48 |
Plan Steps: Break down the problem into logical steps required to reach the final answer
|
| 49 |
2. Delegate Strategically
|
| 50 |
For each step, choose the best Agent Tool. Call the tool with a single string argument `request` containing ALL information the specialist needs
|
| 51 |
-
Available Tools: `DuckDuckGoSearchAgent`, `CodeExecutorAgent`
|
|
|
|
| 52 |
- For general web searches, **strongly prefer** `DuckDuckGoSearchAgent` formatting the query like DuckDuckGoSearchAgent(`request`='search query') for potentially higher quality results"
|
| 53 |
- For standard Python execution, **strongly prefer** `CodeExecutorAgent` formatting the query like BuiltinCodeExecutorAgent(`request`='python code') for reliability."
|
| 54 |
|
|
@@ -141,7 +143,8 @@ class BasicAgent:
|
|
| 141 |
|
| 142 |
def wiki_search(self, state: AnswerState) -> Dict[str, Any]:
|
| 143 |
print("[wiki_search] Searching for: " + str(state["search_request"]))
|
| 144 |
-
|
|
|
|
| 145 |
results = wiki_tool.run(str(state["search_request"]))
|
| 146 |
print(f"Wiki results: {results}")
|
| 147 |
state["messages"].append(
|
|
|
|
| 7 |
import gradio as gr
|
| 8 |
import pandas as pd
|
| 9 |
import requests
|
| 10 |
+
|
| 11 |
+
from langchain_community.tools import DuckDuckGoSearchRun, WikipediaQueryRun
|
| 12 |
+
from langchain_community.utilities import WikipediaAPIWrapper
|
| 13 |
|
| 14 |
from langchain_core import messages
|
| 15 |
from langchain_core.messages import (
|
|
|
|
| 49 |
Plan Steps: Break down the problem into logical steps required to reach the final answer
|
| 50 |
2. Delegate Strategically
|
| 51 |
For each step, choose the best Agent Tool. Call the tool with a single string argument `request` containing ALL information the specialist needs
|
| 52 |
+
Available Tools: `DuckDuckGoSearchAgent`, `CodeExecutorAgent`, `WikipediaAgent`
|
| 53 |
+
- For wikipedia searches, **strongly prefer** `WikipediaAgent` formatting the query like WikipediaAgent(`request`='search query')
|
| 54 |
- For general web searches, **strongly prefer** `DuckDuckGoSearchAgent` formatting the query like DuckDuckGoSearchAgent(`request`='search query') for potentially higher quality results"
|
| 55 |
- For standard Python execution, **strongly prefer** `CodeExecutorAgent` formatting the query like BuiltinCodeExecutorAgent(`request`='python code') for reliability."
|
| 56 |
|
|
|
|
| 143 |
|
| 144 |
def wiki_search(self, state: AnswerState) -> Dict[str, Any]:
|
| 145 |
print("[wiki_search] Searching for: " + str(state["search_request"]))
|
| 146 |
+
api_wrapper = WikipediaAPIWrapper(top_k_results=1, doc_content_chars_max=5000)
|
| 147 |
+
wiki_tool = WikipediaQueryRun(api_wrapper=api_wrapper)
|
| 148 |
results = wiki_tool.run(str(state["search_request"]))
|
| 149 |
print(f"Wiki results: {results}")
|
| 150 |
state["messages"].append(
|