Antoine101 commited on
Commit
1f88fc5
·
verified ·
1 Parent(s): 2dfba6a

Create tools.py

Browse files
Files changed (1) hide show
  1. tools.py +20 -0
tools.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain_community.retrievers import BM25Retriever
2
+ from langchain.tools import Tool
3
+
4
+
5
+
6
+ bm25_retriever = BM25Retriever.from_documents(docs)
7
+
8
+ def extract_text(query: str) -> str:
9
+ """Retrieves detailed information about gala guests based on their name or relation."""
10
+ results = bm25_retriever.invoke(query)
11
+ if results:
12
+ return "\n\n".join([doc.page_content for doc in results[:3]])
13
+ else:
14
+ return "No matching guest information found."
15
+
16
+ guest_info_tool = Tool(
17
+ name="guest_info_retriever",
18
+ func=extract_text,
19
+ description="Retrieves detailed information about gala guests based on their name or relation."
20
+ )