Download retriever.py from Janneyffr/API: direct link, hf CLI and curl.
- Browser
- Download file 535 Bytes
-
https://huggingface.co/spaces/Janneyffr/API/resolve/main/retriever.py
- Command line
-
hf download hf://spaces/Janneyffr/API/retriever.py
-
curl -L -o retriever.py https://huggingface.co/spaces/Janneyffr/API/resolve/main/retriever.py
535 Bytes
| import datasets | |
| from langchain_core.documents import Document | |
| # 加载数据集 | |
| guest_dataset = datasets.load_dataset("agents-course/unit3-invitees", split="train") | |
| # 转换为 Document 对象 | |
| 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 | |
| ] |