minor change
This commit is contained in:
parent
5a166e7e21
commit
3d6607622e
|
|
@ -51,11 +51,8 @@ public class GeminiTextCompletionProvider : ITextCompletion
|
|||
var aiModel = client.CreateGenerativeModel(_model);
|
||||
PrepareOptions(aiModel);
|
||||
|
||||
_tokenStatistics.StartTimer();
|
||||
var response = await aiModel.GenerateContentAsync(text);
|
||||
_tokenStatistics.StopTimer();
|
||||
|
||||
var completion = response.Text ?? string.Empty;
|
||||
var completion = response?.Text ?? string.Empty;
|
||||
|
||||
// After completion hook
|
||||
foreach (var hook in contentHooks)
|
||||
|
|
@ -64,7 +61,10 @@ public class GeminiTextCompletionProvider : ITextCompletion
|
|||
{
|
||||
Prompt = text,
|
||||
Provider = Provider,
|
||||
Model = _model
|
||||
Model = _model,
|
||||
PromptCount = response.UsageMetadata?.PromptTokenCount ?? 0,
|
||||
CachedPromptCount = response.UsageMetadata?.CachedContentTokenCount ?? 0,
|
||||
CompletionCount = response.UsageMetadata?.CandidatesTokenCount ?? 0
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -79,6 +79,7 @@ public class GeminiTextCompletionProvider : ITextCompletion
|
|||
private void PrepareOptions(GenerativeModel aiModel)
|
||||
{
|
||||
var settings = _services.GetRequiredService<GoogleAiSettings>();
|
||||
|
||||
aiModel.UseGoogleSearch = settings.Gemini.UseGoogleSearch;
|
||||
aiModel.UseGrounding = settings.Gemini.UseGrounding;
|
||||
aiModel.FunctionCallingBehaviour = new FunctionCallingBehaviour()
|
||||
|
|
|
|||
Loading…
Reference in a new issue