Spaces:
Sleeping
Sleeping
graph test
Browse files- app.py +3 -4
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -8,7 +8,6 @@ import gradio as gr
|
|
| 8 |
import pandas as pd
|
| 9 |
import requests
|
| 10 |
from langchain_community.retrievers import WikipediaRetriever
|
| 11 |
-
|
| 12 |
from langchain_community.tools import DuckDuckGoSearchRun, WikipediaQueryRun
|
| 13 |
from langchain_community.utilities import WikipediaAPIWrapper
|
| 14 |
|
|
@@ -21,13 +20,13 @@ from langchain_core.messages import (
|
|
| 21 |
ToolCall,
|
| 22 |
ToolMessage,
|
| 23 |
)
|
|
|
|
| 24 |
from langchain_openai import ChatOpenAI
|
| 25 |
from langgraph.graph import END, START, StateGraph
|
| 26 |
|
| 27 |
|
| 28 |
hf_token = os.getenv("OPENAI_API_KEY")
|
| 29 |
|
| 30 |
-
|
| 31 |
# (Keep Constants as is)
|
| 32 |
# --- Constants ---
|
| 33 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
@@ -178,8 +177,8 @@ class BasicAgent:
|
|
| 178 |
|
| 179 |
def web_search(self, state: AnswerState) -> Dict[str, Any]:
|
| 180 |
print("[web_search] Searching for: " + str(state["search_request"]))
|
| 181 |
-
search_tool =
|
| 182 |
-
results = search_tool.
|
| 183 |
print(f"Search results: {results}")
|
| 184 |
state["messages"].append(
|
| 185 |
ChatMessage(
|
|
|
|
| 8 |
import pandas as pd
|
| 9 |
import requests
|
| 10 |
from langchain_community.retrievers import WikipediaRetriever
|
|
|
|
| 11 |
from langchain_community.tools import DuckDuckGoSearchRun, WikipediaQueryRun
|
| 12 |
from langchain_community.utilities import WikipediaAPIWrapper
|
| 13 |
|
|
|
|
| 20 |
ToolCall,
|
| 21 |
ToolMessage,
|
| 22 |
)
|
| 23 |
+
from langchain_google_community.search import GoogleSearchAPIWrapper
|
| 24 |
from langchain_openai import ChatOpenAI
|
| 25 |
from langgraph.graph import END, START, StateGraph
|
| 26 |
|
| 27 |
|
| 28 |
hf_token = os.getenv("OPENAI_API_KEY")
|
| 29 |
|
|
|
|
| 30 |
# (Keep Constants as is)
|
| 31 |
# --- Constants ---
|
| 32 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
|
|
| 177 |
|
| 178 |
def web_search(self, state: AnswerState) -> Dict[str, Any]:
|
| 179 |
print("[web_search] Searching for: " + str(state["search_request"]))
|
| 180 |
+
search_tool = GoogleSearchAPIWrapper()
|
| 181 |
+
results = search_tool.run(str(state["search_request"]))
|
| 182 |
print(f"Search results: {results}")
|
| 183 |
state["messages"].append(
|
| 184 |
ChatMessage(
|
requirements.txt
CHANGED
|
@@ -9,3 +9,4 @@ langchain-community
|
|
| 9 |
ddgs
|
| 10 |
duckduckgo-search
|
| 11 |
wikipedia
|
|
|
|
|
|
| 9 |
ddgs
|
| 10 |
duckduckgo-search
|
| 11 |
wikipedia
|
| 12 |
+
langchain-google-community
|