pub struct OpenAIChatModel<T> { /* private fields */ }Expand description
Represents a processor for sending and processing requests to the OpenAI API.
OpenAIChatModel encapsulates the functionality required to interact with
the OpenAI Chat API, handling both the construction of requests and the
parsing of responses.
Implementations§
Source§impl<T> OpenAIChatModel<T>
impl<T> OpenAIChatModel<T>
Sourcepub async fn new_with_key(
system_prompt: String,
model: String,
api_key: String,
) -> Self
pub async fn new_with_key( system_prompt: String, model: String, api_key: String, ) -> Self
Constructs a new OpenAI node using the specified API key.
The system prompt is passed in as the first message in the conversation
using ChatCompletionRequestSystemMessage.
Trait Implementations§
Source§impl<T> Debug for OpenAIChatModel<T>
impl<T> Debug for OpenAIChatModel<T>
Source§impl<T> Node for OpenAIChatModel<T>
impl<T> Node for OpenAIChatModel<T>
Source§fn process<'life0, 'async_trait>(
&'life0 self,
input: Self::Input,
) -> Pin<Box<dyn Future<Output = Result<Self::Output, AnchorChainError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn process<'life0, 'async_trait>(
&'life0 self,
input: Self::Input,
) -> Pin<Box<dyn Future<Output = Result<Self::Output, AnchorChainError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sends the input to the OpenAI API and processes the response.
Constructs a request based on the input and the system prompt, then parses the model’s response to extract and return final output.
Auto Trait Implementations§
impl<T> !RefUnwindSafe for OpenAIChatModel<T>
impl<T> !UnwindSafe for OpenAIChatModel<T>
impl<T> Freeze for OpenAIChatModel<T>
impl<T> Send for OpenAIChatModel<T>where
T: Send,
impl<T> Sync for OpenAIChatModel<T>where
T: Sync,
impl<T> Unpin for OpenAIChatModel<T>where
T: Unpin,
impl<T> UnsafeUnpin for OpenAIChatModel<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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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 moreCreates a shared type from an unshared type.