Update app.py
Browse files
app.py
CHANGED
|
@@ -45,9 +45,7 @@ def search_tavily(state):
|
|
| 45 |
""" Retrieve docs from web search """
|
| 46 |
|
| 47 |
# Search
|
| 48 |
-
tavily_search = TavilySearchResults(max_results=2)
|
| 49 |
-
|
| 50 |
-
search_docs = tavily_search.invoke(state['question'])
|
| 51 |
|
| 52 |
# Format
|
| 53 |
formatted_search_docs = "\n\n---\n\n".join(
|
|
@@ -65,7 +63,7 @@ def search_wikipedia(state):
|
|
| 65 |
""" Retrieve docs from wikipedia """
|
| 66 |
|
| 67 |
# Search
|
| 68 |
-
search_docs = WikipediaLoader(query=
|
| 69 |
load_max_docs=2).load()
|
| 70 |
|
| 71 |
# Format
|
|
@@ -85,7 +83,7 @@ def router(state: MessagesState):
|
|
| 85 |
return {"messages": [llm_with_tools.invoke(state["messages"])]}
|
| 86 |
|
| 87 |
|
| 88 |
-
builder = StateGraph(
|
| 89 |
builder.add_node("router", router)
|
| 90 |
builder.add_node("tools", ToolNode([search_tavily, search_wikipedia]))
|
| 91 |
builder.add_edge(START, "router")
|
|
|
|
| 45 |
""" Retrieve docs from web search """
|
| 46 |
|
| 47 |
# Search
|
| 48 |
+
tavily_search = TavilySearchResults(query=query, max_results=2)
|
|
|
|
|
|
|
| 49 |
|
| 50 |
# Format
|
| 51 |
formatted_search_docs = "\n\n---\n\n".join(
|
|
|
|
| 63 |
""" Retrieve docs from wikipedia """
|
| 64 |
|
| 65 |
# Search
|
| 66 |
+
search_docs = WikipediaLoader(query=query,
|
| 67 |
load_max_docs=2).load()
|
| 68 |
|
| 69 |
# Format
|
|
|
|
| 83 |
return {"messages": [llm_with_tools.invoke(state["messages"])]}
|
| 84 |
|
| 85 |
|
| 86 |
+
builder = StateGraph(MessagesState)
|
| 87 |
builder.add_node("router", router)
|
| 88 |
builder.add_node("tools", ToolNode([search_tavily, search_wikipedia]))
|
| 89 |
builder.add_edge(START, "router")
|