Class SemanticRetrieverModel
- Namespace
- GenerativeAI
- Assembly
- GenerativeAI.dll
Represents a semantic retriever model used for working with documents, corpora, chunks, and corpus permissions. This model requires a platform adapter with authentication for initialization.
public class SemanticRetrieverModel : BaseModel
- Inheritance
-
SemanticRetrieverModel
- Inherited Members
- Extension Methods
Constructors
SemanticRetrieverModel(IPlatformAdapter, string, ICollection<SafetySetting>?, HttpClient?, ILogger?)
Initializes a new instance of the SemanticRetrieverModel class.
public SemanticRetrieverModel(IPlatformAdapter platform, string modelName, ICollection<SafetySetting>? safetySettings = null, HttpClient? httpClient = null, ILogger? logger = null)
Parameters
platformIPlatformAdapterThe platform adapter providing necessary infrastructure, including authentication.
modelNamestringThe name of the semantic retriever model.
safetySettingsICollection<SafetySetting>Optional collection of safety settings to apply to the model.
httpClientHttpClientThe optional HTTP client for making requests.
loggerILoggerThe optional logger for logging events and debugging information.
Exceptions
- GenerativeAIException
Thrown when the platform authenticator is not provided.
SemanticRetrieverModel(string, string, IGoogleAuthenticator, HttpClient?, ICollection<SafetySetting>?, ILogger?)
Represents a semantic retriever model designed to interact with a platform to fetch and process semantic data.
public SemanticRetrieverModel(string modelName, string apiKey, IGoogleAuthenticator authenticator, HttpClient? httpClient = null, ICollection<SafetySetting>? safetySettings = null, ILogger? logger = null)
Parameters
modelNamestringapiKeystringauthenticatorIGoogleAuthenticatorhttpClientHttpClientsafetySettingsICollection<SafetySetting>loggerILogger
Properties
CorporaManager
Gets or sets the corpora manager, which provides operations for managing corpora, documents, chunks, and corpus permissions.
public CorporaManager CorporaManager { get; set; }
Property Value
ModelName
Gets or sets the name of the model.
public string ModelName { get; set; }
Property Value
SafetySettings
Gets or sets the list of safety settings that define harm categories and thresholds to control the content moderation for model interactions.
public List<SafetySetting>? SafetySettings { get; set; }
Property Value
Methods
CreateChatSession(string, AnswerStyle, List<Content>?, List<SafetySetting>?)
Creates a new chat session for semantic retrieval.
public SemanticRetrieverChatSession CreateChatSession(string corpusName, AnswerStyle answerStyle = AnswerStyle.VERBOSE, List<Content>? history = null, List<SafetySetting>? safetySettings = null)
Parameters
corpusNamestringThe name of the corpus to query.
answerStyleAnswerStyleThe style of answers to generate.
historyList<Content>Optional conversation history.
safetySettingsList<SafetySetting>Optional safety settings for the session.
Returns
- SemanticRetrieverChatSession
A new SemanticRetrieverChatSession instance.
GenerateAnswerAsync(GenerateAnswerRequest, CancellationToken)
Generates an answer asynchronously based on the provided request.
public Task<GenerateAnswerResponse> GenerateAnswerAsync(GenerateAnswerRequest request, CancellationToken cancellationToken = default)
Parameters
requestGenerateAnswerRequestThe request containing the input details for generating an answer.
cancellationTokenCancellationTokenA cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
- Task<GenerateAnswerResponse>
Returns a GenerateAnswerResponse containing the generated answer and additional context.
- See Also
GenerateAnswerAsync(string, string, AnswerStyle, ICollection<SafetySetting>?, CancellationToken)
Generates an answer asynchronously based on the given prompt and specified parameters.
public Task<GenerateAnswerResponse> GenerateAnswerAsync(string prompt, string corpusId, AnswerStyle answerStyle = AnswerStyle.ABSTRACTIVE, ICollection<SafetySetting>? safetySettings = null, CancellationToken cancellationToken = default)
Parameters
promptstringThe text input that serves as the basis for generating a response.
corpusIdstringThe ID of the corpus to use as the grounding source for generating the answer.
answerStyleAnswerStyleAn optional parameter indicating the stylistic approach to be used when generating the answer.
safetySettingsICollection<SafetySetting>An optional collection of rules or configurations applied to ensure safety during the answer generation process.
cancellationTokenCancellationTokenA token to monitor for cancellation requests during the asynchronous operation.
Returns
- Task<GenerateAnswerResponse>
Returns a GenerateAnswerResponse object containing the generated response and associated metadata.
- See Also