Struct Client

Source
pub struct Client {
    pub api_endpoint: String,
    pub api_key: String,
    pub organization: Option<String>,
    pub proxy: Option<String>,
    pub timeout: Option<u64>,
}

Fields§

§api_endpoint: String§api_key: String§organization: Option<String>§proxy: Option<String>§timeout: Option<u64>

Implementations§

Source§

impl OpenAIClient

Source

pub fn new(api_key: String) -> OpenAIClient

Source

pub fn new_with_endpoint(api_endpoint: String, api_key: String) -> OpenAIClient

Source

pub fn new_with_organization( api_key: String, organization: String, ) -> OpenAIClient

Source

pub fn new_with_proxy(api_key: String, proxy: String) -> OpenAIClient

Source

pub fn new_with_timeout(api_key: String, timeout: u64) -> OpenAIClient

Source

pub async fn completion( &self, req: CompletionRequest, ) -> Result<CompletionResponse, APIError>

Source

pub async fn edit(&self, req: EditRequest) -> Result<EditResponse, APIError>

Source

pub async fn image_generation( &self, req: ImageGenerationRequest, ) -> Result<ImageGenerationResponse, APIError>

Source

pub async fn image_edit( &self, req: ImageEditRequest, ) -> Result<ImageEditResponse, APIError>

Source

pub async fn image_variation( &self, req: ImageVariationRequest, ) -> Result<ImageVariationResponse, APIError>

Source

pub async fn embedding( &self, req: EmbeddingRequest, ) -> Result<EmbeddingResponse, APIError>

Source

pub async fn file_list(&self) -> Result<FileListResponse, APIError>

Source

pub async fn upload_file( &self, req: FileUploadRequest, ) -> Result<FileUploadResponse, APIError>

Source

pub async fn delete_file( &self, req: FileDeleteRequest, ) -> Result<FileDeleteResponse, APIError>

Source

pub async fn retrieve_file( &self, file_id: String, ) -> Result<FileRetrieveResponse, APIError>

Source

pub async fn retrieve_file_content( &self, file_id: String, ) -> Result<Bytes, APIError>

Source

pub async fn chat_completion( &self, req: ChatCompletionRequest, ) -> Result<ChatCompletionResponse, APIError>

Source

pub async fn audio_transcription( &self, req: AudioTranscriptionRequest, ) -> Result<AudioTranscriptionResponse, APIError>

Source

pub async fn audio_translation( &self, req: AudioTranslationRequest, ) -> Result<AudioTranslationResponse, APIError>

Source

pub async fn audio_speech( &self, req: AudioSpeechRequest, ) -> Result<AudioSpeechResponse, APIError>

Source

pub async fn create_fine_tuning_job( &self, req: CreateFineTuningJobRequest, ) -> Result<FineTuningJobObject, APIError>

Source

pub async fn list_fine_tuning_jobs( &self, ) -> Result<FineTuningPagination<FineTuningJobObject>, APIError>

Source

pub async fn list_fine_tuning_job_events( &self, req: ListFineTuningJobEventsRequest, ) -> Result<FineTuningPagination<FineTuningJobEvent>, APIError>

Source

pub async fn retrieve_fine_tuning_job( &self, req: RetrieveFineTuningJobRequest, ) -> Result<FineTuningJobObject, APIError>

Source

pub async fn cancel_fine_tuning_job( &self, req: CancelFineTuningJobRequest, ) -> Result<FineTuningJobObject, APIError>

Source

pub async fn create_moderation( &self, req: CreateModerationRequest, ) -> Result<CreateModerationResponse, APIError>

Source

pub async fn create_assistant( &self, req: AssistantRequest, ) -> Result<AssistantObject, APIError>

Source

pub async fn retrieve_assistant( &self, assistant_id: String, ) -> Result<AssistantObject, APIError>

Source

pub async fn modify_assistant( &self, assistant_id: String, req: AssistantRequest, ) -> Result<AssistantObject, APIError>

Source

pub async fn delete_assistant( &self, assistant_id: String, ) -> Result<DeletionStatus, APIError>

Source

pub async fn list_assistant( &self, limit: Option<i64>, order: Option<String>, after: Option<String>, before: Option<String>, ) -> Result<ListAssistant, APIError>

Source

pub async fn create_assistant_file( &self, assistant_id: String, req: AssistantFileRequest, ) -> Result<AssistantFileObject, APIError>

Source

pub async fn retrieve_assistant_file( &self, assistant_id: String, file_id: String, ) -> Result<AssistantFileObject, APIError>

Source

pub async fn delete_assistant_file( &self, assistant_id: String, file_id: String, ) -> Result<DeletionStatus, APIError>

Source

pub async fn list_assistant_file( &self, assistant_id: String, limit: Option<i64>, order: Option<String>, after: Option<String>, before: Option<String>, ) -> Result<ListAssistantFile, APIError>

Source

pub async fn create_thread( &self, req: CreateThreadRequest, ) -> Result<ThreadObject, APIError>

Source

