pub struct TextSearchProvider { /* private fields */ }Expand description
A ContextProvider that adds text-search results to a run. See the
module docs.
Cloning yields a handle onto the same provider.
Implementations§
Source§impl TextSearchProvider
impl TextSearchProvider
Sourcepub fn new<F, Fut>(search: F) -> TextSearchProvider
pub fn new<F, Fut>(search: F) -> TextSearchProvider
A provider searching with search, which takes the query text.
Sourcepub fn with_behavior(self, behavior: TextSearchBehavior) -> TextSearchProvider
pub fn with_behavior(self, behavior: TextSearchBehavior) -> TextSearchProvider
When to search (default TextSearchBehavior::BeforeInvoke).
Sourcepub fn with_tool(
self,
name: impl Into<String>,
description: impl Into<String>,
) -> TextSearchProvider
pub fn with_tool( self, name: impl Into<String>, description: impl Into<String>, ) -> TextSearchProvider
The on-demand tool’s name and description (default Search).
Sourcepub fn with_context_prompt(
self,
prompt: impl Into<String>,
) -> TextSearchProvider
pub fn with_context_prompt( self, prompt: impl Into<String>, ) -> TextSearchProvider
The line put before the results.
Sourcepub fn with_citations_prompt(
self,
prompt: impl Into<String>,
) -> TextSearchProvider
pub fn with_citations_prompt( self, prompt: impl Into<String>, ) -> TextSearchProvider
The line put after the results, asking for citations.
Sourcepub fn with_context_formatter(
self,
formatter: impl Fn(&[TextSearchResult]) -> Result<String, Error> + Send + Sync + 'static,
) -> TextSearchProvider
pub fn with_context_formatter( self, formatter: impl Fn(&[TextSearchResult]) -> Result<String, Error> + Send + Sync + 'static, ) -> TextSearchProvider
Format results yourself instead of the default layout. Called for every search, including one with no results.
Sourcepub fn with_recent_message_memory(self, limit: usize) -> TextSearchProvider
pub fn with_recent_message_memory(self, limit: usize) -> TextSearchProvider
Include up to limit recent conversation messages in the search
input (default 0, off). Only messages with a role in
Self::with_recent_message_roles (default user) are kept. The
memory lives in the session state under Self::with_state_key, so a
run without a session has none.
Sourcepub fn with_recent_message_roles(self, roles: Vec<Role>) -> TextSearchProvider
pub fn with_recent_message_roles(self, roles: Vec<Role>) -> TextSearchProvider
The roles recent-message memory keeps (default user only).
Sourcepub fn with_state_key(
self,
key: impl Into<String>,
) -> Result<TextSearchProvider, Error>
pub fn with_state_key( self, key: impl Into<String>, ) -> Result<TextSearchProvider, Error>
The session-state key for recent-message memory (default
DEFAULT_TEXT_SEARCH_STATE_KEY). A blank key is refused.
Sourcepub fn with_sensitive_logging(self, enabled: bool) -> TextSearchProvider
pub fn with_sensitive_logging(self, enabled: bool) -> TextSearchProvider
Log queries and formatted results at trace level. Off by default:
both carry conversation content.
Sourcepub fn search_tool(&self) -> ToolDefinition
pub fn search_tool(&self) -> ToolDefinition
The on-demand search tool. Added to every run under
TextSearchBehavior::OnDemandFunctionCalling; it takes one string
argument, userQuestion.
Trait Implementations§
Source§impl Clone for TextSearchProvider
impl Clone for TextSearchProvider
Source§fn clone(&self) -> TextSearchProvider
fn clone(&self) -> TextSearchProvider
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ContextProvider for TextSearchProvider
impl ContextProvider for TextSearchProvider
Source§fn after_run<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
request_messages: &'life1 [Message],
response_messages: &'life2 [Message],
error: Option<&'life3 Error>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
TextSearchProvider: 'async_trait,
fn after_run<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
request_messages: &'life1 [Message],
response_messages: &'life2 [Message],
error: Option<&'life3 Error>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
TextSearchProvider: 'async_trait,
Records the run’s messages in recent-message memory. after_run
receives no session, so the run is matched by its input to the state
handle before_run recorded (as the harness mode provider does). A
failed run records nothing, and neither does a run whose input
matches in-flight runs of more than one session, since it cannot be
told apart from them.
Source§fn before_run<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 mut SessionContext,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
TextSearchProvider: 'async_trait,
fn before_run<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 mut SessionContext,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
TextSearchProvider: 'async_trait,
Source§fn is_history_provider(&self) -> bool
fn is_history_provider(&self) -> bool
HistoryProvider). Agent
and WorkflowAgent use this to
detect an already-attached history provider among a session’s
context_providers and avoid auto-attaching a redundant
InMemoryHistoryProvider.
Defaults to false; history providers override it to true.