From f60cfef8a14b1206fecf65b4a9f779bef5633c57 Mon Sep 17 00:00:00 2001 From: Alex Castillo Date: Tue, 20 Oct 2026 09:29:05 -0400 Subject: [PATCH] Replace the retired gemini-2.0-flash PDF reading default ReadPdfFn falls back to google-ai / gemini-2.0-flash when FileHandler:Pdf:Reading has no provider and model, and the sample appsettings.json configures the same model for PDF reading. Google shut gemini-2.0-flash down on 2026-06-01, so reading a PDF with the default settings returns an error from the Gemini API. Use gemini-3.8-flash, the current stable Flash model, in the fallback and in appsettings.json (the chat model entry and the FileHandler setting), with its standard paid-tier prices per 1K tokens. The Google provider sends a temperature (0.0 by default) that Gemini 3 accepts but recommends leaving at its default. Co-Authored-By: Claude Sonnet 5.5 --- .../Functions/ReadPdfFn.cs | 2 +- src/WebStarter/appsettings.json | 10 +++---- .../BotSharp.Core.UnitTests.csproj | 2 ++ .../Plugins/ReadPdfFnDefaultModelTests.cs | 26 +++++++++++++++++++ 4 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 tests/BotSharp.Core.UnitTests/Plugins/ReadPdfFnDefaultModelTests.cs diff --git a/src/Plugins/BotSharp.Plugin.FileHandler/Functions/ReadPdfFn.cs b/src/Plugins/BotSharp.Plugin.FileHandler/Functions/ReadPdfFn.cs index 198ed4e89..6a2557d48 100644 --- a/src/Plugins/BotSharp.Plugin.FileHandler/Functions/ReadPdfFn.cs +++ b/src/Plugins/BotSharp.Plugin.FileHandler/Functions/ReadPdfFn.cs @@ -146,7 +146,7 @@ private async Task GetChatCompletion(Agent agent, List } provider = "google-ai"; - model = "gemini-2.0-flash"; + model = "gemini-3.8-flash"; return (provider, model); } diff --git a/src/WebStarter/appsettings.json b/src/WebStarter/appsettings.json index 3e4bf12c9..d9a55c51c 100644 --- a/src/WebStarter/appsettings.json +++ b/src/WebStarter/appsettings.json @@ -1119,7 +1119,7 @@ "Provider": "google-ai", "Models": [ { - "Name": "gemini-2.0-flash", + "Name": "gemini-3.8-flash", "ApiKey": "", "Type": "chat", "MultiModal": true, @@ -1129,11 +1129,11 @@ "PdfReading" ], "Cost": { - "TextInputCost": 0.0015, - "CachedTextInputCost": 0, + "TextInputCost": 0.00075, + "CachedTextInputCost": 0.000075, "AudioInputCost": 0, "CachedAudioInputCost": 0, - "TextOutputCost": 0.002, + "TextOutputCost": 0.00375, "AudioOutputCost": 0 } }, @@ -1368,7 +1368,7 @@ "Pdf": { "Reading": { "Provider": "google-ai", - "Model": "gemini-2.0-flash", + "Model": "gemini-3.8-flash", "ConvertToImage": false, "ImageDetailLevel": "auto", "ImageConverter": { diff --git a/tests/BotSharp.Core.UnitTests/BotSharp.Core.UnitTests.csproj b/tests/BotSharp.Core.UnitTests/BotSharp.Core.UnitTests.csproj index 252d113e1..2e1475e43 100644 --- a/tests/BotSharp.Core.UnitTests/BotSharp.Core.UnitTests.csproj +++ b/tests/BotSharp.Core.UnitTests/BotSharp.Core.UnitTests.csproj @@ -44,6 +44,8 @@ + + diff --git a/tests/BotSharp.Core.UnitTests/Plugins/ReadPdfFnDefaultModelTests.cs b/tests/BotSharp.Core.UnitTests/Plugins/ReadPdfFnDefaultModelTests.cs new file mode 100644 index 000000000..968a414a3 --- /dev/null +++ b/tests/BotSharp.Core.UnitTests/Plugins/ReadPdfFnDefaultModelTests.cs @@ -0,0 +1,26 @@ +using System.Reflection; +using BotSharp.Plugin.FileHandler.Functions; +using BotSharp.Plugin.FileHandler.Settings; +using Microsoft.Extensions.Logging.Abstractions; +using Xunit; + +namespace BotSharp.Core.UnitTests.Plugins; + +public class ReadPdfFnDefaultModelTests +{ + // Google shut down gemini-2.0-flash on 2026-06-01, so the model that ReadPdfFn + // falls back to when no FileHandler:Pdf:Reading provider and model are set + // must be one the Gemini API still serves. + [Fact] + public void Falls_back_to_a_gemini_model_that_is_still_served() + { + var fn = new ReadPdfFn(null!, NullLogger.Instance, new FileHandlerSettings()); + + var (provider, model) = ((string, string))typeof(ReadPdfFn) + .GetMethod("GetLlmProviderModel", BindingFlags.NonPublic | BindingFlags.Instance)! + .Invoke(fn, null)!; + + Assert.Equal("google-ai", provider); + Assert.Equal("gemini-3.8-flash", model); + } +}