pub struct ContextWindowConfig {
pub max_tokens: usize,
pub system_prompt_tokens: usize,
pub query_tokens: usize,
pub answer_tokens: usize,
pub strategy: TruncationStrategy,
pub token_strategy: TokenCountStrategy,
pub separator: String,
pub include_source: bool,
}Expand description
上下文窗口配置
Fields§
§max_tokens: usize最大 token 数(上下文窗口大小)
system_prompt_tokens: usize系统提示预留的 token 数
query_tokens: usize查询预留的 token 数
answer_tokens: usize回答预留的 token 数
strategy: TruncationStrategy截断策略
token_strategy: TokenCountStrategytoken 计数策略
separator: String片段之间的分隔符
include_source: bool是否包含来源信息
Implementations§
Source§impl ContextWindowConfig
impl ContextWindowConfig
Sourcepub fn with_system_prompt_tokens(self, tokens: usize) -> Self
pub fn with_system_prompt_tokens(self, tokens: usize) -> Self
设置系统提示预留 token 数
Sourcepub fn with_query_tokens(self, tokens: usize) -> Self
pub fn with_query_tokens(self, tokens: usize) -> Self
设置查询预留 token 数
Sourcepub fn with_answer_tokens(self, tokens: usize) -> Self
pub fn with_answer_tokens(self, tokens: usize) -> Self
设置回答预留 token 数
Sourcepub fn with_strategy(self, strategy: TruncationStrategy) -> Self
pub fn with_strategy(self, strategy: TruncationStrategy) -> Self
设置截断策略
Sourcepub fn with_token_strategy(self, strategy: TokenCountStrategy) -> Self
pub fn with_token_strategy(self, strategy: TokenCountStrategy) -> Self
设置 token 计数策略
Sourcepub fn with_separator(self, separator: impl Into<String>) -> Self
pub fn with_separator(self, separator: impl Into<String>) -> Self
设置分隔符
Sourcepub fn with_source(self, include: bool) -> Self
pub fn with_source(self, include: bool) -> Self
是否包含来源信息
Sourcepub fn available_context_tokens(&self) -> usize
pub fn available_context_tokens(&self) -> usize
计算可用于上下文的 token 数
Trait Implementations§
Source§impl Clone for ContextWindowConfig
impl Clone for ContextWindowConfig
Source§fn clone(&self) -> ContextWindowConfig
fn clone(&self) -> ContextWindowConfig
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 ContextWindowConfig
impl Debug for ContextWindowConfig
Auto Trait Implementations§
impl Freeze for ContextWindowConfig
impl RefUnwindSafe for ContextWindowConfig
impl Send for ContextWindowConfig
impl Sync for ContextWindowConfig
impl Unpin for ContextWindowConfig
impl UnsafeUnpin for ContextWindowConfig
impl UnwindSafe for ContextWindowConfig
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