pub struct SamplingParams {Show 14 fields
pub max_tokens: Option<usize>,
pub temperature: Option<f32>,
pub top_p: Option<f32>,
pub top_k: Option<usize>,
pub repeat_penalty: Option<f32>,
pub repeat_last_n: Option<usize>,
pub stop_tokens: Option<Vec<String>>,
pub seed: Option<u64>,
pub length_penalty: Option<f32>,
pub typical_p: Option<f32>,
pub epsilon_cutoff: Option<f32>,
pub eta_cutoff: Option<f32>,
pub do_sample: Option<bool>,
pub timeout_ms: Option<u64>,
}Expand description
Unified sampling parameters with Option fields for clean precedence merging.
All fields are Option
Fields§
§max_tokens: Option<usize>§temperature: Option<f32>§top_p: Option<f32>§top_k: Option<usize>§repeat_penalty: Option<f32>§repeat_last_n: Option<usize>§stop_tokens: Option<Vec<String>>§seed: Option<u64>§length_penalty: Option<f32>§typical_p: Option<f32>§epsilon_cutoff: Option<f32>§eta_cutoff: Option<f32>§do_sample: Option<bool>§timeout_ms: Option<u64>Implementations§
Source§impl SamplingParams
impl SamplingParams
Sourcepub async fn from_model_path(model_path: &Path) -> Result<Self, Box<dyn Error>>
pub async fn from_model_path(model_path: &Path) -> Result<Self, Box<dyn Error>>
Load model-specific config from a model directory
Sourcepub fn merge(self, other: Self) -> Self
pub fn merge(self, other: Self) -> Self
Merge with another config. The other config takes precedence for any Some values.
This enables clear precedence: base.merge(override) where override wins.
Sourcepub fn into_generation_request(self, prompt: String) -> GenerationRequest
pub fn into_generation_request(self, prompt: String) -> GenerationRequest
Build a GenerationRequest from these sampling params and a prompt.
Applies SamplingParams fields as Option<T> — None means “not specified”,
letting the engine use its defaults.
Sourcepub fn resolve(self) -> ResolvedSamplingParams
pub fn resolve(self) -> ResolvedSamplingParams
Resolve to concrete values with defaults
Trait Implementations§
Source§impl Clone for SamplingParams
impl Clone for SamplingParams
Source§fn clone(&self) -> SamplingParams
fn clone(&self) -> SamplingParams
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 SamplingParams
impl Debug for SamplingParams
Source§impl Default for SamplingParams
impl Default for SamplingParams
Source§fn default() -> SamplingParams
fn default() -> SamplingParams
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for SamplingParams
impl<'de> Deserialize<'de> for SamplingParams
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
Source§impl From<&ChatCompletionRequest> for SamplingParams
impl From<&ChatCompletionRequest> for SamplingParams
Source§fn from(req: &ChatCompletionRequest) -> Self
fn from(req: &ChatCompletionRequest) -> Self
Converts to this type from the input type.
Source§impl From<&CompletionRequest> for SamplingParams
impl From<&CompletionRequest> for SamplingParams
Source§fn from(req: &CompletionRequest) -> Self
fn from(req: &CompletionRequest) -> Self
Converts to this type from the input type.
Source§impl From<&SamplingParamDefaults> for SamplingParams
impl From<&SamplingParamDefaults> for SamplingParams
Source§fn from(defaults: &SamplingParamDefaults) -> Self
fn from(defaults: &SamplingParamDefaults) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for SamplingParams
impl RefUnwindSafe for SamplingParams
impl Send for SamplingParams
impl Sync for SamplingParams
impl Unpin for SamplingParams
impl UnsafeUnpin for SamplingParams
impl UnwindSafe for SamplingParams
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<T> JaggedSlice<T> for T
impl<T> JaggedSlice<T> for T
§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
The none-equivalent value.
§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
The none-equivalent value.
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>
§impl<T> ServiceExt for T
impl<T> ServiceExt for T
§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
Apply a transformation to the response body. Read more
§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using HTTP status codes. Read more
§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using gRPC headers. Read more