Skip to content

Commit

Permalink
fixing gifs in notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
HowieG committed Jun 7, 2024
1 parent 993533a commit 82763f8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 199 deletions.
200 changes: 23 additions & 177 deletions examples/langchain_examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "initial_id",
"metadata": {
"ExecuteTime": {
Expand All @@ -40,7 +40,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "585f00bb186711a7",
"metadata": {
"ExecuteTime": {
Expand All @@ -63,26 +63,15 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "1490411415d7317c",
"metadata": {
"ExecuteTime": {
"end_time": "2023-12-15T20:21:11.494019Z",
"start_time": "2023-12-15T20:21:11.479154Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"from dotenv import load_dotenv\n",
"load_dotenv()"
Expand All @@ -100,16 +89,10 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "deec8da7-5b88-487e-bb07-e1ec79147b72",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [""]
}
],
"outputs": [],
"source": [
"AGENTOPS_API_KEY = os.environ.get('AGENTOPS_API_KEY')\n",
"OPENAI_API_KEY = os.environ.get('OPENAI_API_KEY')\n",
Expand All @@ -131,18 +114,10 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "5c4ef053",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Agent Ops session ID: 85cb6f74-833d-4659-bc08-cf70544b6542\n"
]
}
],
"outputs": [],
"source": [
"print(\"Agent Ops session ID: \" + str(agentops_handler.session_id))"
]
Expand All @@ -157,7 +132,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "6abf26f9",
"metadata": {},
"outputs": [],
Expand All @@ -184,7 +159,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"id": "71d56635-d0db-4362-b140-5072abee249f",
"metadata": {},
"outputs": [],
Expand All @@ -203,24 +178,15 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"id": "d538b20aa954ee80",
"metadata": {
"ExecuteTime": {
"end_time": "2023-12-15T20:21:12.352862Z",
"start_time": "2023-12-15T20:21:12.351126Z"
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/howardgil/Desktop/agentops/AgentOps-AI/agentops/env/lib/python3.12/site-packages/langchain_core/_api/deprecation.py:117: LangChainDeprecationWarning: The function `initialize_agent` was deprecated in LangChain 0.1.0 and will be removed in 0.2.0. Use Use new agent constructor methods like create_react_agent, create_json_agent, create_structured_chat_agent, etc. instead.\n",
" warn_deprecated(\n"
]
}
],
"outputs": [],
"source": [
"agent = initialize_agent(tools,\n",
" llm,\n",
Expand All @@ -232,111 +198,12 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"id": "6dfb127553751384",
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/howardgil/Desktop/agentops/AgentOps-AI/agentops/env/lib/python3.12/site-packages/langchain_core/_api/deprecation.py:117: LangChainDeprecationWarning: The function `run` was deprecated in LangChain 0.1.0 and will be removed in 0.2.0. Use invoke instead.\n",
" warn_deprecated(\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[32;1m\u001b[1;3mQuestion: What comedies are playing?\n",
"Thought: We should use the find_movie tool to search for available comedy movies.\n",
"Action:\n",
"```\n",
"{\n",
" \"action\": \"find_movie\",\n",
" \"action_input\": \"comedy\"\n",
"}\n",
"```\n",
"\u001b[0m\n",
"Observation: \u001b[36;1m\u001b[1;3mPineapple Express\u001b[0m\n",
"Thought:\u001b[32;1m\u001b[1;3mWe should check if there are more comedy movies available.\n",
"Action: \n",
"```\n",
"{\n",
" \"action\": \"find_movie\",\n",
" \"action_input\": \"comedy\"\n",
"}\n",
"```\u001b[0m\n",
"Observation: \u001b[36;1m\u001b[1;3mPineapple Express\u001b[0m\n",
"Thought:\u001b[32;1m\u001b[1;3mCould not parse LLM output: I now know the final answer.\u001b[0m\n",
"Observation: Invalid or incomplete response\n",
"Thought:\u001b[32;1m\u001b[1;3mI apologize for the confusion in the previous interaction. Let's try to find comedy movies again.\n",
"\n",
"Question: What comedies are playing?\n",
"Thought: Let's use the find_movie tool to search for available comedy movies.\n",
"Action:\n",
"```\n",
"{\n",
" \"action\": \"find_movie\",\n",
" \"action_input\": \"comedy\"\n",
"}\n",
"```\n",
"\u001b[0m\n",
"Observation: \u001b[36;1m\u001b[1;3mPineapple Express\u001b[0m\n",
"Thought:\u001b[32;1m\u001b[1;3mI apologize for the confusion in the previous interactions. Let's make sure to get a clear list of comedy movies this time.\n",
"\n",
"Question: What comedies are playing?\n",
"Thought: Let's try using the find_movie tool once again to search for available comedy movies.\n",
"Action:\n",
"```\n",
"{\n",
" \"action\": \"find_movie\",\n",
" \"action_input\": \"comedy\"\n",
"}\n",
"```\n",
"\u001b[0m\n",
"Observation: \u001b[36;1m\u001b[1;3mPineapple Express\u001b[0m\n",
"Thought:\u001b[32;1m\u001b[1;3mI apologize for the technical issues we encountered. Let's try finding comedy movies one more time.\n",
"\n",
"Question: What comedies are playing?\n",
"Thought: Let's use the find_movie tool to search for available comedy movies.\n",
"Action:\n",
"```\n",
"{\n",
" \"action\": \"find_movie\",\n",
" \"action_input\": \"comedy\"\n",
"}\n",
"```\n",
"\n",
"\u001b[0m\n",
"Observation: \u001b[36;1m\u001b[1;3mPineapple Express\u001b[0m\n",
"Thought:\u001b[32;1m\u001b[1;3mFinal Answer: Pineapple Express\u001b[0m\n",
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n"
]
},
{
"data": {
"text/plain": [
"'Pineapple Express'"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"agent.run(\"What comedies are playing?\", callbacks=[agentops_handler])"
]
Expand Down Expand Up @@ -368,7 +235,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"id": "973f00a2-24da-48b3-adf7-97872d0d5afd",
"metadata": {},
"outputs": [],
Expand All @@ -381,7 +248,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"id": "16d8136c-cac2-47a5-85d8-cc466089feea",
"metadata": {},
"outputs": [],
Expand All @@ -391,7 +258,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"id": "b5986ed0-02d0-4e5f-99cd-c1fdfd7e5f1c",
"metadata": {},
"outputs": [],
Expand All @@ -405,18 +272,10 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"id": "bdce6ac1-bdbc-46ba-a9f1-7fd384187016",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Agent Ops session ID: 85cb6f74-833d-4659-bc08-cf70544b6542\n"
]
}
],
"outputs": [],
"source": [
"agentops_handler = AgentOpsAsyncLangchainCallbackHandler(api_key=AGENTOPS_API_KEY, tags=['Async Example'])\n",
"\n",
Expand All @@ -429,7 +288,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": null,
"id": "d728c326-9a41-498b-bb64-9720577aac3e",
"metadata": {},
"outputs": [],
Expand All @@ -451,23 +310,10 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": null,
"id": "30eddc8b-0c90-4d96-9f1f-45da38c0d984",
"metadata": {},
"outputs": [
{
"ename": "RuntimeError",
"evalue": "asyncio.run() cannot be called from a running event loop",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[15], line 13\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[38;5;28;01masync\u001b[39;00m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mrun_async\u001b[39m():\n\u001b[1;32m 11\u001b[0m \u001b[38;5;28;01mawait\u001b[39;00m agent\u001b[38;5;241m.\u001b[39mrun(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mWhat comedies are playing?\u001b[39m\u001b[38;5;124m\"\u001b[39m, callbacks\u001b[38;5;241m=\u001b[39m[agentops_handler])\n\u001b[0;32m---> 13\u001b[0m \u001b[43masyncio\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrun_async\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n",
"File \u001b[0;32m/opt/homebrew/Cellar/[email protected]/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py:190\u001b[0m, in \u001b[0;36mrun\u001b[0;34m(main, debug, loop_factory)\u001b[0m\n\u001b[1;32m 161\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"Execute the coroutine and return the result.\u001b[39;00m\n\u001b[1;32m 162\u001b[0m \n\u001b[1;32m 163\u001b[0m \u001b[38;5;124;03mThis function runs the passed coroutine, taking care of\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 186\u001b[0m \u001b[38;5;124;03m asyncio.run(main())\u001b[39;00m\n\u001b[1;32m 187\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 188\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m events\u001b[38;5;241m.\u001b[39m_get_running_loop() \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 189\u001b[0m \u001b[38;5;66;03m# fail fast with short traceback\u001b[39;00m\n\u001b[0;32m--> 190\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mRuntimeError\u001b[39;00m(\n\u001b[1;32m 191\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124masyncio.run() cannot be called from a running event loop\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 193\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m Runner(debug\u001b[38;5;241m=\u001b[39mdebug, loop_factory\u001b[38;5;241m=\u001b[39mloop_factory) \u001b[38;5;28;01mas\u001b[39;00m runner:\n\u001b[1;32m 194\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m runner\u001b[38;5;241m.\u001b[39mrun(main)\n",
"\u001b[0;31mRuntimeError\u001b[0m: asyncio.run() cannot be called from a running event loop"
]
}
],
"outputs": [],
"source": [
"agent = initialize_agent(\n",
" tools,\n",
Expand Down Expand Up @@ -514,7 +360,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
"version": "3.8.10"
}
},
"nbformat": 4,
Expand Down
9 changes: 3 additions & 6 deletions examples/multion/browse.ipynb

Large diffs are not rendered by default.

7 changes: 1 addition & 6 deletions examples/multion/retrieve.ipynb

Large diffs are not rendered by default.

12 changes: 2 additions & 10 deletions examples/multion/step.ipynb

Large diffs are not rendered by default.

0 comments on commit 82763f8

Please sign in to comment.