AzureAIMemoryRetrieverTool()Tool that retrieves relevant memories from Azure AI Foundry Memory.
This tool is designed to be used in conjunction with the
:class:AzureAIMemoryMiddleware to enable agents to store and retrieve
long-term memories in Azure AI Foundry.
Example usage:
from langchain.agents import create_agent
from langchain.chat_models import init_chat_model
from langchain_azure_ai.agents.middleware import AzureAIMemoryMiddleware
from langchain_azure_ai.tools import AzureAIMemoryRetrieverTool
memory_middleware = AzureAIMemoryMiddleware(
project_endpoint="https://resource...",
store_name="agent-memories",
scope="general",
roles=["user"],
)
retriever_tool = memory_middleware.get_retriever_tool(k=1)
agent = create_agent(
system_prompt=(
"You are a helpful assistant that can remember information over time."
"Use the provided tool to retrieve relevant memories when needed."
),
tools=[retriever_tool],
model=init_chat_model("azure_ai:gpt-4o"),
middleware=[memory_middleware],
)