Spaces:
Runtime error
Runtime error
File size: 648 Bytes
3fb867c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
from langchain_community.retrievers import BM25Retriever
from langchain.tools import Tool
bm25_retriever = BM25Retriever.from_documents(docs)
def extract_text(query: str) -> str:
"""Retrieves detailed information about gala guests based on their name or relation."""
results = bm25_retriever.invoke(query)
if results:
return "\n\n".join([doc.page_content for doc in results[:3]])
else:
return "No matching guest information found."
guest_info_tool = Tool(
name="guest_info_retriever",
func=extract_text,
description="Retrieves detailed information about gala guests based on their name or relation."
) |