Spaces:
Runtime error
Runtime error
abtsousa
commited on
Commit
·
94d07d4
1
Parent(s):
692b974
Refactor wiki_search function: replace WikipediaLoader with WikipediaQueryRun
Browse files- tools/wikipedia.py +5 -3
tools/wikipedia.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
from langchain_core.tools import tool
|
| 2 |
-
from langchain_community.
|
|
|
|
| 3 |
|
| 4 |
@tool
|
| 5 |
def wiki_search(query: str) -> str:
|
|
@@ -9,5 +10,6 @@ def wiki_search(query: str) -> str:
|
|
| 9 |
Args:
|
| 10 |
query (str): The search query to find relevant Wikipedia articles.
|
| 11 |
"""
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
| 1 |
from langchain_core.tools import tool
|
| 2 |
+
from langchain_community.tools import WikipediaQueryRun
|
| 3 |
+
from langchain_community.utilities import WikipediaAPIWrapper
|
| 4 |
|
| 5 |
@tool
|
| 6 |
def wiki_search(query: str) -> str:
|
|
|
|
| 10 |
Args:
|
| 11 |
query (str): The search query to find relevant Wikipedia articles.
|
| 12 |
"""
|
| 13 |
+
wikipedia = WikipediaQueryRun(api_wrapper=WikipediaAPIWrapper(top_k_results=1, doc_content_chars_max=32000)) # type: ignore
|
| 14 |
+
result = wikipedia.run(query)
|
| 15 |
+
return result
|