pub async fn retrieve_thread( &self, thread_id: String, ) -> Result<ThreadObject, APIError>

Source

pub async fn modify_thread( &self, thread_id: String, req: ModifyThreadRequest, ) -> Result<ThreadObject, APIError>

Source

pub async fn delete_thread( &self, thread_id: String, ) -> Result<DeletionStatus, APIError>

Source

pub async fn create_message( &self, thread_id: String, req: CreateMessageRequest, ) -> Result<MessageObject, APIError>

Source

pub async fn retrieve_message( &self, thread_id: String, message_id: String, ) -> Result<MessageObject, APIError>

Source

pub async fn modify_message( &self, thread_id: String, message_id: String, req: ModifyMessageRequest, ) -> Result<MessageObject, APIError>

Source

pub async fn list_messages( &self, thread_id: String, ) -> Result<ListMessage, APIError>

Source

pub async fn retrieve_message_file( &self, thread_id: String, message_id: String, file_id: String, ) -> Result<MessageFileObject, APIError>

Source

pub async fn list_message_file( &self, thread_id: String, message_id: String, limit: Option<i64>, order: Option<String>, after: Option<String>, before: Option<String>, ) -> Result<ListMessageFile, APIError>

Source

pub async fn create_run( &self, thread_id: String, req: CreateRunRequest, ) -> Result<RunObject, APIError>

Source

pub async fn retrieve_run( &self, thread_id: String, run_id: String, ) -> Result<RunObject, APIError>

Source

pub async fn modify_run( &self, thread_id: String, run_id: String, req: ModifyRunRequest, ) -> Result<RunObject, APIError>

Source

pub async fn list_run( &self, thread_id: String, limit: Option<i64>, order: Option<String>, after: Option<String>, before: Option<String>, ) -> Result<ListRun, APIError>

Source

pub async fn cancel_run( &self, thread_id: String, run_id: String, ) -> Result<RunObject, APIError>

Source

pub async fn create_thread_and_run( &self, req: CreateThreadAndRunRequest, ) -> Result<RunObject, APIError>

Source

pub async fn retrieve_run_step( &self, thread_id: String, run_id: String, step_id: String, ) -> Result<RunStepObject, APIError>

Source

pub async fn list_run_step( &self, thread_id: String, run_id: String, limit: Option<i64>, order: Option<String>, after: Option<String>, before: Option<String>, ) -> Result<ListRunStep, APIError>

Source

pub async fn create_batch( &self, req: CreateBatchRequest, ) -> Result<BatchResponse, APIError>

Source

pub async fn retrieve_batch( &self, batch_id: String, ) -> Result<BatchResponse, APIError>

Source

pub async fn cancel_batch( &self, batch_id: String, ) -> Result<BatchResponse, APIError>

Source

pub async fn list_batch( &self, after: Option<String>, limit: Option<i64>, ) -> Result<ListBatchResponse, APIError>

Auto Trait Implementations§

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<S> AssignWithType for S

Source§

fn assign_with_type<T, IntoT>(&mut self, component: IntoT)
where IntoT: Into<T>, S: Assign<T, IntoT>,

Sets the value of a component by its type. 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<C, E> EntryToVal<C> for E
where C: Collection<Entry = E>,

Source§

type Val = <C as Collection>::Val

The type of values stored in the collection. This might be distinct from Entry in complex collections. For example, in a HashMap, while Entry might be a ( key, value ) tuple, Val might only be the value part.
Source§

fn entry_to_val(self) -> <E as EntryToVal<C>>::Val

Converts an entry into a value representation specific to the type of collection. This conversion is crucial for handling operations on entries, especially when they need to be treated or accessed as individual values, such as retrieving the value part from a key-value pair in a hash map.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<Initial, Error, Final> TransitiveTryFrom<Error, Initial> for Final

Source§

fn transitive_try_from<Transitive>(src: Initial) -> Result<Self, Error>
where Transitive: TryFrom<Initial>, Self: TryFrom<Transitive, Error = Error>, Error: From<<Transitive as TryFrom<Initial>>::Error>,

Performs a transitive try_from conversion. Read more
Source§

impl<Error, Final, Initial> TransitiveTryInto<Error, Final> for Initial

Source§

fn transitive_try_into<Transitive>(self) -> Result<Final, Error>
where Self: TryInto<Transitive>, Transitive: TryInto<Final, Error = Error>, Error: From<Self::Error>,

Performs a transitive try_into conversion. 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> TypeName for T
where T: ?Sized,

Source§

fn type_name(&self) -> &'static str

Return name of type of variable.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<C, Val> ValToEntry<C> for Val
where C: CollectionValToEntry<Val>,

Source§

fn val_to_entry(self) -> <C as CollectionValToEntry<Val>>::Entry

Invokes the val_to_entry function of the CollectionValToEntry trait to convert the value to an entry.

Source§

type Entry = <C as CollectionValToEntry<Val>>::Entry

Represents the type of entry that corresponds to the value within the collection.
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,

Source§

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