Spaces:
Sleeping
Sleeping
update wikipedia tool
Browse files
agent.py
CHANGED
|
@@ -12,7 +12,8 @@ from langchain_community.document_loaders import ImageCaptionLoader
|
|
| 12 |
import requests
|
| 13 |
import pandas as pd
|
| 14 |
from pypdf import PdfReader
|
| 15 |
-
from
|
|
|
|
| 16 |
from youtube_transcript_api import YouTubeTranscriptApi
|
| 17 |
|
| 18 |
@tool
|
|
@@ -43,7 +44,9 @@ def wiki_search(query: str) -> str:
|
|
| 43 |
Args:
|
| 44 |
query: what you want to wiki
|
| 45 |
"""
|
| 46 |
-
|
|
|
|
|
|
|
| 47 |
|
| 48 |
|
| 49 |
@tool
|
|
|
|
| 12 |
import requests
|
| 13 |
import pandas as pd
|
| 14 |
from pypdf import PdfReader
|
| 15 |
+
from langchain_community.tools import WikipediaQueryRun
|
| 16 |
+
from langchain_community.utilities import WikipediaAPIWrapper
|
| 17 |
from youtube_transcript_api import YouTubeTranscriptApi
|
| 18 |
|
| 19 |
@tool
|
|
|
|
| 44 |
Args:
|
| 45 |
query: what you want to wiki
|
| 46 |
"""
|
| 47 |
+
api_wrapper = WikipediaAPIWrapper(top_k_results=1, doc_content_chars_max=100)
|
| 48 |
+
wikipediatool = WikipediaQueryRun(api_wrapper=api_wrapper)
|
| 49 |
+
return wikipediatool.run({"query": query})
|
| 50 |
|
| 51 |
|
| 52 |
@tool
|