Revert model upgrade adapting#1365
Conversation
PR Summary by QodoRevert model upgrade mapping and use explicit model names Description
Diagram
High-Level Assessment
Files changed (18)
|
Code Review by Qodo
1. gpt-4o setting missing
|
| { | ||
| Provider = "openai", | ||
| Model = settingService.GetUpgradeModel(Gpt4xModelConstants.GPT_4o), | ||
| Model = Gpt4xModelConstants.GPT_4o, |
There was a problem hiding this comment.
1. Gpt-4o setting missing 🐞 Bug ☼ Reliability
Code paths now pass Gpt4xModelConstants.GPT_4o ("gpt-4o") directly, but the repo's OpenAI
LlmProviders models do not define a model with Name == "gpt-4o". When OpenAI
ProviderHelper.GetClient is invoked, GetSetting returns null and settings!.ApiKey can throw a
NullReferenceException at runtime.
Agent Prompt
### Issue description
Several call sites now hardcode the model name `gpt-4o` (via `Gpt4xModelConstants.GPT_4o`). In the repo’s default configuration, OpenAI models are configured with names like `gpt-4o-2024-11-20` and `gpt-4o-mini`, so `ILlmProviderService.GetSetting("openai", "gpt-4o")` returns `null` and OpenAI client creation can crash.
### Issue Context
- `LlmProviderService.GetSetting` resolves by **model Name** (not Id).
- `BotSharp.Plugin.OpenAI` uses `ProviderHelper.GetClient(...)` which dereferences `settings!.ApiKey`.
### Fix Focus Areas
- src/Plugins/BotSharp.Plugin.SqlDriver/Functions/SqlValidateFn.cs[63-76]
- src/Plugins/BotSharp.Plugin.SqlDriver/Services/DbKnowledgeService.cs[22-33]
- src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Instruct.cs[95-103]
**Suggested remediation options (pick one):**
1. **Config fix:** Add an OpenAI model entry with `Name: "gpt-4o"` under `LlmProviders` (and any other environments, e.g. tests), so `GetSetting` succeeds.
2. **Code fix:** Stop passing `gpt-4o` directly; instead, select a configured model name (e.g., `gpt-4o-2024-11-20`) or resolve via `ILlmProviderService` (e.g., choose a model by Id/group/capability and use `.Name`).
3. **Hardening (recommended regardless):** Add explicit null checks in OpenAI client creation paths so a missing model setting fails with a clear exception instead of a NullReferenceException.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| _botsharpOptions = botsharpOptions; | ||
|
|
||
| var settingService = _services.GetRequiredService<ISettingService>(); | ||
| _model = settingService.GetUpgradeModel(_model); |
There was a problem hiding this comment.
2. Realtime model not configured 🐞 Bug ☼ Reliability
The OpenAI realtime provider no longer upgrades the model name, so the repo default
RealtimeModel.Model ("gpt-realtime") is used as-is. RealTimeCompletionProvider.BuildHeaders
calls GetSetting(Provider, _model) and dereferences settings.ApiKey without a null check, which
will throw if "gpt-realtime" is not present in LlmProviders.
Agent Prompt
### Issue description
After removing `GetUpgradeModel`, realtime connections may now use `RealtimeModel.Model = "gpt-realtime"` directly. The OpenAI realtime provider requires a corresponding `LlmProviders` model setting (for ApiKey resolution), but the repo’s OpenAI models list does not include `Name: "gpt-realtime"`, causing `BuildHeaders()` to throw.
### Issue Context
- `src/WebStarter/appsettings.json` sets `RealtimeModel.Model` to `gpt-realtime`.
- `LlmProviders` for OpenAI does not define a model named `gpt-realtime` (but does define a realtime model like `gpt-4o-mini-realtime-preview-2024-12-17`).
- `BuildHeaders()` assumes `GetSetting(...)` is non-null.
### Fix Focus Areas
- src/Plugins/BotSharp.Plugin.OpenAI/Providers/Realtime/RealTimeCompletionProvider.cs[728-738]
- src/WebStarter/appsettings.json[1002-1014]
- src/WebStarter/appsettings.json[154-215]
**Suggested remediation (do both):**
1. **Config:** Change `RealtimeModel.Model` to a model name that exists under `LlmProviders` (e.g., `gpt-4o-mini-realtime-preview-2024-12-17` as currently configured).
2. **Code hardening:** Update `BuildHeaders()` to handle `settings == null` (throw a clear `InvalidOperationException` like `Can't find model settings for openai.<model>`), instead of a NullReferenceException.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
reviewed |
No description provided.