-
-
Couldn't load subscription status.
- Fork 582
Features/refine model settings #1145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Features/refine model settings #1145
Conversation
…atures/refine-model-settings
…atures/refine-model-settings
…atures/refine-model-settings
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||
…atures/refine-model-settings
…atures/refine-model-settings
…celjc/BotSharp into features/refine-model-settings
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||||||||||
PR Type
Enhancement, Bug fix
Description
• Major refactoring of file handling and AI provider configurations: Added comprehensive settings for file operations, image conversion, and LLM provider selection across multiple functions
• Enhanced multi-modal support: Added support for image content parts, annotations, and advanced features across Azure OpenAI, DeepSeek, OpenAI, and Google AI chat providers
• New image converter architecture: Introduced
IImageConverterinterface withFileHandlerImageConverterimplementation using SixLabors.ImageSharp for PNG conversion• Improved file selection system: Refactored from simple ID-based to message-based file selection with detailed context including message ID, file index, and source
• API endpoint restructuring: Updated instruct mode controller endpoints from
/uploadto/formwith specialized request models• Enhanced AI-powered responses: Added
AiResponseHelperfor generating contextual user feedback in file operations• Package updates: Updated Google GenerativeAI (2.5.8→3.2.0), Azure OpenAI (2.2.0-beta.5→2.3.0-beta.2), OpenAI (2.3.0→2.4.0), and SixLabors.ImageSharp (3.1.7→3.1.11)
• Configuration enhancements: Added comprehensive FileHandler and FileSelect settings with LLM configuration support
• Bug fixes: Improved error handling in chart plotting and removed deprecated additional message wrapper functionality
Diagram Walkthrough
File Walkthrough
32 files
InstructModeController.cs
Refactor API endpoints and add image conversion supportsrc/Infrastructure/BotSharp.OpenAPI/Controllers/InstructModeController.cs
• Updated API endpoint paths from
/uploadto/formfor multi-modaloperations
• Renamed parameter variables from
inputtorequestforconsistency
• Added
ImageConvertProviderproperty toInstructOptionsfor image processing operations
• Updated request types to use more
specific file request models
ChatCompletionProvider.cs
Enhance Azure OpenAI chat completion with advanced featuressrc/Plugins/BotSharp.Plugin.AzureOpenAI/Providers/Chat/ChatCompletionProvider.cs
• Added
#pragma warning disable OPENAI001to suppress OpenAI warnings• Enhanced chat completion with
ToolCallIdandAnnotationssupport•
Refactored message preparation with new helper methods for content
parts
• Added support for reasoning effort levels and web search
options
ChatCompletionProvider.cs
Add multi-modal and advanced features to DeepSeek chat providersrc/Plugins/BotSharp.Plugin.DeepSeekAI/Providers/Chat/ChatCompletionProvider.cs
• Added
#pragma warning disable OPENAI001and new imports for filehandling
• Enhanced chat completion with
Annotationssupport for webresources
• Added multi-modal support with image content parts
collection
• Implemented reasoning effort levels and web search
configuration
FileInstructService.SelectFile.cs
Enhance file selection service with improved filtering and AIselectionsrc/Infrastructure/BotSharp.Core/Files/Services/Instruct/FileInstructService.SelectFile.cs
• Refactored file selection logic to use routing context and message
limits
• Updated file selection criteria with new
FileSelectItemstructure
• Enhanced file attachment to dialog messages with proper
indexing
• Improved AI-based file selection with better prompt
handling
EditImageFn.cs
Enhance image editing function with conversion and AI responsessrc/Plugins/BotSharp.Plugin.FileHandler/Functions/EditImageFn.cs
• Added image conversion support with configurable providers
•
Enhanced error handling and response generation for image editing
•
Integrated conversation settings for file selection parameters
• Added
AI-powered response generation for better user feedback
ChatCompletionProvider.cs
Enhance OpenAI chat provider with annotations and multi-modalimprovementssrc/Plugins/BotSharp.Plugin.OpenAI/Providers/Chat/ChatCompletionProvider.cs
• Added support for chat annotations with web resource information
•
Refactored message content parts collection into reusable helper
method
• Added image detail level configuration support
• Enhanced
multi-modal message handling for both user and assistant roles
GenerateImageFn.cs
Enhance image generation with configurable providers and AI responsessrc/Plugins/BotSharp.Plugin.FileHandler/Functions/GenerateImageFn.cs
• Added configurable LLM provider and model selection for image
generation
• Enhanced response generation with AI-powered
user-friendly messages
• Improved image generation settings with
response format configuration
• Added better error handling and file
saving feedback
FileInstructService.Image.cs
Add image conversion support and improve image processingsrc/Infrastructure/BotSharp.Core/Files/Services/Instruct/FileInstructService.Image.cs
• Added image conversion support for image editing operations
•
Enhanced text content handling with fallback to instruction templates
• Updated default model from
dall-e-2togpt-image-1for consistency•
Improved file name building for mask operations
ReadImageFn.cs
Enhance image reading with configurable providers and improved filehandlingsrc/Plugins/BotSharp.Plugin.FileHandler/Functions/ReadImageFn.cs
• Added configurable LLM provider and model selection
• Enhanced file
collection to include both user and bot images
• Added image detail
level configuration support
• Improved agent configuration with proper
LLM settings
GeminiChatCompletionProvider.cs
Add multi-modal support to Google AI chat providersrc/Plugins/BotSharp.Plugin.GoogleAI/Providers/Chat/GeminiChatCompletionProvider.cs
• Added multi-modal support for assistant messages with file
attachments
• Refactored content parts collection into reusable helper
method
• Enhanced message handling to support both text and file
content
• Improved code organization with better separation of
concerns
ReadPdfFn.cs
Enhance PDF reading with configurable providers and settingssrc/Plugins/BotSharp.Plugin.FileHandler/Functions/ReadPdfFn.cs
• Added configurable LLM provider and model selection for PDF reading
• Enhanced agent configuration with proper LLM settings
• Added image
detail level configuration support
• Improved error handling and
provider selection logic
WebIntelligentSearchFn.cs
Add configurable LLM providers to web search functionsrc/Infrastructure/BotSharp.Core/WebSearch/Functions/WebIntelligentSearchFn.cs
• Added configurable LLM provider and model selection for web search
•
Enhanced model selection logic with web search capability detection
•
Improved provider configuration with fallback mechanisms
• Updated
agent name for consistency
InstructBaseRequest.cs
Add specialized request models with image conversion supportsrc/Infrastructure/BotSharp.OpenAPI/ViewModels/Instructs/Request/InstructBaseRequest.cs
• Added new request models for specific file operations
(ImageEditFileRequest, PdfReadFileRequest, etc.)
• Added
ImageConvertProviderproperty to image-related requests• Separated
file-based requests from base requests for better type safety
•
Enhanced request structure with more specific typing
LocalFileStorageService.Conversation.cs
Add file indexing and improve PDF conversion interfacesrc/Infrastructure/BotSharp.Core/Files/Services/Storage/LocalFileStorageService.Conversation.cs
• Added
FileIndexproperty to message file models• Updated PDF to
image conversion to use new
IImageConverterinterface• Reduced thread
sleep time from 100ms to 50ms for better performance
• Enhanced file
model creation with proper indexing
HandleEmailSenderFn.cs
Clean up dependencies and enhance email file handlingsrc/Plugins/BotSharp.Plugin.EmailHandler/Functions/HandleEmailSenderFn.cs
• Removed unused dependencies (
IHttpClientFactory,IHttpContextAccessor)• Enhanced file selection with conversation
settings integration
• Added proper configuration for file selection
parameters
• Improved file attachment handling for email operations
FileInstructService.Pdf.cs
Update PDF processing with new converter interfacesrc/Infrastructure/BotSharp.Core/Files/Services/Instruct/FileInstructService.Pdf.cs
• Updated PDF to image conversion to use new
IImageConverterinterface• Enhanced conversion method with instruction options parameter
•
Updated default model from
gpt-4otogpt-5-mini• Improved converter
selection logic
FileHandlerImageConverter.cs
Add new image converter implementation with PNG supportsrc/Plugins/BotSharp.Plugin.FileHandler/Converters/FileHandlerImageConverter.cs
• Added new image converter implementation using SixLabors.ImageSharp
• Supports PNG conversion with configurable color types (RGBA, RGB,
Grayscale, etc.)
• Implements
IImageConverterinterface for imageprocessing operations
• Provides error handling and fallback to
original binary data
ImageCompletionProvider.Generation.cs
Add background support to OpenAI image generationsrc/Plugins/BotSharp.Plugin.OpenAI/Providers/Image/ImageCompletionProvider.Generation.cs
• Added
#pragma warning disable OPENAI001to suppress OpenAI warnings• Added support for
image_backgroundparameter in image generation•
Enhanced image generation options with background configuration
•
Updated image count handling with better parameter processing
TencentCosService.Conversation.cs
Add file indexing and update converter interface for Tencent COSsrc/Plugins/BotSharp.Plugin.TencentCos/Services/TencentCosService.Conversation.cs
• Added
FileIndexproperty extraction from subdirectory structure•
Updated PDF to image conversion to use new
IImageConverterinterface•
Enhanced file model creation with proper indexing
• Improved converter
selection logic
SelectFileOptions.cs
Refactor file selection options with enhanced configurationsrc/Infrastructure/BotSharp.Abstraction/Files/Models/SelectFileOptions.cs
• Refactored to extend
LlmConfigBasefor consistent LLM configuration• Renamed
IncludeBotFiletoIsIncludeBotFilesfor clarity• Added
MessageLimit,IsAttachFiles, andDataproperties• Replaced
Offsetwith
MessageLimitfor better controlImageCompletionProvider.Edit.cs
Add background support to OpenAI image editingsrc/Plugins/BotSharp.Plugin.OpenAI/Providers/Image/ImageCompletionProvider.Edit.cs
• Added
#pragma warning disable OPENAI001to suppress OpenAI warnings• Added support for
image_backgroundparameter in image editing•
Enhanced image edit options with background configuration
• Updated
image count handling with better parameter processing
LlmModelSetting.cs
Add background configuration to image model settingssrc/Infrastructure/BotSharp.Abstraction/MLTasks/Settings/LlmModelSetting.cs
• Added
Backgroundproperty toImageGenerationSettingandImageEditSetting• Enhanced image model settings with background
configuration support
• Added region comments for better code
organization
• Improved settings structure for image-related
operations
AiResponseHelper.cs
Add AI response helper for enhanced user feedbacksrc/Plugins/BotSharp.Plugin.FileHandler/Helpers/AiResponseHelper.cs
• Added new helper class for AI-powered response generation
• Provides
default response formatting for file operations
• Implements image
generation response creation with LLM integration
• Enhances user
experience with contextual response messages
IImageConverter.cs
Add new image converter interface for extensible image processingsrc/Infrastructure/BotSharp.Abstraction/Files/Converters/IImageConverter.cs
• Added new interface for image conversion operations
• Supports both
PDF to image conversion and image format conversion
• Provides
extensible architecture for different converter implementations
•
Includes optional configuration through
ImageConvertOptionsFileInstructService.cs
Add image converter support to file instruction servicesrc/Infrastructure/BotSharp.Core/Files/Services/Instruct/FileInstructService.cs
• Added
GetImageConverterhelper method for converter selection•
Enhanced service with image conversion capability
• Added support for
configurable converter providers
• Improved file processing
infrastructure
FileSelectContext.cs
Enhance file selection context with detailed item informationsrc/Infrastructure/BotSharp.Abstraction/Files/Models/FileSelectContext.cs
• Replaced simple ID-based selection with detailed file selection
items
• Added
FileSelectItemclass with message ID, file index, andsource
• Enhanced file selection context with more granular control
•
Improved file identification and selection accuracy
ImageConvertOptions.cs
Add ImageConvertOptions model for image conversion settingssrc/Infrastructure/BotSharp.Abstraction/Files/Models/ImageConvertOptions.cs
• Added new
ImageConvertOptionsclass with default properties forimage conversion
• Includes
ImageTypeproperty defaulting to "png" andColorTypeproperty defaulting to "rgba"util-file-select_file_instruction.liquid
Refactor file selection template with enhanced message-based approachsrc/Infrastructure/BotSharp.Core/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/templates/util-file-select_file_instruction.liquid
• Completely rewrote file selection instruction template with new
structured approach
• Changed from simple file ID selection to
message-based file selection with
message_id,file_source, andfile_index• Added detailed requirements and response format sections
for better file selection logic
• Replaced example-based approach with
step-by-step instruction methodology
util-chart-plot_instruction.liquid
Remove report summary from chart plotting response formatsrc/Plugins/BotSharp.Plugin.ChartHandler/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/templates/util-chart-plot_instruction.liquid
• Removed
report_summaryfield from the JSON response format•
Simplified output to only include
greeting_messageandjs_codefieldsutil-file-generate_image.fn.liquid
Clarify image generation function usage conditionssrc/Plugins/BotSharp.Plugin.FileHandler/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/templates/util-file-generate_image.fn.liquid
• Modified instruction to clarify when NOT to call
util-file-generate_image• Added specific condition about not calling
function when user wants to change or edit existing images
util-file-edit_image.fn.liquid
Expand image editing function trigger conditionssrc/Plugins/BotSharp.Plugin.FileHandler/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/templates/util-file-edit_image.fn.liquid
• Added "modify" to the list of actions that trigger image editing
function
• Enhanced instruction to include more comprehensive editing
scenarios
util-file-edit_image.json
Refine image editing function parameter descriptionsrc/Plugins/BotSharp.Plugin.FileHandler/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/functions/util-file-edit_image.json
• Updated
user_requestparameter description to be more specific aboutuser requirements for image editing
1 files
PlotChartFn.cs
Improve chart plotting error handling and simplify response processingsrc/Plugins/BotSharp.Plugin.ChartHandler/Functions/PlotChartFn.cs
• Enhanced error handling for AI chart response deserialization
•
Removed additional message wrapper functionality
• Simplified response
handling with better error recovery
• Improved code robustness with
try-catch for JSON deserialization
4 files
RoleDialogModel.cs
Remove additional message wrapper functionality from dialog modelsrc/Infrastructure/BotSharp.Abstraction/Conversations/Models/RoleDialogModel.cs
• Removed
AdditionalMessageWrapperproperty and related functionality• Simplified dialog model by removing sequential message sending
capability
• Cleaned up JSON serialization attributes
• Streamlined
model structure for better maintainability
ConversationController.cs
Remove additional message wrapper from conversation controllersrc/Infrastructure/BotSharp.OpenAPI/Controllers/ConversationController.cs
• Removed
AdditionalMessageWrapperhandling from conversationresponses
• Simplified response processing by removing sequential
message functionality
• Cleaned up response model assignments
•
Streamlined conversation flow handling
Using.cs
Add new global using statements for converters and helperssrc/Plugins/BotSharp.Plugin.FileHandler/Using.cs
• Added new global using statements for file converters and helpers
•
Enhanced namespace imports for better code organization
• Added
support for new converter interfaces and helper classes
• Improved
code accessibility with additional imports
ConversationStorage.cs
Remove additional message wrapper from conversation storagesrc/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStorage.cs
• Removed handling of
AdditionalMessageWrapperin dialog storage•
Simplified dialog element building process
• Cleaned up conversation
storage logic
• Streamlined dialog processing workflow
4 files
FileHandlerSettings.cs
Add comprehensive file handler settings configurationsrc/Plugins/BotSharp.Plugin.FileHandler/Settings/FileHandlerSettings.cs
• Added comprehensive settings structure for image and PDF operations
• Added
ImageConverterconfiguration with provider selection• Created
specialized settings classes for different file operations
• Added
FileLlmSettingBasefor consistent LLM configurationConversationSetting.cs
Add file selection settings to conversation configurationsrc/Infrastructure/BotSharp.Abstraction/Conversations/Settings/ConversationSetting.cs
• Added
FileSelectSettingproperty for file selection configuration•
Created new
FileSelectSettingclass extendingLlmConfigBase• Enhanced
conversation settings with file handling capabilities
• Added message
limit configuration for file selection
appsettings.json
Add FileHandler and FileSelect configuration sectionssrc/WebStarter/appsettings.json
• Added new
FileSelectconfiguration section with LLM settings forfile selection
• Added comprehensive
FileHandlerconfiguration sectionwith image and PDF handling settings
• Included new
ImageConverterprovider configuration
agent.json
Update agent LLM model and add reasoning effort configurationsrc/Infrastructure/BotSharp.Core/data/agents/01e2fc5c-2c89-4ec7-8470-7688608b496c/agent.json
• Updated LLM model from "gpt-4o-mini" to "gpt-5-mini"
• Added new
reasoning_effort_levelproperty set to "minimal"2 files
Directory.Packages.props
Update AI and image processing package versionsDirectory.Packages.props
• Updated
Google_GenerativeAIandGoogle_GenerativeAI.Livefromversion 2.5.8 to 3.2.0
• Updated
SixLabors.ImageSharpfrom version3.1.7 to 3.1.11
• Updated
Azure.AI.OpenAIfrom version 2.2.0-beta.5 to2.3.0-beta.2
• Updated
OpenAIfrom version 2.3.0 to 2.4.0BotSharp.Plugin.FileHandler.csproj
Add ImageSharp package reference for image processingsrc/Plugins/BotSharp.Plugin.FileHandler/BotSharp.Plugin.FileHandler.csproj
• Added
SixLabors.ImageSharppackage reference to the project17 files