From 9fd5986bbc6a5b35c721fc2de77df2e4768fc610 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Tue, 4 Jun 2024 21:16:45 -0700 Subject: [PATCH] docs(assistants.md): update docs for streaming w/ assistants api --- docs/my-website/docs/assistants.md | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/docs/my-website/docs/assistants.md b/docs/my-website/docs/assistants.md index 469c17c72f..215da404db 100644 --- a/docs/my-website/docs/assistants.md +++ b/docs/my-website/docs/assistants.md @@ -193,4 +193,43 @@ curl http://0.0.0.0:4000/v1/threads/thread_abc123/runs \ +## Streaming + + + + +```python +from litellm import run_thread_stream +import os + +os.environ["OPENAI_API_KEY"] = "sk-.." + +message = {"role": "user", "content": "Hey, how's it going?"} + +data = {"custom_llm_provider": "openai", "thread_id": _new_thread.id, "assistant_id": assistant_id, **message} + +run = run_thread_stream(**data) +with run as run: + assert isinstance(run, AssistantEventHandler) + for chunk in run: + print(f"chunk: {chunk}") + run.until_done() +``` + + + + +```bash +curl -X POST 'http://0.0.0.0:4000/threads/{thread_id}/runs' \ +-H 'Authorization: Bearer sk-1234' \ +-H 'Content-Type: application/json' \ +-D '{ + "assistant_id": "asst_6xVZQFFy1Kw87NbnYeNebxTf", + "stream": true +}' +``` + + + + ## [👉 Proxy API Reference](https://litellm-api.up.railway.app/#/assistants)