Struct ThreadsApi

Source
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>

Source

pub async fn create( &self, request: ThreadCreationRequest, ) -> OpenAIResult<Value>

Create a new thread with the provided request parameters.

§Arguments
§Returns

A Result containing the JSON response as serde_json::Value on success, or an OpenAIError on failure.

Source

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.

Source

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 - A ThreadModificationRequest containing the modification parameters.
§Returns

A Result containing the JSON response as serde_json::Value on success, or an OpenAIError on failure.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

§

impl<'a> Freeze for ThreadsApi<'a>

§

impl<'a> !RefUnwindSafe for ThreadsApi<'a>

§

impl<'a> Send for ThreadsApi<'a>

§

impl<'a> Sync for ThreadsApi<'a>

§

impl<'a> Unpin for ThreadsApi<'a>

§

impl<'a> !UnwindSafe for ThreadsApi<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,