Skip to content

Switch AI backend from OpenAI GPT-3.5 to Google Gemini#6

Open
Copilot wants to merge 2 commits into
masterfrom
copilot/update-to-gemini-ai-model
Open

Switch AI backend from OpenAI GPT-3.5 to Google Gemini#6
Copilot wants to merge 2 commits into
masterfrom
copilot/update-to-gemini-ai-model

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 4, 2026

Replaces the OpenAI GPT-3.5 Turbo integration with Google's Gemini API (gemini-2.0-flash) using the official Google.GenAI SDK.

Changes

  • TalkGPT.csproj: Swap Betalgo.OpenAI.GPT3Google.GenAI v1.2.0
  • talkgptsettings.json: Rename config key OpenAI_APIKEYGemini_APIKEY
  • Program.cs:
    • Replace OpenAI imports and OpenAIService with Google.GenAI.Client
    • Instantiate Client once outside the recognition loop (was re-created per request)
    • Add fallback console message when Gemini returns no candidates
var geminiClient = new Client(apiKey: Gemini_APIKey);
// ...
var response = await geminiClient.Models.GenerateContentAsync(
    model: "gemini-2.0-flash",
    contents: text
);
if (response?.Candidates?.Count > 0)
{
    geminiResult = response.Candidates[0].Content?.Parts?[0]?.Text ?? "";
    // speak geminiResult ...
}
else
{
    Console.WriteLine("\nTalkGPT = (No response received from Gemini)");
}

Note: The Gemini_APIKEY value in talkgptsettings.json must be replaced with a valid key from Google AI Studio before use.

Original prompt

This section details on the original issue you should resolve

<issue_title>我要把AI 模型改為GEMINI 的AI模型</issue_title>
<issue_description>我要把AI 模型改為GEMINI 的AI模型
KEY = 123123123</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

@superlevin superlevin marked this pull request as ready for review March 4, 2026 07:14
Copilot AI review requested due to automatic review settings March 4, 2026 07:14
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: superlevin <33922143+superlevin@users.noreply.github.com>
Copilot AI changed the title [WIP] Update AI model to Gemini model Switch AI backend from OpenAI GPT-3.5 to Google Gemini Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

我要把AI 模型改為GEMINI 的AI模型

3 participants