Cheh Kit Hong
commited on
Commit
·
c92c6b2
1
Parent(s):
6b84d68
patched tavily to latest
Browse files- agent/tools.py +7 -3
- requirements.txt +4 -1
agent/tools.py
CHANGED
|
@@ -3,12 +3,13 @@ from typing import List
|
|
| 3 |
from langchain_core.tools import tool
|
| 4 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
| 5 |
from langchain_chroma import Chroma
|
| 6 |
-
from
|
| 7 |
from langchain_community.document_loaders import WikipediaLoader, ArxivLoader
|
| 8 |
-
|
| 9 |
|
| 10 |
from config import configs
|
| 11 |
|
|
|
|
| 12 |
|
| 13 |
def intialize_chroma_vectorstore():
|
| 14 |
"""Initialize and return the Chroma vector store."""
|
|
@@ -33,7 +34,10 @@ def web_search_tavily(query: str) -> dict:
|
|
| 33 |
'source', 'page', and 'content'.
|
| 34 |
"""
|
| 35 |
try:
|
| 36 |
-
search_docs =
|
|
|
|
|
|
|
|
|
|
| 37 |
results = [
|
| 38 |
{
|
| 39 |
"title": doc.get("title", ""),
|
|
|
|
| 3 |
from langchain_core.tools import tool
|
| 4 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
| 5 |
from langchain_chroma import Chroma
|
| 6 |
+
from langchain_tavily import TavilySearch
|
| 7 |
from langchain_community.document_loaders import WikipediaLoader, ArxivLoader
|
| 8 |
+
from dotenv import load_dotenv
|
| 9 |
|
| 10 |
from config import configs
|
| 11 |
|
| 12 |
+
load_dotenv()
|
| 13 |
|
| 14 |
def intialize_chroma_vectorstore():
|
| 15 |
"""Initialize and return the Chroma vector store."""
|
|
|
|
| 34 |
'source', 'page', and 'content'.
|
| 35 |
"""
|
| 36 |
try:
|
| 37 |
+
search_docs = TavilySearch(
|
| 38 |
+
max_results=3,
|
| 39 |
+
topic="general",
|
| 40 |
+
).invoke({"query": query})["results"]
|
| 41 |
results = [
|
| 42 |
{
|
| 43 |
"title": doc.get("title", ""),
|
requirements.txt
CHANGED
|
@@ -14,4 +14,7 @@ langchain_text_splitters
|
|
| 14 |
pymupdf-layout
|
| 15 |
sentence_transformers
|
| 16 |
gradio
|
| 17 |
-
python-dotenv
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
pymupdf-layout
|
| 15 |
sentence_transformers
|
| 16 |
gradio
|
| 17 |
+
python-dotenv
|
| 18 |
+
langchain-tavily
|
| 19 |
+
arxiv
|
| 20 |
+
wikipedia
|