Table of Contents

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

platform IPlatformAdapter

The platform adapter providing necessary infrastructure, including authentication.

modelName string

The name of the semantic retriever model.

safetySettings ICollection<SafetySetting>

Optional collection of safety settings to apply to the model.

httpClient HttpClient

The optional HTTP client for making requests.

logger ILogger

The 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

modelName string
apiKey string
authenticator IGoogleAuthenticator
httpClient HttpClient
safetySettings ICollection<SafetySetting>
logger ILogger

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

CorporaManager

ModelName

Gets or sets the name of the model.

public string ModelName { get; set; }

Property Value

string

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

List<SafetySetting>

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

corpusName string

The name of the corpus to query.

answerStyle AnswerStyle

The style of answers to generate.

history List<Content>

Optional conversation history.

safetySettings List<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

request GenerateAnswerRequest

The request containing the input details for generating an answer.

cancellationToken CancellationToken

A 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

prompt string

The text input that serves as the basis for generating a response.

corpusId string

The ID of the corpus to use as the grounding source for generating the answer.

answerStyle AnswerStyle

An optional parameter indicating the stylistic approach to be used when generating the answer.

safetySettings ICollection<SafetySetting>

An optional collection of rules or configurations applied to ensure safety during the answer generation process.

cancellationToken CancellationToken

A 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