Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9108ea6
refine model settings
Aug 22, 2025
ca638da
refine file select prompt
Aug 22, 2025
261a01a
Merge branch 'master' of https://github.com/SciSharp/BotSharp into fe…
Aug 25, 2025
6ff8875
Merge branch 'master' of https://github.com/SciSharp/BotSharp into fe…
Aug 25, 2025
d1118a6
Merge branch 'master' of https://github.com/SciSharp/BotSharp into fe…
Sep 4, 2025
939e9cf
refine setting
Sep 4, 2025
c31eff6
add settings in file handler
Sep 4, 2025
50ff810
minor change
iceljc Sep 5, 2025
fc1bb15
Merge branch 'master' of https://github.com/SciSharp/BotSharp into fe…
iceljc Sep 5, 2025
e12808e
Merge branch 'master' of https://github.com/SciSharp/BotSharp into fe…
Sep 11, 2025
1ed0846
Merge branch 'features/refine-model-settings' of https://github.com/i…
Sep 11, 2025
b20347f
upgrade openai package
Sep 11, 2025
5ed4f90
minor change
Sep 11, 2025
1021c81
remove report summary
Sep 11, 2025
e72a6b5
refine image converter
Sep 11, 2025
6e16aea
minor change
Sep 11, 2025
517d46a
refine image converter
Sep 12, 2025
98291a5
refine multi modal instruct
Sep 12, 2025
93e904d
revert
Sep 12, 2025
e14a83a
refine file select
Sep 12, 2025
f12e395
refine prompt
Sep 13, 2025
349e58e
refine code and settings
Sep 15, 2025
70477fd
patch annotations
Sep 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="EntityFramework" Version="6.4.4" />
<PackageVersion Include="Google_GenerativeAI" Version="2.5.8" />
<PackageVersion Include="Google_GenerativeAI.Live" Version="2.5.8" />
<PackageVersion Include="Google_GenerativeAI" Version="3.2.0" />
<PackageVersion Include="Google_GenerativeAI.Live" Version="3.2.0" />
<PackageVersion Include="LLMSharp.Google.Palm" Version="1.0.2" />
<PackageVersion Include="Microsoft.AspNetCore.Http.Abstractions" Version="$(AspNetCoreVersion)" />
<PackageVersion Include="Microsoft.AspNetCore.StaticFiles" Version="$(AspNetCoreVersion)" />
Expand All @@ -20,7 +20,7 @@
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="SharpHook" Version="5.3.9" />
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.7" />
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.11" />
<PackageVersion Include="System.ClientModel" Version="1.3.0" />
<PackageVersion Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="8.0.0" />
Expand All @@ -45,8 +45,8 @@
<PackageVersion Include="Whisper.net" Version="1.8.1" />
<PackageVersion Include="Whisper.net.Runtime" Version="1.8.1" />
<PackageVersion Include="NCrontab" Version="3.3.3" />
<PackageVersion Include="Azure.AI.OpenAI" Version="2.2.0-beta.5" />
<PackageVersion Include="OpenAI" Version="2.3.0" />
<PackageVersion Include="Azure.AI.OpenAI" Version="2.3.0-beta.2" />
<PackageVersion Include="OpenAI" Version="2.4.0" />
<PackageVersion Include="MailKit" Version="4.11.0" />
<PackageVersion Include="Microsoft.Data.Sqlite" Version="8.0.8" />
<PackageVersion Include="MySql.Data" Version="9.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ public class ChatResponseDto : InstructResult
[JsonPropertyName("is_streaming")]
public bool IsStreaming { get; set; }

[JsonPropertyName("is_append")]
public bool IsAppend { get; set; }

[JsonPropertyName("created_at")]
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,6 @@ public class RoleDialogModel : ITrackableMessage
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
public bool IsStreaming { get; set; }

/// <summary>
/// Additional messages that can be sent sequentially and save to db
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
public ChatMessageWrapper? AdditionalMessageWrapper { get; set; }


