Skip to content

Conversation

hchen2020
Copy link
Contributor

@hchen2020 hchen2020 commented Oct 9, 2025

PR Type

Enhancement


Description

  • Skip file selection when only one image exists

  • Update default model from gpt-image-1 to gpt-image-1-mini

  • Change LLM model from gpt-4o-mini to gpt-5-mini

  • Fix template name typo in file selection


Diagram Walkthrough

flowchart LR
  A["File Selection"] --> B{"Single Image?"}
  B -->|Yes| C["Skip Selection"]
  B -->|No| D["Run Selection Logic"]
  E["Model Updates"] --> F["gpt-image-1-mini"]
  E --> G["gpt-5-mini"]
Loading

File Walkthrough

Relevant files
Configuration changes
FileInstructService.Image.cs
Update image processing model defaults                                     

src/Infrastructure/BotSharp.Core/Files/Services/Instruct/FileInstructService.Image.cs

  • Updated default model from gpt-image-1 to gpt-image-1-mini in three
    image processing methods
  • Changed model parameter in GenerateImage, EditImage (single), and
    EditImage (with mask) methods
+3/-3     
CompletionProvider.cs
Update completion provider model default                                 

src/Infrastructure/BotSharp.Core/Infrastructures/CompletionProvider.cs

  • Updated default model fallback from gpt-image-1 to gpt-image-1-mini
+1/-1     
EditImageFn.cs
Update edit image function models                                               

src/Plugins/BotSharp.Plugin.FileHandler/Functions/EditImageFn.cs

  • Changed LLM model from gpt-4o-mini to gpt-5-mini in agent
    configuration
  • Updated default model from gpt-image-1 to gpt-image-1-mini in provider
    settings
+2/-2     
GenerateImageFn.cs
Update generate image function models                                       

src/Plugins/BotSharp.Plugin.FileHandler/Functions/GenerateImageFn.cs

  • Changed LLM model from gpt-4o-mini to gpt-5-mini in agent
    configuration
  • Updated default model from gpt-image-1 to gpt-image-1-mini in provider
    settings
+2/-2     
Enhancement
FileInstructService.SelectFile.cs
Skip selection for single files                                                   

src/Infrastructure/BotSharp.Core/Files/Services/Instruct/FileInstructService.SelectFile.cs

  • Added early return when only one file exists to skip selection process
  • Fixed template name typo from select_chat_file_instruction to
    select-chat-file_instruction
+5/-1     
AiResponseHelper.cs
Improve response helper text and model                                     

src/Plugins/BotSharp.Plugin.FileHandler/Helpers/AiResponseHelper.cs

  • Modified response text to be more user-friendly and shorter
  • Changed default model from gpt-4o-mini to gpt-5-mini
+3/-3     

Copy link

qodo-merge-pro bot commented Oct 9, 2025

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
No custom compliance provided

Follow the guide to enable custom compliance check.

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

Copy link

qodo-merge-pro bot commented Oct 9, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix incorrect state key for model

In EditImageFn.cs, correct the state key used to retrieve the LLM model. The key
"image_edit_llm_provider" is mistakenly used instead of "image_edit_llm_model".

src/Plugins/BotSharp.Plugin.FileHandler/Functions/EditImageFn.cs [155]

-var model = state.GetState("image_edit_llm_provider");
+var model = state.GetState("image_edit_llm_model");

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 8

__

Why: This suggestion correctly identifies a copy-paste bug where the model variable is being assigned using the state key for the provider. This would lead to incorrect behavior by using the provider's name as the model name.

Medium
High-level
Centralize default model name configuration

Replace hardcoded default model names like "gpt-image-1-mini" and "gpt-5-mini"
with constants defined in a central configuration class. This improves
maintainability by enabling future model updates in a single location.

Examples:

src/Plugins/BotSharp.Plugin.FileHandler/Functions/EditImageFn.cs [140]
                Model = llmConfig?.Model ?? "gpt-5-mini",
