pub struct Summarizer {
pub prompts: SummaryPrompts,
pub limits: SummaryLimits,
}Expand description
Builds the request for a summary of a conversation’s older messages and reads the summary from the model’s answer. The conversation goes as text in one user message, so the model reads it rather than continues it.
Fields§
§prompts: SummaryPromptsWhat the model is asked.
limits: SummaryLimitsSizes.
Implementations§
Source§impl Summarizer
impl Summarizer
Source§impl Summarizer
impl Summarizer
Sourcepub fn request(
&self,
older: &[Arc<Message>],
previous: &str,
reason: &CompactReason,
spec: &ModelSpec,
) -> Result<CompletionRequest, UnsupportedOption>
pub fn request( &self, older: &[Arc<Message>], previous: &str, reason: &CompactReason, spec: &ModelSpec, ) -> Result<CompletionRequest, UnsupportedOption>
The request to spec for a summary of older for reason, merged
into previous when that is not empty. A summary the user asked for
keeps its focus above all; one after an overflow reads at most
AFTER_OVERFLOW of the input limit. The room below the reserve, or
half the limit when that is more, is split: the summary asks for at
most half of it, and the older messages fill the rest. A model whose
output bounds are unknown (known_limits) is sent no output
limit, as a turn is not, so its server’s default holds.
Sourcepub fn max_tokens(&self, spec: &ModelSpec) -> u64
pub fn max_tokens(&self, spec: &ModelSpec) -> u64
The longest summary asked of spec: the limit’s, or the model’s
output limit when that is lower.
Sourcepub fn instruction(&self, focus: &str, tokens: u64) -> String
pub fn instruction(&self, focus: &str, tokens: u64) -> String
The message that asks for a summary at the end of the conversation
itself, the agent’s own request with its system prompt and tools cut
before the first message kept, so the provider can read all of it
from its prompt cache: SummaryPrompts::in_place, focus when it
is not empty, the format, and the output limit of tokens the
request asks for.
Sourcepub fn notes_instruction(&self, tokens: u64) -> String
pub fn notes_instruction(&self, tokens: u64) -> String
The message that asks, in place, for notes on the tool outputs about
to be cleared (SummaryPrompts::notes), with the output limit of
tokens the request asks for.
Sourcepub fn summary_text(
response: &CompletionResponse,
) -> Result<String, SummaryError>
pub fn summary_text( response: &CompletionResponse, ) -> Result<String, SummaryError>
The summary in a finished answer, or why it cannot be used.
Trait Implementations§
Source§impl Clone for Summarizer
impl Clone for Summarizer
Source§impl Debug for Summarizer
impl Debug for Summarizer
Source§impl Default for Summarizer
impl Default for Summarizer
Source§impl<'de> Deserialize<'de> for Summarizerwhere
Summarizer: Default,
impl<'de> Deserialize<'de> for Summarizerwhere
Summarizer: Default,
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>,
impl Eq for Summarizer
Source§impl PartialEq for Summarizer
impl PartialEq for Summarizer
Source§impl Serialize for Summarizer
impl Serialize for Summarizer
impl StructuralPartialEq for Summarizer
Auto Trait Implementations§
impl Freeze for Summarizer
impl RefUnwindSafe for Summarizer
impl Send for Summarizer
impl Sync for Summarizer
impl Unpin for Summarizer
impl UnsafeUnpin for Summarizer
impl UnwindSafe for Summarizer
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.