Skip to content

Commit

Permalink
wip: debug and fix thanks to @JasonWeill in jupyterlab/jupyter-ai#746
Browse files Browse the repository at this point in the history
  • Loading branch information
jaanli committed Apr 25, 2024
1 parent b90f669 commit f38a3db
Showing 1 changed file with 34 additions and 21 deletions.
55 changes: 34 additions & 21 deletions notebooks/getting-started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"id": "18fbede1-a82a-4929-938e-25cf18d160f7",
"metadata": {},
"outputs": [],
Expand All @@ -55,7 +55,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 3,
"id": "945fb6ae-e03c-4670-8210-cae493757ee6",
"metadata": {},
"outputs": [],
Expand All @@ -65,7 +65,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 4,
"id": "42d67f40-462b-43ba-a63f-fdd9e126a423",
"metadata": {},
"outputs": [],
Expand All @@ -85,32 +85,45 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 8,
"id": "9ae14480-b195-4686-9c80-70654bccfd24",
"metadata": {},
"outputs": [
{
"ename": "UsageError",
"evalue": "No such command 'anthropic:claude-v1.2'.",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mUsageError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[11], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mget_ipython\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun_line_magic\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mai\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43manthropic:claude-v1.2\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n",
"File \u001b[0;32m~/jaanli/language-model-notebooks/.venv/lib/python3.12/site-packages/IPython/core/interactiveshell.py:2480\u001b[0m, in \u001b[0;36mInteractiveShell.run_line_magic\u001b[0;34m(self, magic_name, line, _stack_depth)\u001b[0m\n\u001b[1;32m 2478\u001b[0m kwargs[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mlocal_ns\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mget_local_scope(stack_depth)\n\u001b[1;32m 2479\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mbuiltin_trap:\n\u001b[0;32m-> 2480\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[43mfn\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 2482\u001b[0m \u001b[38;5;66;03m# The code below prevents the output from being displayed\u001b[39;00m\n\u001b[1;32m 2483\u001b[0m \u001b[38;5;66;03m# when using magics with decorator @output_can_be_silenced\u001b[39;00m\n\u001b[1;32m 2484\u001b[0m \u001b[38;5;66;03m# when the last Python token in the expression is a ';'.\u001b[39;00m\n\u001b[1;32m 2485\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mgetattr\u001b[39m(fn, magic\u001b[38;5;241m.\u001b[39mMAGIC_OUTPUT_CAN_BE_SILENCED, \u001b[38;5;28;01mFalse\u001b[39;00m):\n",
"File \u001b[0;32m~/jaanli/language-model-notebooks/.venv/lib/python3.12/site-packages/jupyter_ai_magics/magics.py:575\u001b[0m, in \u001b[0;36mAiMagics.ai\u001b[0;34m(self, line, cell)\u001b[0m\n\u001b[1;32m 573\u001b[0m args \u001b[38;5;241m=\u001b[39m cell_magic_parser(raw_args, prog_name\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m%%\u001b[39;00m\u001b[38;5;124mai\u001b[39m\u001b[38;5;124m\"\u001b[39m, standalone_mode\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m)\n\u001b[1;32m 574\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 575\u001b[0m args \u001b[38;5;241m=\u001b[39m \u001b[43mline_magic_parser\u001b[49m\u001b[43m(\u001b[49m\u001b[43mraw_args\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mprog_name\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;132;43;01m%a\u001b[39;49;00m\u001b[38;5;124;43mi\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstandalone_mode\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[1;32m 577\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m args \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m0\u001b[39m:\n\u001b[1;32m 578\u001b[0m \u001b[38;5;66;03m# this happens when `--help` is called on the root command, in which\u001b[39;00m\n\u001b[1;32m 579\u001b[0m \u001b[38;5;66;03m# case we want to exit early.\u001b[39;00m\n\u001b[1;32m 580\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m\n",
"File \u001b[0;32m~/jaanli/language-model-notebooks/.venv/lib/python3.12/site-packages/click/core.py:1157\u001b[0m, in \u001b[0;36mBaseCommand.__call__\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1155\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m__call__\u001b[39m(\u001b[38;5;28mself\u001b[39m, \u001b[38;5;241m*\u001b[39margs: t\u001b[38;5;241m.\u001b[39mAny, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs: t\u001b[38;5;241m.\u001b[39mAny) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m t\u001b[38;5;241m.\u001b[39mAny:\n\u001b[1;32m 1156\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Alias for :meth:`main`.\"\"\"\u001b[39;00m\n\u001b[0;32m-> 1157\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmain\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
"File \u001b[0;32m~/jaanli/language-model-notebooks/.venv/lib/python3.12/site-packages/click/core.py:1078\u001b[0m, in \u001b[0;36mBaseCommand.main\u001b[0;34m(self, args, prog_name, complete_var, standalone_mode, windows_expand_args, **extra)\u001b[0m\n\u001b[1;32m 1076\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 1077\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mmake_context(prog_name, args, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mextra) \u001b[38;5;28;01mas\u001b[39;00m ctx:\n\u001b[0;32m-> 1078\u001b[0m rv \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43minvoke\u001b[49m\u001b[43m(\u001b[49m\u001b[43mctx\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1079\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m standalone_mode:\n\u001b[1;32m 1080\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m rv\n",
"File \u001b[0;32m~/jaanli/language-model-notebooks/.venv/lib/python3.12/site-packages/click/core.py:1682\u001b[0m, in \u001b[0;36mMultiCommand.invoke\u001b[0;34m(self, ctx)\u001b[0m\n\u001b[1;32m 1678\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mchain:\n\u001b[1;32m 1679\u001b[0m \u001b[38;5;66;03m# Make sure the context is entered so we do not clean up\u001b[39;00m\n\u001b[1;32m 1680\u001b[0m \u001b[38;5;66;03m# resources until the result processor has worked.\u001b[39;00m\n\u001b[1;32m 1681\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m ctx:\n\u001b[0;32m-> 1682\u001b[0m cmd_name, cmd, args \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mresolve_command\u001b[49m\u001b[43m(\u001b[49m\u001b[43mctx\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43margs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1683\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m cmd \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 1684\u001b[0m ctx\u001b[38;5;241m.\u001b[39minvoked_subcommand \u001b[38;5;241m=\u001b[39m cmd_name\n",
"File \u001b[0;32m~/jaanli/language-model-notebooks/.venv/lib/python3.12/site-packages/click/core.py:1746\u001b[0m, in \u001b[0;36mMultiCommand.resolve_command\u001b[0;34m(self, ctx, args)\u001b[0m\n\u001b[1;32m 1744\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m split_opt(cmd_name)[\u001b[38;5;241m0\u001b[39m]:\n\u001b[1;32m 1745\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mparse_args(ctx, ctx\u001b[38;5;241m.\u001b[39margs)\n\u001b[0;32m-> 1746\u001b[0m \u001b[43mctx\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfail\u001b[49m\u001b[43m(\u001b[49m\u001b[43m_\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mNo such command \u001b[39;49m\u001b[38;5;132;43;01m{name!r}\u001b[39;49;00m\u001b[38;5;124;43m.\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mformat\u001b[49m\u001b[43m(\u001b[49m\u001b[43mname\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43moriginal_cmd_name\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1747\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m cmd_name \u001b[38;5;28;01mif\u001b[39;00m cmd \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m, cmd, args[\u001b[38;5;241m1\u001b[39m:]\n",
"File \u001b[0;32m~/jaanli/language-model-notebooks/.venv/lib/python3.12/site-packages/click/core.py:684\u001b[0m, in \u001b[0;36mContext.fail\u001b[0;34m(self, message)\u001b[0m\n\u001b[1;32m 678\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mfail\u001b[39m(\u001b[38;5;28mself\u001b[39m, message: \u001b[38;5;28mstr\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mte.NoReturn\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[1;32m 679\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Aborts the execution of the program with a specific error\u001b[39;00m\n\u001b[1;32m 680\u001b[0m \u001b[38;5;124;03m message.\u001b[39;00m\n\u001b[1;32m 681\u001b[0m \n\u001b[1;32m 682\u001b[0m \u001b[38;5;124;03m :param message: the error message to fail with.\u001b[39;00m\n\u001b[1;32m 683\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[0;32m--> 684\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m UsageError(message, \u001b[38;5;28mself\u001b[39m)\n",
"\u001b[0;31mUsageError\u001b[0m: No such command 'anthropic:claude-v1.2'."
]
"data": {
"text/markdown": [
"Cannot determine model provider from model ID `anthropic:claude-v1.2`.\n",
"\n",
"To see a list of models you can use, run `%ai list`\n",
"\n",
"If you were trying to run a command, run `%ai help` to see a list of commands."
],
"text/plain": [
"Cannot determine model provider from model ID 'anthropic:claude-v1.2'.\n",
"\n",
"To see a list of models you can use, run '%ai list'\n",
"\n",
"If you were trying to run a command, run '%ai help' to see a list of commands."
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%ai anthropic:claude-v1.2"
"%%ai anthropic:claude-v1.2\n",
"\n",
"Test"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8e36a7e9-edfd-4379-b8f8-0bd6654b0d3c",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit f38a3db

Please sign in to comment.