pub struct ChatRequest {
pub model: String,
pub messages: Vec<Value>,
pub extra: Map<String, Value>,
}Expand description
Wire-shape chat-completion request.
Fields§
§model: String§messages: Vec<Value>Raw message bodies — kept as serde_json::Value so multipart content
(image_url, audio, tool calls with arbitrary payloads) round-trips
without bespoke enums.
extra: Map<String, Value>Catch-all for every other OpenAI parameter (temperature, stream,
tools, …). #[serde(flatten)] makes them inline peers of model
and messages on the wire.
Implementations§
Source§impl ChatRequest
impl ChatRequest
Sourcepub fn new(model: impl Into<String>, messages: Vec<Value>) -> Self
pub fn new(model: impl Into<String>, messages: Vec<Value>) -> Self
Build a request with model, messages, and no extras.
Sourcepub fn with_extra(self, key: impl Into<String>, value: Value) -> Self
pub fn with_extra(self, key: impl Into<String>, value: Value) -> Self
Insert (or replace) one extra parameter. Builder-style.
Sourcepub fn is_streaming(&self) -> bool
pub fn is_streaming(&self) -> bool
true iff the request asks for streaming (stream: true in extras).
Trait Implementations§
Source§impl Clone for ChatRequest
impl Clone for ChatRequest
Source§fn clone(&self) -> ChatRequest
fn clone(&self) -> ChatRequest
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ChatRequest
impl Debug for ChatRequest
Source§impl<'de> Deserialize<'de> for ChatRequest
impl<'de> Deserialize<'de> for ChatRequest
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ChatRequest
impl RefUnwindSafe for ChatRequest
impl Send for ChatRequest
impl Sync for ChatRequest
impl Unpin for ChatRequest
impl UnsafeUnpin for ChatRequest
impl UnwindSafe for ChatRequest
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