pub trait BaseLanguageModel<Input: Send + Sync + 'static, Output: Send + Sync + 'static>: Runnable<Input, Output> {
// Required methods
fn model_name(&self) -> &str;
fn get_num_tokens(&self, text: &str) -> usize;
fn with_temperature(self, temp: f32) -> Self
where Self: Sized;
fn with_max_tokens(self, max: usize) -> Self
where Self: Sized;
// Provided methods
fn temperature(&self) -> Option<f32> { ... }
fn max_tokens(&self) -> Option<usize> { ... }
}Expand description
语言模型基础 trait
所有语言模型包装器都继承自这个基类。 它继承自 Runnable 接口,提供统一的调用方式。
Required Methods§
Sourcefn model_name(&self) -> &str
fn model_name(&self) -> &str
获取模型名称
Sourcefn with_temperature(self, temp: f32) -> Selfwhere
Self: Sized,
fn with_temperature(self, temp: f32) -> Selfwhere
Self: Sized,
设置温度参数
Sourcefn with_max_tokens(self, max: usize) -> Selfwhere
Self: Sized,
fn with_max_tokens(self, max: usize) -> Selfwhere
Self: Sized,
设置最大 token 数
Provided Methods§
Sourcefn temperature(&self) -> Option<f32>
fn temperature(&self) -> Option<f32>
获取温度参数
Sourcefn max_tokens(&self) -> Option<usize>
fn max_tokens(&self) -> Option<usize>
获取最大 token 数