Download src/agentic_rag/data_loader.py from hibanail/langgraph-demo: direct link, hf CLI and curl.
- Browser
- Download file 854 Bytes
-
https://huggingface.co/hibanail/langgraph-demo/resolve/main/src/agentic_rag/data_loader.py
- Command line
-
hf download hf://hibanail/langgraph-demo/src/agentic_rag/data_loader.py
-
curl -L -o data_loader.py https://huggingface.co/hibanail/langgraph-demo/resolve/main/src/agentic_rag/data_loader.py
854 Bytes
| from datasets import load_dataset | |
| from langchain_core.documents import Document | |
| # The Hugging Face dataset is similar to a database table, | |
| # and we're converting each row into a Document object. | |
| def load_guest_documents() -> list[Document]: | |
| dataset = load_dataset( | |
| "agents-course/unit3-invitees", | |
| split="train" | |
| ) | |
| documents = [] | |
| for index, guest in enumerate(dataset): | |
| document = Document( | |
| page_content="\n".join([ | |
| f"Name: {guest['name']}", | |
| f"Relation: {guest['relation']}", | |
| f"Description: {guest['description']}", | |
| f"Email: {guest['email']}" | |
| ]), | |
| metadata={ | |
| "guest_id": index, | |
| "name": guest["name"] | |
| } | |
| ) | |
| documents.append(document) | |
| return documents | |