Spaces:
Starting
Starting
import datasets | |
from langchain.docstore.document import Document | |
from langchain_community.retrievers import BM25Retriever | |
from smolagents import Tool | |
def load_guest_dataset(): | |
try: | |
guest_dataset = datasets.load_dataset("agents-course/unit3-invitees", split="train") | |
docs = [ | |
Document( | |
page_content="\n".join([ | |
f"Name: {guest['name']}", | |
f"Relation: {guest['relation']}", | |
f"Description: {guest['description']}", | |
f"Email: {guest['email']}" | |
]), | |
metadata={"name": guest["name"]} | |
) | |
for guest in guest_dataset | |
] | |
except Exception as e: | |
# Fallback mock dataset | |
docs = [ | |
Document( | |
page_content="\n".join([ | |
"Name: Dr. Nikola Tesla", | |
"Relation: old friend from university days", | |
"Description: Dr. Nikola Tesla is an old friend from your university days. He's recently patented a new wireless energy transmission system.", | |
"Email: nikola.tesla@gmail.com" | |
]), | |
metadata={"name": "Dr. Nikola Tesla"} | |
) | |
] | |
return docs |