pub struct AssistantsClient<'a, T = ()> { /* private fields */ }Expand description
Client for assistants API.
Implementations§
Source§impl<T: Default + Send + Sync> AssistantsClient<'_, T>
impl<T: Default + Send + Sync> AssistantsClient<'_, T>
Sourcepub async fn create(&self, builder: AssistantBuilder) -> Result<AssistantObject>
pub async fn create(&self, builder: AssistantBuilder) -> Result<AssistantObject>
Create a new assistant.
§Example
ⓘ
use openai_ergonomic::Client;
use openai_ergonomic::builders::assistants::AssistantBuilder;
let client = Client::from_env()?;
let builder = AssistantBuilder::new("gpt-4")
.name("Math Tutor")
.instructions("You are a helpful math tutor.");
let assistant = client.assistants().create(builder).await?;
println!("Created assistant: {}", assistant.id);Sourcepub async fn list(
&self,
limit: Option<i32>,
order: Option<&str>,
after: Option<&str>,
before: Option<&str>,
) -> Result<ListAssistantsResponse>
pub async fn list( &self, limit: Option<i32>, order: Option<&str>, after: Option<&str>, before: Option<&str>, ) -> Result<ListAssistantsResponse>
Sourcepub async fn update(
&self,
assistant_id: impl Into<String>,
builder: AssistantBuilder,
) -> Result<AssistantObject>
pub async fn update( &self, assistant_id: impl Into<String>, builder: AssistantBuilder, ) -> Result<AssistantObject>
Update an assistant.
§Example
ⓘ
use openai_ergonomic::Client;
use openai_ergonomic::builders::assistants::AssistantBuilder;
let client = Client::from_env()?;
let builder = AssistantBuilder::new("gpt-4")
.name("Updated Name")
.instructions("Updated instructions");
let assistant = client.assistants().update("asst_123", builder).await?;
println!("Updated: {}", assistant.id);Sourcepub async fn delete(
&self,
assistant_id: impl Into<String>,
) -> Result<DeleteAssistantResponse>
pub async fn delete( &self, assistant_id: impl Into<String>, ) -> Result<DeleteAssistantResponse>
Sourcepub async fn create_run(
&self,
thread_id: impl Into<String>,
builder: RunBuilder,
) -> Result<RunObject>
pub async fn create_run( &self, thread_id: impl Into<String>, builder: RunBuilder, ) -> Result<RunObject>
Create a run on a thread.
§Example
ⓘ
use openai_ergonomic::Client;
use openai_ergonomic::builders::assistants::RunBuilder;
let client = Client::from_env()?;
let builder = RunBuilder::new("asst_123");
let run = client.assistants().create_run("thread_123", builder).await?;
println!("Run created: {}", run.id);Sourcepub async fn list_runs(
&self,
thread_id: impl Into<String>,
limit: Option<i32>,
order: Option<&str>,
after: Option<&str>,
before: Option<&str>,
) -> Result<ListRunsResponse>
pub async fn list_runs( &self, thread_id: impl Into<String>, limit: Option<i32>, order: Option<&str>, after: Option<&str>, before: Option<&str>, ) -> Result<ListRunsResponse>
Sourcepub async fn get_run(
&self,
thread_id: impl Into<String>,
run_id: impl Into<String>,
) -> Result<RunObject>
pub async fn get_run( &self, thread_id: impl Into<String>, run_id: impl Into<String>, ) -> Result<RunObject>
Sourcepub async fn cancel_run(
&self,
thread_id: impl Into<String>,
run_id: impl Into<String>,
) -> Result<RunObject>
pub async fn cancel_run( &self, thread_id: impl Into<String>, run_id: impl Into<String>, ) -> Result<RunObject>
Sourcepub async fn submit_tool_outputs(
&self,
thread_id: impl Into<String>,
run_id: impl Into<String>,
tool_outputs: Vec<SubmitToolOutputsRunRequestToolOutputsInner>,
) -> Result<RunObject>
pub async fn submit_tool_outputs( &self, thread_id: impl Into<String>, run_id: impl Into<String>, tool_outputs: Vec<SubmitToolOutputsRunRequestToolOutputsInner>, ) -> Result<RunObject>
Submit tool outputs to a run.
§Example
ⓘ
use openai_ergonomic::Client;
let client = Client::from_env()?;
let outputs = vec![
SubmitToolOutputsRunRequestToolOutputsInner::new("call_123", "output data")
];
let run = client.assistants().submit_tool_outputs("thread_123", "run_123", outputs).await?;
println!("Tool outputs submitted: {}", run.id);Sourcepub async fn create_message(
&self,
thread_id: impl Into<String>,
builder: MessageBuilder,
) -> Result<MessageObject>
pub async fn create_message( &self, thread_id: impl Into<String>, builder: MessageBuilder, ) -> Result<MessageObject>
Create a message on a thread.
§Example
ⓘ
use openai_ergonomic::Client;
use openai_ergonomic::builders::assistants::MessageBuilder;
let client = Client::from_env()?;
let builder = MessageBuilder::new("user", "Hello, assistant!");
let message = client.assistants().create_message("thread_123", builder).await?;
println!("Message created: {}", message.id);Sourcepub async fn list_messages(
&self,
thread_id: impl Into<String>,
limit: Option<i32>,
order: Option<&str>,
after: Option<&str>,
before: Option<&str>,
run_id: Option<&str>,
) -> Result<ListMessagesResponse>
pub async fn list_messages( &self, thread_id: impl Into<String>, limit: Option<i32>, order: Option<&str>, after: Option<&str>, before: Option<&str>, run_id: Option<&str>, ) -> Result<ListMessagesResponse>
Sourcepub async fn get_message(
&self,
thread_id: impl Into<String>,
message_id: impl Into<String>,
) -> Result<MessageObject>
pub async fn get_message( &self, thread_id: impl Into<String>, message_id: impl Into<String>, ) -> Result<MessageObject>
Sourcepub async fn list_run_steps(
&self,
thread_id: impl Into<String>,
run_id: impl Into<String>,
limit: Option<i32>,
order: Option<&str>,
after: Option<&str>,
before: Option<&str>,
include: Option<Vec<String>>,
) -> Result<ListRunStepsResponse>
pub async fn list_run_steps( &self, thread_id: impl Into<String>, run_id: impl Into<String>, limit: Option<i32>, order: Option<&str>, after: Option<&str>, before: Option<&str>, include: Option<Vec<String>>, ) -> Result<ListRunStepsResponse>
Trait Implementations§
Source§impl<'a, T: Clone> Clone for AssistantsClient<'a, T>
impl<'a, T: Clone> Clone for AssistantsClient<'a, T>
Source§fn clone(&self) -> AssistantsClient<'a, T>
fn clone(&self) -> AssistantsClient<'a, T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a, T: Debug> Debug for AssistantsClient<'a, T>
impl<'a, T: Debug> Debug for AssistantsClient<'a, T>
impl<'a, T: Copy> Copy for AssistantsClient<'a, T>
Auto Trait Implementations§
impl<'a, T> Freeze for AssistantsClient<'a, T>
impl<'a, T = ()> !RefUnwindSafe for AssistantsClient<'a, T>
impl<'a, T> Send for AssistantsClient<'a, T>
impl<'a, T> Sync for AssistantsClient<'a, T>
impl<'a, T> Unpin for AssistantsClient<'a, T>
impl<'a, T = ()> !UnwindSafe for AssistantsClient<'a, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more