pub trait RequestAdapter {
Show 13 methods
// Required methods
fn messages(&self) -> &[MessageNum];
fn messages_mut(&mut self) -> &mut Vec<MessageNum>;
fn system_instructions(&self) -> Vec<&MessageNum>;
fn response_json_schema(&self) -> Option<&Value>;
fn preprend_system_instructions(
&mut self,
messages: Vec<MessageNum>,
) -> Result<(), TypeError>;
fn get_py_system_instructions<'py>(
&self,
py: Python<'py>,
) -> Result<Bound<'py, PyList>, TypeError>;
fn model_settings<'py>(
&self,
py: Python<'py>,
) -> Result<Bound<'py, PyAny>, TypeError>;
fn to_request_body(&self) -> Result<Value, TypeError>;
fn match_provider(&self, provider: &Provider) -> bool;
fn build_provider_enum(
messages: Vec<MessageNum>,
system_instructions: Vec<MessageNum>,
model: String,
settings: ModelSettings,
response_json_schema: Option<Value>,
) -> Result<ProviderRequest, TypeError>;
fn set_response_json_schema(&mut self, response_json_schema: Option<Value>);
fn add_tools(
&mut self,
tools: Vec<AgentToolDefinition>,
) -> Result<(), TypeError>;
// Provided method
fn insert_message(&mut self, message: MessageNum, idx: Option<usize>) { ... }
}Expand description
Core trait that must be implemented for all request types
Required Methods§
Sourcefn messages(&self) -> &[MessageNum]
fn messages(&self) -> &[MessageNum]
Returns all messages in the request
Sourcefn messages_mut(&mut self) -> &mut Vec<MessageNum>
fn messages_mut(&mut self) -> &mut Vec<MessageNum>
Returns a mutable reference to the messages in the request
Sourcefn system_instructions(&self) -> Vec<&MessageNum>
fn system_instructions(&self) -> Vec<&MessageNum>
Returns all system instructions in the request
Sourcefn response_json_schema(&self) -> Option<&Value>
fn response_json_schema(&self) -> Option<&Value>
Returns the response JSON schema if set
Sourcefn preprend_system_instructions(
&mut self,
messages: Vec<MessageNum>,
) -> Result<(), TypeError>
fn preprend_system_instructions( &mut self, messages: Vec<MessageNum>, ) -> Result<(), TypeError>
Prepends system instructions to the messages
Sourcefn get_py_system_instructions<'py>(
&self,
py: Python<'py>,
) -> Result<Bound<'py, PyList>, TypeError>
fn get_py_system_instructions<'py>( &self, py: Python<'py>, ) -> Result<Bound<'py, PyList>, TypeError>
Sourcefn model_settings<'py>(
&self,
py: Python<'py>,
) -> Result<Bound<'py, PyAny>, TypeError>
fn model_settings<'py>( &self, py: Python<'py>, ) -> Result<Bound<'py, PyAny>, TypeError>
Returns the model settings for the request (python object)
Sourcefn to_request_body(&self) -> Result<Value, TypeError>
fn to_request_body(&self) -> Result<Value, TypeError>
Converts the request to a JSON value for sending to the provider
Sourcefn match_provider(&self, provider: &Provider) -> bool
fn match_provider(&self, provider: &Provider) -> bool
Checks if the request matches the given provider
Sourcefn build_provider_enum(
messages: Vec<MessageNum>,
system_instructions: Vec<MessageNum>,
model: String,
settings: ModelSettings,
response_json_schema: Option<Value>,
) -> Result<ProviderRequest, TypeError>
fn build_provider_enum( messages: Vec<MessageNum>, system_instructions: Vec<MessageNum>, model: String, settings: ModelSettings, response_json_schema: Option<Value>, ) -> Result<ProviderRequest, TypeError>
Builds a provider-specific request enum from the given parameters The ProviderRequest enum encapsulates all supported provider request types and is an attribute of the Prompt struct. ProviderRequest is built on instantiation of the Prompt
Sourcefn set_response_json_schema(&mut self, response_json_schema: Option<Value>)
fn set_response_json_schema(&mut self, response_json_schema: Option<Value>)
Sets the response JSON schema for the request Typically used as part of workflows when adding tasks
Provided Methods§
Sourcefn insert_message(&mut self, message: MessageNum, idx: Option<usize>)
fn insert_message(&mut self, message: MessageNum, idx: Option<usize>)
Inserts a message at the specified index (or at the start if None)
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.