pub struct OllamaCtx { /* private fields */ }Expand description
本地 Ollama 模型的上下文策略。
Implementations§
Trait Implementations§
Source§impl CtxBuilder for OllamaCtx
impl CtxBuilder for OllamaCtx
Source§fn needs_compression(&self, conv: &Conversation, system_tokens: usize) -> bool
fn needs_compression(&self, conv: &Conversation, system_tokens: usize) -> bool
复用 ctx::render::needs_compression — 它的绝对 headroom 公式
ctx_window - min(13K, ctx_window/4) 在小窗口下天然偏紧
(8K Ollama → 6K threshold = 75% 触发, 比之前的 35% 晚但更接近“撑爆前一刻“的真实 headroom)。
之前的 35% hardcoded 阈值是为 4-8K Ollama 量身的早触发, 但在
16K-32K Ollama 上反而过早。新公式自适应窗口大小, 不再需要单独的 Ollama tier。
Source§fn build_messages(
&self,
conv: &Conversation,
system_prompt: &str,
turn_reminder: &str,
) -> (Vec<Message>, ContextStats)
fn build_messages( &self, conv: &Conversation, system_prompt: &str, turn_reminder: &str, ) -> (Vec<Message>, ContextStats)
Build the messages array to send to the LLM for this turn. Read more
Source§fn compression_plan(&self, conv: &Conversation) -> Option<(String, usize)>
fn compression_plan(&self, conv: &Conversation) -> Option<(String, usize)>
Produce a compression plan
(content_to_summarize, messages_to_remove). Default: None (no compression).Source§fn truncate_tool_output(&self, result: &mut ToolResult, tool_name: &str)
fn truncate_tool_output(&self, result: &mut ToolResult, tool_name: &str)
Truncate a single tool output in place.
Source§fn ctx_window(&self) -> usize
fn ctx_window(&self) -> usize
Effective token budget for this strategy. Read more
Auto Trait Implementations§
impl Freeze for OllamaCtx
impl RefUnwindSafe for OllamaCtx
impl Send for OllamaCtx
impl Sync for OllamaCtx
impl Unpin for OllamaCtx
impl UnsafeUnpin for OllamaCtx
impl UnwindSafe for OllamaCtx
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 more