Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/oss/langgraph/agentic-rag.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,17 @@ Now that we have our split documents, we can index them into a vector store that
)
retriever = vectorstore.as_retriever()
```
2. Create a retriever tool using LangChain's prebuilt `create_retriever_tool`:
2. Create a retriever tool using the `@tool` decorator:
```python
from langchain_classic.tools.retriever import create_retriever_tool
from langchain.tools import tool

retriever_tool = create_retriever_tool(
retriever,
"retrieve_blog_posts",
"Search and return information about Lilian Weng blog posts.",
)
@tool
def retrieve_blog_posts(query: str) -> str:
"""Search and return information about Lilian Weng blog posts."""
docs = retriever.invoke(query)
return "\n\n".join([doc.page_content for doc in docs])

retriever_tool = retrieve_blog_posts
```
3. Test the tool:
```python
Expand Down
Loading