pub struct Codex { /* private fields */ }Expand description
A LanguageModel for a single model on the Codex subscription backend.
Implementations§
Source§impl Codex
impl Codex
Sourcepub fn new(credentials: CodexCredentials, model: impl Into<String>) -> Self
pub fn new(credentials: CodexCredentials, model: impl Into<String>) -> Self
Create a client for model using the given credentials.
Sourcepub fn with_base_url(self, base_url: impl Into<String>) -> Self
pub fn with_base_url(self, base_url: impl Into<String>) -> Self
Override the backend base URL (defaults to the Codex subscription endpoint).
§Panics
Panics if the client has already been cloned/shared.
Sourcepub fn with_originator(self, originator: impl Into<String>) -> Self
pub fn with_originator(self, originator: impl Into<String>) -> Self
Override the originator header (defaults to ORIGINATOR).
§Panics
Panics if the client has already been cloned/shared.
Sourcepub fn on_refresh(
self,
callback: impl Fn(&CodexCredentials) + Send + Sync + 'static,
) -> Self
pub fn on_refresh( self, callback: impl Fn(&CodexCredentials) + Send + Sync + 'static, ) -> Self
Register a callback fired whenever tokens rotate.
§Panics
Panics if the client has already been cloned/shared.
Sourcepub async fn credentials(&self) -> CodexCredentials
pub async fn credentials(&self) -> CodexCredentials
A snapshot of the current credentials.
Trait Implementations§
Source§impl LanguageModel for Codex
impl LanguageModel for Codex
Source§type Error = CodexError
type Error = CodexError
The error type returned by this language model.
Source§fn respond(
&self,
request: LLMRequest,
) -> impl Stream<Item = Result<Event, Self::Error>> + Send
fn respond( &self, request: LLMRequest, ) -> impl Stream<Item = Result<Event, Self::Error>> + Send
Generates a streaming response to a conversation. Read more
Source§fn profile(&self) -> impl Future<Output = ModelProfile> + Send
fn profile(&self) -> impl Future<Output = ModelProfile> + Send
Returns model profile and capabilities. Read more
Source§fn respond_with_tools(
&self,
request: LLMRequestWithTools<'_>,
) -> impl Stream<Item = Result<Event, Self::Error>> + Send
fn respond_with_tools( &self, request: LLMRequestWithTools<'_>, ) -> impl Stream<Item = Result<Event, Self::Error>> + Send
Generates a streaming response with a mutable tool registry. Read more
Source§fn generate<T>(
&self,
request: LLMRequest,
) -> impl Future<Output = Result<T, GenerateError<Self::Error>>> + Sendwhere
T: JsonSchema + DeserializeOwned + 'static,
fn generate<T>(
&self,
request: LLMRequest,
) -> impl Future<Output = Result<T, GenerateError<Self::Error>>> + Sendwhere
T: JsonSchema + DeserializeOwned + 'static,
Generates structured output conforming to JSON schema. Read more
Source§fn complete(
&self,
prefix: &str,
) -> impl Stream<Item = Result<Event, Self::Error>> + Send
fn complete( &self, prefix: &str, ) -> impl Stream<Item = Result<Event, Self::Error>> + Send
Completes given text prefix.
Source§fn summarize(
&self,
text: &str,
) -> impl Stream<Item = Result<Event, Self::Error>> + Send
fn summarize( &self, text: &str, ) -> impl Stream<Item = Result<Event, Self::Error>> + Send
Summarizes text. Read more
Source§fn categorize<T>(
&self,
text: &str,
) -> impl Future<Output = Result<T, GenerateError<Self::Error>>> + Sendwhere
T: JsonSchema + DeserializeOwned + 'static,
fn categorize<T>(
&self,
text: &str,
) -> impl Future<Output = Result<T, GenerateError<Self::Error>>> + Sendwhere
T: JsonSchema + DeserializeOwned + 'static,
Categorizes text. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for Codex
impl !UnwindSafe for Codex
impl Freeze for Codex
impl Send for Codex
impl Sync for Codex
impl Unpin for Codex
impl UnsafeUnpin for Codex
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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