diff --git a/src/documentation/how_tos/how_to_run_the_trace_viewer.ipynb b/src/documentation/how_tos/how_to_run_the_trace_viewer.ipynb index 48d3f7dd7..13bfdd647 100644 --- a/src/documentation/how_tos/how_to_run_the_trace_viewer.ipynb +++ b/src/documentation/how_tos/how_to_run_the_trace_viewer.ipynb @@ -22,28 +22,45 @@ "1. Initialize a `StudioClient` with a project.\n", " - Use an existing project or create a new one with the `StudioClient.create_project` function.\n", "2. Submit your traces with the client\n", - " - submit a single trace via `Tracer.export_for_viewing` and `StudioClient.submit_trace`\n", - " - [Recommended] submit multiple traces via `StudioClient.submit_from_tracer`. \n", - "3. Click the link \n", + " 1. Submit a single trace via `Tracer.export_for_viewing` and `StudioClient.submit_trace`\n", + " 2. [Recommended] submit multiple traces via `StudioClient.submit_from_tracer`. \n", "\n", "### Example" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [] - }, { "cell_type": "code", "execution_count": null, - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, + "metadata": {}, "outputs": [], - "source": [] + "source": [ + "from intelligence_layer.connectors.studio.studio import StudioClient\n", + "from intelligence_layer.core.task import Task\n", + "from intelligence_layer.core.tracer.in_memory_tracer import InMemoryTracer\n", + "from intelligence_layer.core.tracer.tracer import TaskSpan\n", + "\n", + "# Step 0\n", + "class DummyTask(Task[str, str]):\n", + " def do_run(self, input: str, task_span: TaskSpan) -> str:\n", + " return f\"{input} -> output\"\n", + "\n", + "tracer = InMemoryTracer()\n", + "DummyTask().run('My Dummy Run', tracer=tracer)\n", + "\n", + "# Step 1\n", + "studio_client = StudioClient(project='my_project')\n", + "my_project = studio_client.create_project(project='my_project')\n", + "\n", + "# Step 2.1\n", + "trace_to_submit = tracer.export_for_viewing()\n", + "studio_client.submit_trace(trace_to_submit) # only works for single traces\n", + "\n", + "# Step 2.2\n", + "DummyTask().run('My Dummy Run2', tracer=tracer)\n", + "multiple_traces_to_submit = studio_client.submit_from_tracer(tracer)\n", + "\n", + "\n" + ] } ], "metadata": {