#[non_exhaustive]pub struct SamplingRequest {
pub system: Option<String>,
pub prompt: String,
pub max_tokens: Option<u32>,
pub temperature: Option<f32>,
}Expand description
A request to the LLM for a text completion.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.system: Option<String>Optional system message.
prompt: StringUser message content.
max_tokens: Option<u32>Maximum tokens to generate.
temperature: Option<f32>Temperature (0.0–1.0).
Implementations§
Source§impl SamplingRequest
impl SamplingRequest
Sourcepub fn new(prompt: impl Into<String>) -> Self
pub fn new(prompt: impl Into<String>) -> Self
Create a simple prompt-only request.
§Examples
use synwire_core::agents::sampling::SamplingRequest;
let req = SamplingRequest::new("Summarise this code.");
assert_eq!(req.prompt, "Summarise this code.");
assert!(req.system.is_none());Sourcepub fn with_system(self, system: impl Into<String>) -> Self
pub fn with_system(self, system: impl Into<String>) -> Self
Set the system message.
§Examples
use synwire_core::agents::sampling::SamplingRequest;
let req = SamplingRequest::new("Hello").with_system("You are a helpful assistant.");
assert!(req.system.is_some());Sourcepub const fn with_max_tokens(self, max_tokens: u32) -> Self
pub const fn with_max_tokens(self, max_tokens: u32) -> Self
Set the maximum number of tokens to generate.
Sourcepub const fn with_temperature(self, temperature: f32) -> Self
pub const fn with_temperature(self, temperature: f32) -> Self
Set the sampling temperature.
Trait Implementations§
Source§impl Clone for SamplingRequest
impl Clone for SamplingRequest
Source§fn clone(&self) -> SamplingRequest
fn clone(&self) -> SamplingRequest
Returns a duplicate 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 moreAuto Trait Implementations§
impl Freeze for SamplingRequest
impl RefUnwindSafe for SamplingRequest
impl Send for SamplingRequest
impl Sync for SamplingRequest
impl Unpin for SamplingRequest
impl UnsafeUnpin for SamplingRequest
impl UnwindSafe for SamplingRequest
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