src/Infrastructure/BotSharp.Core/Files/Services/Instruct/FileInstructService.Image.cs [52]
        var completion = CompletionProvider.GetImageCompletion(_services, provider: options?.Provider ?? "openai", model: options?.Model ?? "gpt-image-1-mini");

Solution Walkthrough:

Before:

// In EditImageFn.cs
var agent = new Agent
{
    LlmConfig = new AgentLlmConfig
    {
        Model = llmConfig?.Model ?? "gpt-5-mini",
        //...
    }
};

// In GenerateImageFn.cs
private (string, string) GetLlmProviderModel()
{
    //...
    model = "gpt-image-1-mini";
    return (provider, model);
}

After:

// In a new central file, e.g., ModelConstants.cs
public static class ModelConstants
{
    public const string DefaultImageGenerationModel = "gpt-image-1-mini";
    public const string DefaultChatModel = "gpt-5-mini";
}

// In EditImageFn.cs
var agent = new Agent
{
    LlmConfig = new AgentLlmConfig
    {
        Model = llmConfig?.Model ?? ModelConstants.DefaultChatModel,
        //...
    }
};

// In GenerateImageFn.cs
private (string, string) GetLlmProviderModel()
{
    //...
    model = ModelConstants.DefaultImageGenerationModel;
    return (provider, model);
}
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies the maintainability issue of hardcoded model names across multiple files and proposes a valid solution to centralize them, which would simplify future updates.

Medium
Learned
best practice
Add null-safe defaults

Guard against a null _agent or _agent.LlmConfig by using null-coalescing
defaults to prevent potential NullReferenceExceptions.

src/Plugins/BotSharp.Plugin.FileHandler/Functions/EditImageFn.cs [132-144]

-var llmConfig = _agent.LlmConfig;
+var llmConfig = _agent?.LlmConfig;
 var agent = new Agent
 {
     Id = _agent?.Id ?? BuiltInAgentId.UtilityAssistant,
     Name = _agent?.Name ?? "Utility Assistant",
     LlmConfig = new AgentLlmConfig
     {
         Provider = llmConfig?.Provider ?? "openai",
         Model = llmConfig?.Model ?? "gpt-5-mini",
-        MaxOutputTokens = llmConfig?.MaxOutputTokens,
-        ReasoningEffortLevel = llmConfig?.ReasoningEffortLevel
+        MaxOutputTokens = llmConfig?.MaxOutputTokens ?? 0,
+        ReasoningEffortLevel = llmConfig?.ReasoningEffortLevel ?? default
     }
 };

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 6

__

Why:
Relevant best practice - Ensure null-safety on optional inputs and object properties, returning safe defaults to avoid null reference issues.

Low
Make agent config null-safe

Use null-conditional and null-coalescing operators for _agent and its LlmConfig
to avoid dereferencing null.

src/Plugins/BotSharp.Plugin.FileHandler/Functions/GenerateImageFn.cs [96-108]

-var llmConfig = _agent.LlmConfig;
+var llmConfig = _agent?.LlmConfig;
 var agent = new Agent
 {
     Id = _agent?.Id ?? BuiltInAgentId.UtilityAssistant,
     Name = _agent?.Name ?? "Utility Assistant",
     LlmConfig = new AgentLlmConfig
     {
         Provider = llmConfig?.Provider ?? "openai",
         Model = llmConfig?.Model ?? "gpt-5-mini",
-        MaxOutputTokens = llmConfig?.MaxOutputTokens,
-        ReasoningEffortLevel = llmConfig?.ReasoningEffortLevel
+        MaxOutputTokens = llmConfig?.MaxOutputTokens ?? 0,
+        ReasoningEffortLevel = llmConfig?.ReasoningEffortLevel ?? default
     }
 };

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 5

__

Why:
Relevant best practice - Ensure null-safety on optional inputs and object properties, returning safe defaults to avoid null reference issues.

Low
  • More

@Oceania2018 Oceania2018 merged commit 5a6a93c into SciSharp:master Oct 10, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants