Skip to main content

Module threads

Module threads 

Source
Expand description

OpenAI threads endpoint handlers.

Constants§

THREADS_PATH
Route path for thread creation (POST /v1/threads).
THREAD_MESSAGES_ROUTE
Templated route for a thread’s message collection (/v1/threads/{id}/messages).
THREAD_RETRIEVAL_PREFIX
Path prefix shared by thread retrieval and message routes (/v1/threads/).
THREAD_RETRIEVAL_ROUTE
Templated route for retrieving a single thread by id (/v1/threads/{id}).

Functions§

handle_thread_get
Handles GET /v1/threads/{id} and GET /v1/threads/{id}/messages, dispatching to thread retrieval or message listing based on the request path.
handle_thread_post
Handles POST /v1/threads/{id}/messages, appending a message to the thread.
handle_threads
Handles POST /v1/threads, creating a new thread and returning its JSON object.
list_messages
Returns the thread’s messages as an OpenAI list object, or a not-found error response when the thread does not exist.
retrieve_thread
Returns the JSON object for a stored thread, or a not-found error response.