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>) -> Codex
pub fn new(credentials: CodexCredentials, model: impl Into<String>) -> Codex
Create a client for model using the given credentials.
Sourcepub fn with_base_url(self, base_url: impl Into<String>) -> Codex
pub fn with_base_url(self, base_url: impl Into<String>) -> Codex
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>) -> Codex
pub fn with_originator(self, originator: impl Into<String>) -> Codex
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,
) -> Codex
pub fn on_refresh( self, callback: impl Fn(&CodexCredentials) + Send + Sync + 'static, ) -> Codex
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 From<Codex> for CloudProvider
impl From<Codex> for CloudProvider
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, <Codex as LanguageModel>::Error>> + Send
fn respond( &self, request: LLMRequest, ) -> impl Stream<Item = Result<Event, <Codex as LanguageModel>::Error>> + Send
Generates a streaming response to a conversation. Read more
Source§fn profile(
&self,
) -> impl Future<Output = Result<Profile, <Codex as LanguageModel>::Error>> + Send
fn profile( &self, ) -> impl Future<Output = Result<Profile, <Codex as LanguageModel>::Error>> + 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
Source§fn retry_policy(&self) -> RetryPolicy
fn retry_policy(&self) -> RetryPolicy
How a request to this model that failed with a retryable failure is
sent again. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for Codex
impl !UnwindSafe for Codex
impl Forget 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