恭喜你!

使用 MongoDB 與 LangGraph 的 Text-to-Query Agent

Apoorva Joshi

Senior AI/ML Developer Advocate, MongoDB

成品完成!

代理成品示意

使用 MongoDB 與 LangGraph 的 Text-to-Query Agent

你的代理工具箱

from langchain_mongodb.agent_toolkit.toolkit import MongoDBDatabaseToolkit

# Initialize the MongoDB database toolkit
toolkit = MongoDBDatabaseToolkit(db=db, llm=llm)

# Extract the tools from the toolkit
tools = toolkit.get_tools()
使用 MongoDB 與 LangGraph 的 Text-to-Query Agent

提示工程

from langchain_mongodb.agent_toolkit import MONGODB_AGENT_SYSTEM_PROMPT

# Create a templated prompt for the LLM
prompt = ChatPromptTemplate.from_messages(
    [
        ("system", MONGODB_AGENT_SYSTEM_PROMPT),
        ("system", "Do not re-run tools unless absolutely necessary. If you are not
                    able to get enough information using the tools, reply with
                    I DON'T KNOW. You have access to the following tools: {tool_names}."),
        MessagesPlaceholder(variable_name="messages"),
    ]
)
使用 MongoDB 與 LangGraph 的 Text-to-Query Agent

代理協調

代理協作流程圖

使用 MongoDB 與 LangGraph 的 Text-to-Query Agent

記憶體

MongoDB 記憶儲存

執行緒檢查點

使用 MongoDB 與 LangGraph 的 Text-to-Query Agent

下一步?

使用 MongoDB 與 LangGraph 的 Text-to-Query Agent

恭喜你!

使用 MongoDB 與 LangGraph 的 Text-to-Query Agent

Preparing Video For Download...