Skip to content

Commit 611d5ca

Browse files
authored
Merge pull request #1145 from iceljc/features/refine-model-settings
Features/refine model settings
2 parents 6fab3e0 + 70477fd commit 611d5ca

File tree

61 files changed

+1605
-582
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1605
-582
lines changed

Directory.Packages.props

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
</PropertyGroup>
77
<ItemGroup>
88
<PackageVersion Include="EntityFramework" Version="6.4.4" />
9-
<PackageVersion Include="Google_GenerativeAI" Version="2.5.8" />
10-
<PackageVersion Include="Google_GenerativeAI.Live" Version="2.5.8" />
9+
<PackageVersion Include="Google_GenerativeAI" Version="3.2.0" />
10+
<PackageVersion Include="Google_GenerativeAI.Live" Version="3.2.0" />
1111
<PackageVersion Include="LLMSharp.Google.Palm" Version="1.0.2" />
1212
<PackageVersion Include="Microsoft.AspNetCore.Http.Abstractions" Version="$(AspNetCoreVersion)" />
1313
<PackageVersion Include="Microsoft.AspNetCore.StaticFiles" Version="$(AspNetCoreVersion)" />
@@ -20,7 +20,7 @@
2020
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
2121
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
2222
<PackageVersion Include="SharpHook" Version="5.3.9" />
23-
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.7" />
23+
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.11" />
2424
<PackageVersion Include="System.ClientModel" Version="1.3.0" />
2525
<PackageVersion Include="System.ComponentModel.Annotations" Version="5.0.0" />
2626
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="8.0.0" />
@@ -45,8 +45,8 @@
4545
<PackageVersion Include="Whisper.net" Version="1.8.1" />
4646
<PackageVersion Include="Whisper.net.Runtime" Version="1.8.1" />
4747
<PackageVersion Include="NCrontab" Version="3.3.3" />
48-
<PackageVersion Include="Azure.AI.OpenAI" Version="2.2.0-beta.5" />
49-
<PackageVersion Include="OpenAI" Version="2.3.0" />
48+
<PackageVersion Include="Azure.AI.OpenAI" Version="2.3.0-beta.2" />
49+
<PackageVersion Include="OpenAI" Version="2.4.0" />
5050
<PackageVersion Include="MailKit" Version="4.11.0" />
5151
<PackageVersion Include="Microsoft.Data.Sqlite" Version="8.0.8" />
5252
<PackageVersion Include="MySql.Data" Version="9.0.0" />

src/Infrastructure/BotSharp.Abstraction/Conversations/Dtos/ChatResponseDto.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ public class ChatResponseDto : InstructResult
4646
[JsonPropertyName("is_streaming")]
4747
public bool IsStreaming { get; set; }
4848

49-
[JsonPropertyName("is_append")]
50-
public bool IsAppend { get; set; }
51-
5249
[JsonPropertyName("created_at")]
5350
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
5451
}

src/Infrastructure/BotSharp.Abstraction/Conversations/Models/RoleDialogModel.cs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,6 @@ public class RoleDialogModel : ITrackableMessage
132132
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
133133
public bool IsStreaming { get; set; }
134134

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

142136
public RoleDialogModel()
143137
{
@@ -184,26 +178,7 @@ public static RoleDialogModel From(RoleDialogModel source,
184178
Instruction = source.Instruction,
185179
Data = source.Data,
186180
IsStreaming = source.IsStreaming,
187-
Annotations = source.Annotations,
188-
AdditionalMessageWrapper = source.AdditionalMessageWrapper
181+
Annotations = source.Annotations
189182
};
190183
}
191-
}
192-
193-
public class ChatMessageWrapper
194-
{
195-
/// <summary>
196-
/// Messages sending interval in milliseconds
197-
/// </summary>
198-
public int SendingInterval { get; set; }
199-
200-
/// <summary>
201-
/// Whether the Messages are saved to db
202-
/// </summary>
203-
public bool SaveToDb { get; set; }
204-
205-
/// <summary>
206-
/// Messages to send or save
207-
/// </summary>
208-
public List<RoleDialogModel>? Messages { get; set; }
209184
}

