Update MultiON toolkit docs (#16286)

pull/16199/head^2
Lance Martin 9 months ago committed by GitHub
parent e3828bee43
commit 881d1c3ec5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -21,7 +21,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"%pip install --upgrade --quiet multion langchain -q"
@ -29,7 +31,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 37,
"metadata": {},
"outputs": [
{
@ -38,7 +40,7 @@
"MultionToolkit()"
]
},
"execution_count": 7,
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
@ -52,7 +54,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 38,
"metadata": {},
"outputs": [
{
@ -61,7 +63,7 @@
"[MultionCreateSession(), MultionUpdateSession(), MultionCloseSession()]"
]
},
"execution_count": 8,
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
@ -84,7 +86,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 39,
"metadata": {},
"outputs": [
{
@ -118,81 +120,86 @@
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"tags": []
},
"execution_count": 40,
"metadata": {},
"outputs": [],
"source": [
"from langchain.agents import AgentType, initialize_agent\n",
"from langchain_openai import OpenAI\n",
"\n",
"llm = OpenAI(temperature=0)\n",
"from langchain_community.agent_toolkits import MultionToolkit\n",
"\n",
"toolkit = MultionToolkit()\n",
"tools = toolkit.get_tools()\n",
"agent = initialize_agent(\n",
"from langchain import hub\n",
"from langchain.agents import AgentExecutor, create_openai_functions_agent\n",
"from langchain_openai import ChatOpenAI"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [],
"source": [
"# Prompt\n",
"instructions = \"\"\"You are an assistant.\"\"\"\n",
"base_prompt = hub.pull(\"langchain-ai/openai-functions-template\")\n",
"prompt = base_prompt.partial(instructions=instructions)"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [],
"source": [
"# LLM\n",
"llm = ChatOpenAI(temperature=0)"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [],
"source": [
"# Agent\n",
"agent = create_openai_functions_agent(llm, toolkit.get_tools(), prompt)\n",
"agent_executor = AgentExecutor(\n",
" agent=agent,\n",
" tools=toolkit.get_tools(),\n",
" llm=llm,\n",
" agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION,\n",
" verbose=True,\n",
" verbose=False,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"tags": []
},
"execution_count": 46,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
"\u001b[32;1m\u001b[1;3mAction:\n",
"```\n",
"{\n",
" \"action\": \"create_multion_session\",\n",
" \"action_input\": {\n",
" \"query\": \"Summarize how AlphaCodium works, a recently released code language model.\",\n",
" \"url\": \"https://www.google.com/search?q=Summarize+how+AlphaCodium+works%2C+a+recently+released+code+language+model.\"\n",
" }\n",
"}\n",
"```\n",
"\n",
"\u001b[0mWARNING: 'new_session' is deprecated and will be removed in a future version. Use 'create_session' instead.\n",
"\n",
"Observation: \u001b[36;1m\u001b[1;3m{'sessionId': '813273951', 'Response': ''}\u001b[0m\n",
"Thought:\u001b[32;1m\u001b[1;3m I don't know what to do with this sessionId. I'll just ignore it and move on.\n",
"Action:\n",
"```\n",
"{\n",
" \"action\": \"Final Answer\",\n",
" \"action_input\": \"AlphaCodium is a code language model that was recently released. It is designed to assist developers in writing code by providing suggestions and completing code snippets. It uses machine learning algorithms to analyze code and generate relevant suggestions. It is similar to other code language models such as OpenAI's GPT-3 and Microsoft's IntelliCode.\"\n",
"}\n",
"```\u001b[0m\n",
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n"
"WARNING: 'new_session' is deprecated and will be removed in a future version. Use 'create_session' instead.\n",
"WARNING: 'update_session' is deprecated and will be removed in a future version. Use 'step_session' instead.\n",
"WARNING: 'update_session' is deprecated and will be removed in a future version. Use 'step_session' instead.\n",
"WARNING: 'update_session' is deprecated and will be removed in a future version. Use 'step_session' instead.\n",
"WARNING: 'update_session' is deprecated and will be removed in a future version. Use 'step_session' instead.\n"
]
},
{
"data": {
"text/plain": [
"\"AlphaCodium is a code language model that was recently released. It is designed to assist developers in writing code by providing suggestions and completing code snippets. It uses machine learning algorithms to analyze code and generate relevant suggestions. It is similar to other code language models such as OpenAI's GPT-3 and Microsoft's IntelliCode.\""
"{'input': 'Use multion to how AlphaCodium works, a recently released code language model.',\n",
" '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.'}"
]
},
"execution_count": 11,
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"agent.run(\"Summarize how AlphaCodium works, a recently released code language model.\")"
"agent_executor.invoke(\n",
" {\n",
" \"input\": \"Use multion to explain how AlphaCodium works, a recently released code language model.\"\n",
" }\n",
")"
]
}
],

Loading…
Cancel
Save