Struct anchor_chain::models::openai::OpenAIChatModel   
source · 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: Clone> Clone for OpenAIChatModel<T>
 
impl<T: Clone> Clone for OpenAIChatModel<T>
source§fn clone(&self) -> OpenAIChatModel<T>
 
fn clone(&self) -> OpenAIChatModel<T>
Returns a copy 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<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> Freeze for OpenAIChatModel<T>
impl<T> !RefUnwindSafe 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> !UnwindSafe 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