跳至主要內容
Open In ColabOpen on GitHub

MultiOn 工具包

MultiON 建立了一個 AI Agent,可以與廣泛的網路服務和應用程式互動。

本筆記本將引導您將 LangChain 連接到瀏覽器中的 MultiOn 用戶端。

這能夠實現自訂的 Agent 工作流程,以利用 MultiON Agent 的強大功能。

若要使用此工具包,您需要將 MultiOn Extension 新增至您的瀏覽器

%pip install --upgrade --quiet  multion langchain -q
%pip install -qU langchain-community
from langchain_community.agent_toolkits import MultionToolkit

toolkit = MultionToolkit()
toolkit
API 參考:MultionToolkit
MultionToolkit()
tools = toolkit.get_tools()
tools
[MultionCreateSession(), MultionUpdateSession(), MultionCloseSession()]

MultiOn 設定

建立帳戶後,在 https://app.multion.ai/ 建立 API 金鑰。

登入以建立與您擴充功能的連線。

# Authorize connection to your Browser extention
import multion

multion.login()
Logged in.

在 Agent 中使用 Multion 工具包

這將使用 MultiON Chrome 擴充功能來執行所需動作。

我們可以執行以下程式碼,並檢視 trace 以查看

  • Agent 使用 create_multion_session 工具
  • 然後它使用 MultiON 執行查詢
from langchain import hub
from langchain.agents import AgentExecutor, create_openai_functions_agent
from langchain_openai import ChatOpenAI
# Prompt
instructions = """You are an assistant."""
base_prompt = hub.pull("langchain-ai/openai-functions-template")
prompt = base_prompt.partial(instructions=instructions)
# LLM
llm = ChatOpenAI(temperature=0)
# Agent
agent = create_openai_functions_agent(llm, toolkit.get_tools(), prompt)
agent_executor = AgentExecutor(
agent=agent,
tools=toolkit.get_tools(),
verbose=False,
)
agent_executor.invoke(
{
"input": "Use multion to explain how AlphaCodium works, a recently released code language model."
}
)
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.
{'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.'}

此頁面是否對您有幫助?