pub struct ThreadsApi<'a>(/* private fields */);
Expand description
ThreadsApi
struct to interact with thread management endpoints of the API.
Implementations§
Source§impl<'a> ThreadsApi<'a>
impl<'a> ThreadsApi<'a>
Sourcepub async fn create(
&self,
request: ThreadCreationRequest,
) -> OpenAIResult<Value>
pub async fn create( &self, request: ThreadCreationRequest, ) -> OpenAIResult<Value>
Create a new thread with the provided request parameters.
§Arguments
request
- AThreadCreationRequest
containing the parameters for the new thread.
§Returns
A Result containing the JSON response as serde_json::Value
on success, or an OpenAIError
on failure.
Sourcepub async fn retrieve(&self, thread_id: &str) -> OpenAIResult<Value>
pub async fn retrieve(&self, thread_id: &str) -> OpenAIResult<Value>
Retrieve the details of a specific thread by its ID.
§Arguments
thread_id
- The ID of the thread to be retrieved.
§Returns
A Result containing the JSON response as serde_json::Value
on success, or an OpenAIError
on failure.
Sourcepub async fn modify(
&self,
thread_id: &str,
request: ThreadModificationRequest,
) -> OpenAIResult<Value>
pub async fn modify( &self, thread_id: &str, request: ThreadModificationRequest, ) -> OpenAIResult<Value>
Modify an existing thread’s details using the provided request parameters.
§Arguments
thread_id
- The ID of the thread to be modified.request
- AThreadModificationRequest
containing the modification parameters.
§Returns
A Result containing the JSON response as serde_json::Value
on success, or an OpenAIError
on failure.
Sourcepub async fn delete(&self, thread_id: &str) -> OpenAIResult<Value>
pub async fn delete(&self, thread_id: &str) -> OpenAIResult<Value>
Delete a specific thread by its ID.
§Arguments
thread_id
- The ID of the thread to be deleted.
§Returns
A Result containing the JSON response as serde_json::Value
on success, or an OpenAIError
on failure.
Sourcepub async fn create_message(
&self,
thread_id: &str,
role: &str,
content: Value,
attachments: Option<Value>,
metadata: Option<Value>,
) -> OpenAIResult<Value>
pub async fn create_message( &self, thread_id: &str, role: &str, content: Value, attachments: Option<Value>, metadata: Option<Value>, ) -> OpenAIResult<Value>
Create a new message in a specific thread.
§Arguments
thread_id
- The ID of the thread to add a message to.role
- The role of the message sender.content
- The content of the message.attachments
- Optional attachments for the message.metadata
- Optional metadata for the message.
§Returns
A Result containing the JSON response as serde_json::Value
on success, or an OpenAIError
on failure.
Sourcepub async fn list_messages(
&self,
thread_id: &str,
limit: Option<u32>,
order: Option<&str>,
after: Option<&str>,
before: Option<&str>,
) -> OpenAIResult<Value>
pub async fn list_messages( &self, thread_id: &str, limit: Option<u32>, order: Option<&str>, after: Option<&str>, before: Option<&str>, ) -> OpenAIResult<Value>
List messages in a specific thread with optional filters.
§Arguments
thread_id
- The ID of the thread to list messages from.limit
- Optional limit on the number of messages to list.order
- Optional order parameter for the message listing.after
- Optional parameter to list messages after a specific time.before
- Optional parameter to list messages before a specific time.
§Returns
A Result containing the JSON response as serde_json::Value
on success, or an OpenAIError
on failure.
Sourcepub async fn retrieve_message(
&self,
thread_id: &str,
message_id: &str,
) -> OpenAIResult<Value>
pub async fn retrieve_message( &self, thread_id: &str, message_id: &str, ) -> OpenAIResult<Value>
Retrieve a specific message by its ID from a thread.
§Arguments
thread_id
- The ID of the thread to retrieve the message from.message_id
- The ID of the message to retrieve.
§Returns
A Result containing the JSON response as serde_json::Value
on success, or an OpenAIError
on failure.
Sourcepub async fn modify_message(
&self,
thread_id: &str,
message_id: &str,
metadata: Value,
) -> OpenAIResult<Value>
pub async fn modify_message( &self, thread_id: &str, message_id: &str, metadata: Value, ) -> OpenAIResult<Value>
Modify a specific message’s metadata in a thread.
§Arguments
thread_id
- The ID of the thread containing the message.message_id
- The ID of the message to modify.metadata
- The new metadata to apply to the message.
§Returns
A Result containing the JSON response as serde_json::Value
on success, or an OpenAIError
on failure.
Sourcepub async fn delete_message(
&self,
thread_id: &str,
message_id: &str,
) -> OpenAIResult<Value>
pub async fn delete_message( &self, thread_id: &str, message_id: &str, ) -> OpenAIResult<Value>
Delete a specific message by its ID in a thread.
§Arguments
thread_id
- The ID of the thread containing the message.message_id
- The ID of the message to delete.
§Returns
A Result containing the JSON response as serde_json::Value
on success, or an OpenAIError
on failure.
Sourcepub async fn create_run(
&self,
thread_id: &str,
assistant_id: &str,
model: Option<&str>,
instructions: Option<&str>,
additional_instructions: Option<&str>,
additional_messages: Option<Vec<Value>>,
tools: Option<Vec<Value>>,
metadata: Option<Value>,
temperature: Option<f64>,
top_p: Option<f64>,
stream: Option<bool>,
max_prompt_tokens: Option<u32>,
max_completion_tokens: Option<u32>,
truncation_strategy: Option<Value>,
tool_choice: Option<Value>,
parallel_tool_calls: Option<bool>,
response_format: Option<Value>,
) -> OpenAIResult<Value>
pub async fn create_run( &self, thread_id: &str, assistant_id: &str, model: Option<&str>, instructions: Option<&str>, additional_instructions: Option<&str>, additional_messages: Option<Vec<Value>>, tools: Option<Vec<Value>>, metadata: Option<Value>, temperature: Option<f64>, top_p: Option<f64>, stream: Option<bool>, max_prompt_tokens: Option<u32>, max_completion_tokens: Option<u32>, truncation_strategy: Option<Value>, tool_choice: Option<Value>, parallel_tool_calls: Option<bool>, response_format: Option<Value>, ) -> OpenAIResult<Value>
Create and initiate a run in a specific thread with specified parameters.
§Arguments
- Various parameters used to customize the creation of the run.
§Returns
A Result containing the JSON response as serde_json::Value
on success, or an OpenAIError
on failure.
Sourcepub async fn list_runs(
&self,
thread_id: &str,
limit: Option<u32>,
order: Option<&str>,
after: Option<&str>,
before: Option<&str>,
) -> OpenAIResult<Value>
pub async fn list_runs( &self, thread_id: &str, limit: Option<u32>, order: Option<&str>, after: Option<&str>, before: Option<&str>, ) -> OpenAIResult<Value>
List runs within a specific thread with optional filters.
§Arguments
thread_id
- The ID of the thread to list runs from.limit
- Optional limit on the number of runs to list.order
- Optional order parameter for the run listing.after
- Optional parameter to list runs after a specific time.before
- Optional parameter to list runs before a specific time.
§Returns
A Result containing the JSON response as serde_json::Value
on success, or an OpenAIError
on failure.
Sourcepub async fn retrieve_run(
&self,
thread_id: &str,
run_id: &str,
) -> OpenAIResult<Value>
pub async fn retrieve_run( &self, thread_id: &str, run_id: &str, ) -> OpenAIResult<Value>
Retrieve details of a specific run by its ID.
§Arguments
thread_id
- The ID of the thread containing the run.run_id
- The ID of the run to retrieve.
§Returns
A Result containing the JSON response as serde_json::Value
on success, or an OpenAIError
on failure.
Sourcepub async fn modify_run(
&self,
thread_id: &str,
run_id: &str,
metadata: Value,
) -> OpenAIResult<Value>
pub async fn modify_run( &self, thread_id: &str, run_id: &str, metadata: Value, ) -> OpenAIResult<Value>
Modify a specific run’s metadata in a thread.
§Arguments
thread_id
- The ID of the thread containing the run.run_id
- The ID of the run to modify.metadata
- The new metadata to apply to the run.
§Returns
A Result containing the JSON response as serde_json::Value
on success, or an OpenAIError
on failure.
Sourcepub async fn delete_run(
&self,
thread_id: &str,
run_id: &str,
) -> OpenAIResult<Value>
pub async fn delete_run( &self, thread_id: &str, run_id: &str, ) -> OpenAIResult<Value>
Delete a specific run by its ID in a thread.
§Arguments
thread_id
- The ID of the thread containing the run.run_id
- The ID of the run to delete.
§Returns
A Result containing the JSON response as serde_json::Value
on success, or an OpenAIError
on failure.
Sourcepub async fn submit_tool_outputs(
&self,
thread_id: &str,
run_id: &str,
tool_outputs: Vec<Value>,
stream: Option<bool>,
) -> OpenAIResult<Value>
pub async fn submit_tool_outputs( &self, thread_id: &str, run_id: &str, tool_outputs: Vec<Value>, stream: Option<bool>, ) -> OpenAIResult<Value>
Submit tool outputs for a specific run.
§Arguments
thread_id
- The ID of the thread containing the run.run_id
- The ID of the run to submit outputs to.tool_outputs
- List of tool outputs to submit.stream
- Optional stream parameter for the submission.
§Returns
A Result containing the JSON response as serde_json::Value
on success, or an OpenAIError
on failure.
Sourcepub async fn cancel_run(
&self,
thread_id: &str,
run_id: &str,
) -> OpenAIResult<Value>
pub async fn cancel_run( &self, thread_id: &str, run_id: &str, ) -> OpenAIResult<Value>
Cancel a specific run by its ID in a thread.
§Arguments
thread_id
- The ID of the thread containing the run.run_id
- The ID of the run to cancel.
§Returns
A Result containing the JSON response as serde_json::Value
on success, or an OpenAIError
on failure.
Sourcepub async fn list_run_steps(
&self,
thread_id: &str,
run_id: &str,
limit: Option<u32>,
order: Option<&str>,
after: Option<&str>,
before: Option<&str>,
) -> OpenAIResult<Value>
pub async fn list_run_steps( &self, thread_id: &str, run_id: &str, limit: Option<u32>, order: Option<&str>, after: Option<&str>, before: Option<&str>, ) -> OpenAIResult<Value>
List steps for a specific run within a thread.
§Arguments
thread_id
- The ID of the thread containing the run.run_id
- The ID of the run to list steps from.limit
- Optional limit on the number of steps to list.order
- Optional order parameter for the steps listing.after
- Optional parameter to list steps after a specific time.before
- Optional parameter to list steps before a specific time.
§Returns
A Result containing the JSON response as serde_json::Value
on success, or an OpenAIError
on failure.
Sourcepub async fn retrieve_run_step(
&self,
thread_id: &str,
run_id: &str,
step_id: &str,
) -> OpenAIResult<Value>
pub async fn retrieve_run_step( &self, thread_id: &str, run_id: &str, step_id: &str, ) -> OpenAIResult<Value>
Retrieve a specific step by its ID from a run within a thread.
§Arguments
thread_id
- The ID of the thread containing the run.run_id
- The ID of the run containing the step.step_id
- The ID of the step to retrieve.
§Returns
A Result containing the JSON response as serde_json::Value
on success, or an OpenAIError
on failure.