src/Infrastructure/BotSharp.Abstraction/Conversations/Settings/ConversationSetting.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class ConversationSetting
1414
public bool EnableTranslationMemory { get; set; }
1515
public CleanConversationSetting CleanSetting { get; set; } = new();
1616
public RateLimitSetting RateLimit { get; set; } = new();
17+
public FileSelectSetting? FileSelect { get; set; }
1718
}
1819

1920
public class CleanConversationSetting
@@ -24,3 +25,8 @@ public class CleanConversationSetting
2425
public int BufferHours { get; set; }
2526
public IEnumerable<string> ExcludeAgentIds { get; set; } = new List<string>();
2627
}
28+
29+
public class FileSelectSetting : LlmConfigBase
30+
{
31+
public int? MessageLimit { get; set; }
32+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace BotSharp.Abstraction.Files.Converters;
2+
3+
public interface IImageConverter
4+
{
5+
public string Provider { get; }
6+
7+
/// <summary>
8+
/// Convert pdf pages to images, and return a list of image file paths
9+
/// </summary>
10+
/// <param name="pdfLocation">Pdf file location</param>
11+
/// <param name="imageFolderLocation">Image folder location</param>
12+
/// <returns></returns>
13+
/// <exception cref="NotImplementedException"></exception>
14+
Task<IEnumerable<string>> ConvertPdfToImages(string pdfLocation, string imageFolderLocation) => throw new NotImplementedException();
15+
16+
/// <summary>
17+
/// Convert an image to PNG with RGBA
18+
/// </summary>
19+
/// <param name="binary"></param>
20+
/// <param name="options"></param>
21+
/// <returns></returns>
22+
/// <exception cref="NotImplementedException"></exception>
23+
Task<BinaryData> ConvertImage(BinaryData binary, ImageConvertOptions? options = null) => throw new NotImplementedException();
24+
}

src/Infrastructure/BotSharp.Abstraction/Files/Converters/IPdf2ImageConverter.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/Infrastructure/BotSharp.Abstraction/Files/FileCoreSettings.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ namespace BotSharp.Abstraction.Files;
55
public class FileCoreSettings
66
{
77
public string Storage { get; set; } = FileStorageEnum.LocalFileStorage;
8-
public SettingBase Pdf2TextConverter { get; set; }
9-
public SettingBase Pdf2ImageConverter { get; set; }
8+
public SettingBase? Pdf2TextConverter { get; set; }
9+
public SettingBase? Pdf2ImageConverter { get; set; }
10+
public SettingBase? ImageConverter { get; set; }
1011
}
1112

1213
public class SettingBase

src/Infrastructure/BotSharp.Abstraction/Files/Models/BotSharpFile.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
namespace BotSharp.Abstraction.Files.Models;
32

43
public class BotSharpFile : FileInformation
@@ -9,4 +8,8 @@ public class BotSharpFile : FileInformation
98
[JsonPropertyName("file_data")]
109
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
1110
public string? FileData { get; set; } = string.Empty;
11+
12+
[JsonPropertyName("file_index")]
13+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
14+
public string? FileIndex { get; set; } = string.Empty;
1215
}

src/Infrastructure/BotSharp.Abstraction/Files/Models/FileInformation.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,7 @@ public class FileInformation
4242
[JsonPropertyName("file_download_url")]
4343
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
4444
public string? FileDownloadUrl { get; set; } = string.Empty;
45+
46+
47+
public string FileFullName => $"{FileName}.{FileExtension}";
4548
}

src/Infrastructure/BotSharp.Abstraction/Files/Models/FileSelectContext.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,21 @@ namespace BotSharp.Abstraction.Files.Models;
22

33
public class FileSelectContext
44
{
5-
[JsonPropertyName("selected_ids")]
6-
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
7-
public IEnumerable<int>? Selecteds { get; set; }
5+
[JsonPropertyName("selected_files")]
6+
public List<FileSelectItem>? SelectedFiles { get; set; }
87
}
8+
9+
public class FileSelectItem
10+
{
11+
[JsonPropertyName("message_id")]
12+
public string MessageId { get; set; }
13+
14+
[JsonPropertyName("file_index")]
15+
public string FileIndex { get; set; }
16+
17+
[JsonPropertyName("file_source")]
18+
public string FileSource { get; set; }
19+
20+
[JsonPropertyName("file_name")]
21+
public string? FileName { get; set; }
22+
}

0 commit comments

Comments
 (0)