// Copyright (c) Microsoft. All rights reserved.
using System;
using System.Collections.Generic;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.Compliance.Redaction;
namespace Microsoft.Agents.AI;
///
/// Options controlling the behavior of .
///
public sealed class TextSearchProviderOptions
{
///
/// Gets or sets a value indicating when the search should be executed.
///
/// by default.
public TextSearchBehavior SearchTime { get; set; } = TextSearchBehavior.BeforeAIInvoke;
///
/// Gets or sets the name of the exposed search tool when operating in on-demand mode.
///
/// Defaults to "Search".
public string? FunctionToolName { get; set; }
///
/// Gets or sets the description of the exposed search tool when operating in on-demand mode.
///
/// Defaults to "Allows searching for additional information to help answer the user question.".
public string? FunctionToolDescription { get; set; }
///
/// Gets or sets the context prompt prefixed to results.
///
public string? ContextPrompt { get; set; }
///
/// Gets or sets the instruction appended after results to request citations.
///
public string? CitationsPrompt { get; set; }
///
/// Optional delegate to fully customize formatting of the result list.
///
///
/// If provided, and are ignored.
///
public Func, string>? ContextFormatter { get; set; }
///
/// Gets or sets the number of recent conversation messages (both user and assistant) to keep in memory
/// and include when constructing the search input for searches.
///
///
/// The maximum number of most recent messages to retain. A value of 0 (default) disables memory and
/// only the current request's messages are used for search input. The value is a count of individual
/// messages, not turns. Only messages with role or
/// are retained.
///
public int RecentMessageMemoryLimit { get; set; }
///
/// Gets or sets the key used to store provider state in the .
///
///
/// Defaults to the provider's type name. Override this if you need multiple
/// instances with separate state in the same session.
///
public string? StateKey { get; set; }
///
/// Gets or sets an optional filter function applied to request messages when constructing the search input
/// text during .
///
///
/// When , the provider defaults to including only
/// messages.
///
public Func, IEnumerable>? SearchInputMessageFilter { get; set; }
///
/// Gets or sets an optional filter function applied to request messages when updating the recent message
/// memory during .
///
///
/// When , the provider defaults to including only
/// messages.
///
public Func, IEnumerable>? StorageInputRequestMessageFilter { get; set; }
///
/// Gets or sets an optional filter function applied to response messages when updating the recent message
/// memory during .
///
///
/// When , the provider defaults to including all messages.
///
public Func, IEnumerable>? StorageInputResponseMessageFilter { get; set; }
///
/// Gets or sets the list of types to filter recent messages to
/// when deciding which recent messages to include when constructing the search input.
///
///
///
/// Depending on your scenario, you may want to use only user messages, only assistant messages,
/// or both. For example, if the assistant may often provide clarifying questions or if the conversation
/// is expected to be particularly chatty, you may want to include assistant messages in the search context as well.
///
///
/// Be careful when including assistant messages though, as they may skew the search results towards
/// information that has already been provided by the assistant, rather than focusing on the user's current needs.
///
///
///
/// When not specified, defaults to only .
///
public List? RecentMessageRolesIncluded { get; set; }
///
/// Gets or sets a value indicating whether sensitive data such as user queries and search results may appear in logs.
///
/// Defaults to .
///
/// When set to , sensitive data is passed through to logs unchanged and any
/// configured is ignored. This property takes precedence over .
///
public bool EnableSensitiveTelemetryData { get; set; }
///
/// Gets or sets a custom used to redact sensitive data in log output.
///
///
/// When (the default), sensitive data is replaced with a placeholder.
/// When set, this redactor is used to transform sensitive values before they are logged.
/// Ignored when is .
///
public Redactor? Redactor { get; set; }
///
/// Behavior choices for the provider.
///
public enum TextSearchBehavior
{
///
/// Execute search prior to each invocation and inject results as a message.
///
BeforeAIInvoke,
///
/// Expose a function tool to perform search on-demand via function/tool calling.
///
OnDemandFunctionCalling
}
}