public RoleDialogModel()
{
Expand Down Expand Up @@ -184,26 +178,7 @@ public static RoleDialogModel From(RoleDialogModel source,
Instruction = source.Instruction,
Data = source.Data,
IsStreaming = source.IsStreaming,
Annotations = source.Annotations,
AdditionalMessageWrapper = source.AdditionalMessageWrapper
Annotations = source.Annotations
};
}
}

public class ChatMessageWrapper
{
/// <summary>
/// Messages sending interval in milliseconds
/// </summary>
public int SendingInterval { get; set; }

/// <summary>
/// Whether the Messages are saved to db
/// </summary>
public bool SaveToDb { get; set; }

/// <summary>
/// Messages to send or save
/// </summary>
public List<RoleDialogModel>? Messages { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class ConversationSetting
public bool EnableTranslationMemory { get; set; }
public CleanConversationSetting CleanSetting { get; set; } = new();
public RateLimitSetting RateLimit { get; set; } = new();
public FileSelectSetting? FileSelect { get; set; }
}

public class CleanConversationSetting
Expand All @@ -24,3 +25,8 @@ public class CleanConversationSetting
public int BufferHours { get; set; }
public IEnumerable<string> ExcludeAgentIds { get; set; } = new List<string>();
}

public class FileSelectSetting : LlmConfigBase
{
public int? MessageLimit { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace BotSharp.Abstraction.Files.Converters;

public interface IImageConverter
{
public string Provider { get; }

/// <summary>
/// Convert pdf pages to images, and return a list of image file paths
/// </summary>
/// <param name="pdfLocation">Pdf file location</param>
/// <param name="imageFolderLocation">Image folder location</param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
Task<IEnumerable<string>> ConvertPdfToImages(string pdfLocation, string imageFolderLocation) => throw new NotImplementedException();

/// <summary>
/// Convert an image to PNG with RGBA
/// </summary>
/// <param name="binary"></param>
/// <param name="options"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
Task<BinaryData> ConvertImage(BinaryData binary, ImageConvertOptions? options = null) => throw new NotImplementedException();
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ namespace BotSharp.Abstraction.Files;
public class FileCoreSettings
{
public string Storage { get; set; } = FileStorageEnum.LocalFileStorage;
public SettingBase Pdf2TextConverter { get; set; }
public SettingBase Pdf2ImageConverter { get; set; }
public SettingBase? Pdf2TextConverter { get; set; }
public SettingBase? Pdf2ImageConverter { get; set; }
public SettingBase? ImageConverter { get; set; }
}

public class SettingBase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

namespace BotSharp.Abstraction.Files.Models;

public class BotSharpFile : FileInformation
Expand All @@ -9,4 +8,8 @@ public class BotSharpFile : FileInformation
[JsonPropertyName("file_data")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? FileData { get; set; } = string.Empty;

[JsonPropertyName("file_index")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? FileIndex { get; set; } = string.Empty;
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ public class FileInformation
[JsonPropertyName("file_download_url")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? FileDownloadUrl { get; set; } = string.Empty;


public string FileFullName => $"{FileName}.{FileExtension}";
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,21 @@ namespace BotSharp.Abstraction.Files.Models;

public class FileSelectContext
{
[JsonPropertyName("selected_ids")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public IEnumerable<int>? Selecteds { get; set; }
[JsonPropertyName("selected_files")]
public List<FileSelectItem>? SelectedFiles { get; set; }
}

public class FileSelectItem
{
[JsonPropertyName("message_id")]
public string MessageId { get; set; }

[JsonPropertyName("file_index")]
public string FileIndex { get; set; }

[JsonPropertyName("file_source")]
public string FileSource { get; set; }

[JsonPropertyName("file_name")]
public string? FileName { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace BotSharp.Abstraction.Files.Models;

public class ImageConvertOptions
{
public string ImageType { get; set; } = "png";
public string ColorType { get; set; } = "rgba";
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ public class MessageFileModel : FileInformation
[JsonPropertyName("file_source")]
public string FileSource { get; set; } = FileSourceType.User;

[JsonPropertyName("file_index")]
public string FileIndex { get; set; } = string.Empty;

public MessageFileModel()
{

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
namespace BotSharp.Abstraction.Files.Models;

public class SelectFileOptions
public class SelectFileOptions : LlmConfigBase
{
/// <summary>
/// Llm provider
/// </summary>
public string? Provider { get; set; }

/// <summary>
/// Llm model
/// </summary>
public string? Model { get; set; }

/// <summary>
/// Agent id
/// </summary>
Expand All @@ -30,20 +20,30 @@ public class SelectFileOptions
/// <summary>
/// Whether include bot generated files
/// </summary>
public bool IncludeBotFile { get; set; }
public bool IsIncludeBotFiles { get; set; }

/// <summary>
/// Conversation breakpoint
/// </summary>
public bool FromBreakpoint { get; set; }

/// <summary>
/// Message offset from last
/// The maximum number of messages
/// </summary>
public int? Offset { get; set; }
public int? MessageLimit { get; set; }

/// <summary>
/// Whehter attach files to messages
/// </summary>
public bool IsAttachFiles { get; set; }

/// <summary>
/// File content types. If null, all types of files will be retrived
/// </summary>
public IEnumerable<string>? ContentTypes { get; set; }

/// <summary>
/// Data that can be used to fill in the prompt
/// </summary>
public Dictionary<string, object>? Data { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@ public class InstructOptions
/// Data to fill in prompt
/// </summary>
public Dictionary<string, object> Data { get; set; } = new();

/// <summary>
/// Image convert provider
/// </summary>
public string? ImageConvertProvider { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,31 @@ public override string ToString()
}
}

#region Embedding model settings
public class EmbeddingSetting
{
public int Dimension { get; set; }
}
#endregion


#region Reasoning model settings
public class ReasoningSetting
{
public float Temperature { get; set; } = 1.0f;
public string? EffortLevel { get; set; }
}
#endregion

#region Web search model settings
public class WebSearchSetting
{
public bool IsDefault { get; set; }
public string? SearchContextSize { get; set; }
}
#endregion

#region Image model settings
public class ImageSetting
{
public ImageGenerationSetting? Generation { get; set; }
Expand All @@ -103,20 +111,22 @@ public class ImageGenerationSetting
public ModelSettingBase? Size { get; set; }
public ModelSettingBase? Quality { get; set; }
public ModelSettingBase? ResponseFormat { get; set; }
public ModelSettingBase? Background { get; set; }
}

public class ImageEditSetting
{
public ModelSettingBase? Size { get; set; }
public ModelSettingBase? ResponseFormat { get; set; }
public ModelSettingBase? Background { get; set; }
}

public class ImageVariationSetting
{
public ModelSettingBase? Size { get; set; }
public ModelSettingBase? ResponseFormat { get; set; }
}

#endregion

public class ModelSettingBase
{
Expand Down
24 changes: 24 additions & 0 deletions src/Infrastructure/BotSharp.Abstraction/Models/LlmConfigBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace BotSharp.Abstraction.Models;

public class LlmConfigBase
{
/// <summary>
/// Llm provider
/// </summary>
public string? LlmProvider { get; set; }

/// <summary>
/// Llm model
/// </summary>
public string? LlmModel { get; set; }

/// <summary>
/// Llm maximum output tokens
/// </summary>
public int? MaxOutputTokens { get; set; }

/// <summary>
/// Llm reasoning effort level
/// </summary>
public string? ReasoningEffortLevel { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,10 @@ public void Append(string conversationId, IEnumerable<RoleDialogModel> dialogs)

foreach ( var dialog in dialogs)
{
var innerList = new List<RoleDialogModel> { dialog };
if (dialog.AdditionalMessageWrapper != null
&& dialog.AdditionalMessageWrapper.SaveToDb
&& dialog.AdditionalMessageWrapper.Messages?.Count > 0)
var element = BuildDialogElement(dialog);
if (element != null)
{
innerList.AddRange(dialog.AdditionalMessageWrapper.Messages);
}

foreach (var item in innerList)
{
var element = BuildDialogElement(item);
if (element != null)
{
dialogElements.Add(element);
}
dialogElements.Add(element);
}
}

Expand Down
Loading
Loading