30 lines
825 B
Python
30 lines
825 B
Python
"""
|
|
Entry point demonstrating the RAG agent.
|
|
|
|
Runs three example scenarios:
|
|
1. Add a sample text directly via tool call.
|
|
2. Search for a keyword.
|
|
3. Load documents from a directory using init_documents.
|
|
"""
|
|
|
|
import asyncio
|
|
from pathlib import Path
|
|
from langchain_core.messages import HumanMessage
|
|
from agent import agent
|
|
|
|
async def demo():
|
|
# 1. Add sample text
|
|
await agent.ainvoke(
|
|
{"messages": [HumanMessage(content="Add document: Sample")]},
|
|
{"configurable": {"thread_id": "demo-1"}},
|
|
)
|
|
# 2. Search
|
|
result = await agent.ainvoke(
|
|
{"messages": [HumanMessage(content="Search for Python")]},
|
|
{"configurable": {"thread_id": "demo-1"}},
|
|
)
|
|
print("Search result:\n", result["messages"][-1].content)
|
|
|
|
if __name__ == "__main__": # pragma: no cover
|
|
asyncio.run(demo())
|