MultiOn 客户端。
这将启用利用 MultiON 智能体能力的自定义智能体工作流。
要使用此工具包,您需要在浏览器中添加 MultiOn Extension:
- 创建一个 MultiON 账户。
- 添加 MultiOn Chrome 扩展。
Copy
pip install -qU multion langchain -q
Copy
pip install -qU langchain-community
Copy
from langchain_community.agent_toolkits import MultionToolkit
toolkit = MultionToolkit()
toolkit
Copy
MultionToolkit()
Copy
tools = toolkit.get_tools()
tools
Copy
[MultionCreateSession(), MultionUpdateSession(), MultionCloseSession()]
MultiOn 设置
创建账户后,在 app.multion.ai/ 创建 API 密钥。 登录以与您的扩展建立连接。Copy
# Authorize connection to your Browser extention
import multion
multion.login()
Copy
Logged in.
在智能体中使用 multion 工具包
这将使用 MultiON Chrome 扩展执行所需操作。 我们可以运行以下代码,并查看追踪记录以了解:- 智能体使用
create_multion_session工具 - 然后使用 MultiON 执行查询
Copy
from langchain_classic import hub
from langchain.agents import AgentExecutor, create_openai_functions_agent
from langchain_openai import ChatOpenAI
Copy
# Prompt
instructions = """You are an assistant."""
base_prompt = hub.pull("langchain-ai/openai-functions-template")
prompt = base_prompt.partial(instructions=instructions)
Copy
# LLM
llm = ChatOpenAI(temperature=0)
Copy
# Agent
agent = create_openai_functions_agent(llm, toolkit.get_tools(), prompt)
agent_executor = AgentExecutor(
agent=agent,
tools=toolkit.get_tools(),
verbose=False,
)
Copy
agent_executor.invoke(
{
"input": "Use multion to explain how AlphaCodium works, a recently released code language model."
}
)
Copy
WARNING: 'new_session' is deprecated and will be removed in a future version. Use 'create_session' instead.
WARNING: 'update_session' is deprecated and will be removed in a future version. Use 'step_session' instead.
WARNING: 'update_session' is deprecated and will be removed in a future version. Use 'step_session' instead.
WARNING: 'update_session' is deprecated and will be removed in a future version. Use 'step_session' instead.
WARNING: 'update_session' is deprecated and will be removed in a future version. Use 'step_session' instead.
Copy
{'input': 'Use multion to how AlphaCodium works, a recently released code language model.',
'output': 'AlphaCodium is a recently released code language model that is designed to assist developers in writing code more efficiently. It is based on advanced machine learning techniques and natural language processing. AlphaCodium can understand and generate code in multiple programming languages, making it a versatile tool for developers.\n\nThe model is trained on a large dataset of code snippets and programming examples, allowing it to learn patterns and best practices in coding. It can provide suggestions and auto-complete code based on the context and the desired outcome.\n\nAlphaCodium also has the ability to analyze code and identify potential errors or bugs. It can offer recommendations for improving code quality and performance.\n\nOverall, AlphaCodium aims to enhance the coding experience by providing intelligent assistance and reducing the time and effort required to write high-quality code.\n\nFor more detailed information, you can visit the official AlphaCodium website or refer to the documentation and resources available online.\n\nI hope this helps! Let me know if you have any other questions.'}
将这些文档连接到 Claude、VSCode 等,通过 MCP 获取实时解答。

