Spaces:
Sleeping
Sleeping
Download retriever.py from JetzeJ/AlfredAgent: direct link, hf CLI and curl.
- Browser
- Download file 676 Bytes
-
https://huggingface.co/spaces/JetzeJ/AlfredAgent/resolve/main/retriever.py
- Command line
-
hf download hf://spaces/JetzeJ/AlfredAgent/retriever.py
-
curl -L -o retriever.py https://huggingface.co/spaces/JetzeJ/AlfredAgent/resolve/main/retriever.py
676 Bytes
| from langchain_community.retrievers import BM25Retriever | |
| from langchain_core.tools import Tool | |
| from tools import docs | |
| 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." | |
| ) |