toGeminiSettings function

  1. @visibleForTesting
GenerationConfig toGeminiSettings(
  1. GeminiOptions options,
  2. Map<String, dynamic>? outputSchema,
  3. bool isJsonMode
)

Implementation

@visibleForTesting
gcl.GenerationConfig toGeminiSettings(
  GeminiOptions options,
  Map<String, dynamic>? outputSchema,
  bool isJsonMode,
) {
  return gcl.GenerationConfig(
    candidateCount: options.candidateCount,
    stopSequences: options.stopSequences?.isEmpty ?? true
        ? null
        : options.stopSequences,
    maxOutputTokens: options.maxOutputTokens,
    temperature: options.temperature,
    topP: options.topP,
    topK: options.topK,
    responseMimeType: isJsonMode
        ? 'application/json'
        : (options.responseMimeType ?? ''),
    responseJsonSchema: outputSchema,
    presencePenalty: options.presencePenalty,
    frequencyPenalty: options.frequencyPenalty,
    responseLogprobs: options.responseLogprobs,
    logprobs: options.logprobs,
    responseModalities: options.responseModalities?.isEmpty ?? true
        ? null
        : options.responseModalities!.map((m) => m.toUpperCase()).toList(),
    speechConfig: options.speechConfig != null
        ? gcl.SpeechConfig.fromJson(_toSpeechConfig(options.speechConfig)!)
        : null,
    thinkingConfig: options.thinkingConfig != null
        ? gcl.ThinkingConfig.fromJson(
            _toThinkingConfig(options.thinkingConfig)!,
          )
        : null,
  );
}