Hello Lukas,
Welcome to our community! It’s great to see new developers diving into the Assistant API. I’ll address your questions in a more informal and clear manner:
Context Maintenance in Threads:
- You’re spot on about the context being within the thread. Each API call consumes tokens ( Pricing (openai.com) | Assistants API pricing details per message - API - OpenAI Developer Forum ), and there’s a limit to the context size. When it exceeds, only the most recent context that fits within the token budget is retained. This means that older interactions disappear, similar to a sliding window over the conversation history.
Horizontal Scalability with Assistants and Threads:
- You’re on the right track by creating a unique assistant and thread for each user (OpenAI Platform) . Each thread acts as an independent conversation and can handle a unique user ( API Reference - OpenAI API) . There are rate limits and potential pricing considerations based on usage volume, but planning ahead can help manage them effectively.
Cleaning or Emptying Threads:
- It seems, based on the official documentation and API references for OpenAI Assistants, that you can edit or modify threads, but currently, the only available parameter for modification is the metadata. API Reference - OpenAI API - Modify Thread
API Reference - OpenAI API - Threads
Instead, you can effectively manage the continuity of the conversation by creating new threads when you need a fresh start or ensuring relevant content continues in future interactions.
sequenceDiagram
autonumber
participant User as User
participant API as Assistants API
participant Thread as Thread (Conversation)
participant Message as Message
User->>API: Create Thread (POST /v1/threads)
API->>Thread: Thread Initialized
Thread->>User: Respond with Thread ID
User->>API: Send Message (POST /v1/threads/{thread_id}/messages)
API->>Message: Process Message
Message->>Thread: Add Message to Thread
Thread->>User: Confirm Message Receipt
User->>API: Request Response (GET /v1/threads/{thread_id}/messages)
API->>Thread: Retrieve Last Message
Thread->>API: Provide Last Message
API->>User: Display Assistant's Response
I hope this helps shed some light on your questions!
More: