diff --git a/examples/Assistants_API_overview_python.ipynb b/examples/Assistants_API_overview_python.ipynb index 2b9dd29..51c3094 100644 --- a/examples/Assistants_API_overview_python.ipynb +++ b/examples/Assistants_API_overview_python.ipynb @@ -27,7 +27,7 @@ "source": [ "## Setup\n", "\n", - "### Python SDK \n", + "### Python SDK\n", "\n", "> **Note**\n", "> We've updated our [Python SDK](https://github.com/openai/openai-python) to add support for the Assistants API, so you'll need to update it to the latest version (`1.2.3` at time of writing).\n" @@ -35,29 +35,9 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Requirement already satisfied: openai in /Users/ilan/.virtualenvs/openai/lib/python3.9/site-packages (1.2.3)\n", - "Requirement already satisfied: anyio<4,>=3.5.0 in /Users/ilan/.virtualenvs/openai/lib/python3.9/site-packages (from openai) (3.6.2)\n", - "Requirement already satisfied: distro<2,>=1.7.0 in /Users/ilan/.virtualenvs/openai/lib/python3.9/site-packages (from openai) (1.8.0)\n", - "Requirement already satisfied: httpx<1,>=0.23.0 in /Users/ilan/.virtualenvs/openai/lib/python3.9/site-packages (from openai) (0.23.3)\n", - "Requirement already satisfied: pydantic<3,>=1.9.0 in /Users/ilan/.virtualenvs/openai/lib/python3.9/site-packages (from openai) (1.10.9)\n", - "Requirement already satisfied: tqdm>4 in /Users/ilan/.virtualenvs/openai/lib/python3.9/site-packages (from openai) (4.64.1)\n", - "Requirement already satisfied: typing-extensions<5,>=4.5 in /Users/ilan/.virtualenvs/openai/lib/python3.9/site-packages (from openai) (4.5.0)\n", - "Requirement already satisfied: idna>=2.8 in /Users/ilan/.virtualenvs/openai/lib/python3.9/site-packages (from anyio<4,>=3.5.0->openai) (3.4)\n", - "Requirement already satisfied: sniffio>=1.1 in /Users/ilan/.virtualenvs/openai/lib/python3.9/site-packages (from anyio<4,>=3.5.0->openai) (1.3.0)\n", - "Requirement already satisfied: certifi in /Users/ilan/.virtualenvs/openai/lib/python3.9/site-packages (from httpx<1,>=0.23.0->openai) (2022.12.7)\n", - "Requirement already satisfied: httpcore<0.17.0,>=0.15.0 in /Users/ilan/.virtualenvs/openai/lib/python3.9/site-packages (from httpx<1,>=0.23.0->openai) (0.16.3)\n", - "Requirement already satisfied: rfc3986<2,>=1.3 in /Users/ilan/.virtualenvs/openai/lib/python3.9/site-packages (from rfc3986[idna2008]<2,>=1.3->httpx<1,>=0.23.0->openai) (1.5.0)\n", - "Requirement already satisfied: h11<0.15,>=0.13 in /Users/ilan/.virtualenvs/openai/lib/python3.9/site-packages (from httpcore<0.17.0,>=0.15.0->httpx<1,>=0.23.0->openai) (0.14.0)\n" - ] - } - ], + "outputs": [], "source": [ "!pip install --upgrade openai" ] @@ -90,7 +70,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Pretty Printing Helper" + "### Pretty Printing Helper\n" ] }, { @@ -101,6 +81,7 @@ "source": [ "import json\n", "\n", + "\n", "def show_json(obj):\n", " display(json.loads(obj.model_dump_json()))" ] @@ -130,7 +111,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "\"Assistants\n" + "![Assistants Playground](../images/assistants_overview_assistants_playground.png)\n" ] }, { @@ -144,7 +125,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "\"Creating\n" + "![Creating New Assistant](../images/assistants_overview_new_assistant.png)\n" ] }, { @@ -158,7 +139,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "\"Assistants\n" + "![Assistants Dashboard](../images/assistants_overview_assistants_dashboard.png)\n" ] }, { @@ -379,6 +360,7 @@ "source": [ "import time\n", "\n", + "\n", "def wait_on_run(run, thread):\n", " while run.status == \"queued\" or run.status == \"in_progress\":\n", " run = client.beta.threads.runs.retrieve(\n", @@ -587,7 +569,7 @@ "source": [ "from openai import OpenAI\n", "\n", - "MATH_ASSISTANT_ID = assistant.id # or a hard-coded ID like \"asst-...\"\n", + "MATH_ASSISTANT_ID = assistant.id # or a hard-coded ID like \"asst-...\"\n", "\n", "client = OpenAI()\n", "\n", @@ -628,7 +610,9 @@ "\n", "\n", "# Emulating concurrent user requests\n", - "thread1, run1 = create_thread_and_run(\"I need to solve the equation `3x + 11 = 14`. Can you help me?\")\n", + "thread1, run1 = create_thread_and_run(\n", + " \"I need to solve the equation `3x + 11 = 14`. Can you help me?\"\n", + ")\n", "thread2, run2 = create_thread_and_run(\"Could you explain linear algebra to me?\")\n", "thread3, run3 = create_thread_and_run(\"I don't like math. What can I do?\")\n", "\n", @@ -739,7 +723,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "\"Enabling\n" + "![Enabling code interpreter](../images/assistants_overview_enable_code_interpreter.png)\n" ] }, { @@ -928,7 +912,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "\"Enabling\n" + "![Enabling retrieval](../images/assistants_overview_enable_retrieval.png)\n" ] }, { @@ -1526,13 +1510,14 @@ "We covered a lot of ground in this notebook, give yourself a high-five! Hopefully you should now have a strong foundation to build powerful, stateful experiences with tools like Code Interpreter, Retrieval, and Functions!\n", "\n", "There's a few sections we didn't cover for the sake of brevity, so here's a few resources to explore further:\n", + "\n", "- [Annotations](https://platform.openai.com/docs/assistants/how-it-works/managing-threads-and-messages): parsing file citations\n", "- [Files](https://platform.openai.com/docs/api-reference/assistants/file-object): Thread scoped vs Assistant scoped\n", "- [Parallel Function Calls](https://platform.openai.com/docs/guides/function-calling/parallel-function-calling): calling multiple tools in a single Step\n", "- Multi-Assistant Thread Runs: single Thread with Messages from multiple Assistants\n", "- Streaming: coming soon!\n", "\n", - "Now go off and build something ama[zing](https://www.youtube.com/watch?v=xvFZjo5PgG0&pp=ygUQcmljayByb2xsIG5vIGFkcw%3D%3D)! " + "Now go off and build something ama[zing](https://www.youtube.com/watch?v=xvFZjo5PgG0&pp=ygUQcmljayByb2xsIG5vIGFkcw%3D%3D)!\n" ] } ], @@ -1552,7 +1537,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.11.4" } }, "nbformat": 4,