Skip to content

Commit e99cfac

Browse files
authored
Merge pull request #1181 from iceljc/features/add-image-llm-config
Features/add image llm config
2 parents 61b3279 + 40e8457 commit e99cfac

File tree

73 files changed

+1006
-485
lines changed

Some content is hidden

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

73 files changed

+1006
-485
lines changed

BotSharp.sln

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.Plugin.ChartHandle
147147
EndProject
148148
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.Plugin.ExcelHandler", "src\Plugins\BotSharp.Plugin.ExcelHandler\BotSharp.Plugin.ExcelHandler.csproj", "{FC63C875-E880-D8BB-B8B5-978AB7B62983}"
149149
EndProject
150+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.Plugin.ImageHandler", "src\Plugins\BotSharp.Plugin.ImageHandler\BotSharp.Plugin.ImageHandler.csproj", "{242F2D93-FCCE-4982-8075-F3052ECCA92C}"
151+
EndProject
150152
Global
151153
GlobalSection(SolutionConfigurationPlatforms) = preSolution
152154
Debug|Any CPU = Debug|Any CPU
@@ -619,6 +621,14 @@ Global
619621
{FC63C875-E880-D8BB-B8B5-978AB7B62983}.Release|Any CPU.Build.0 = Release|Any CPU
620622
{FC63C875-E880-D8BB-B8B5-978AB7B62983}.Release|x64.ActiveCfg = Release|Any CPU
621623
{FC63C875-E880-D8BB-B8B5-978AB7B62983}.Release|x64.Build.0 = Release|Any CPU
624+
{242F2D93-FCCE-4982-8075-F3052ECCA92C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
625+
{242F2D93-FCCE-4982-8075-F3052ECCA92C}.Debug|Any CPU.Build.0 = Debug|Any CPU
626+
{242F2D93-FCCE-4982-8075-F3052ECCA92C}.Debug|x64.ActiveCfg = Debug|Any CPU
627+
{242F2D93-FCCE-4982-8075-F3052ECCA92C}.Debug|x64.Build.0 = Debug|Any CPU
628+
{242F2D93-FCCE-4982-8075-F3052ECCA92C}.Release|Any CPU.ActiveCfg = Release|Any CPU
629+
{242F2D93-FCCE-4982-8075-F3052ECCA92C}.Release|Any CPU.Build.0 = Release|Any CPU
630+
{242F2D93-FCCE-4982-8075-F3052ECCA92C}.Release|x64.ActiveCfg = Release|Any CPU
631+
{242F2D93-FCCE-4982-8075-F3052ECCA92C}.Release|x64.Build.0 = Release|Any CPU
622632
EndGlobalSection
623633
GlobalSection(SolutionProperties) = preSolution
624634
HideSolutionNode = FALSE
@@ -690,6 +700,7 @@ Global
690700
{B067B126-88CD-4282-BEEF-7369B64423EF} = {32FAFFFE-A4CB-4FEE-BF7C-84518BBC6DCC}
691701
{0428DEAA-E4FE-4259-A6D8-6EDD1A9D0702} = {51AFE054-AE99-497D-A593-69BAEFB5106F}
692702
{FC63C875-E880-D8BB-B8B5-978AB7B62983} = {51AFE054-AE99-497D-A593-69BAEFB5106F}
703+
{242F2D93-FCCE-4982-8075-F3052ECCA92C} = {51AFE054-AE99-497D-A593-69BAEFB5106F}
693704
EndGlobalSection
694705
GlobalSection(ExtensibilityGlobals) = postSolution
695706
SolutionGuid = {A9969D89-C98B-40A5-A12B-FC87E55B3A19}

src/Infrastructure/BotSharp.Abstraction/Agents/IAgentService.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using BotSharp.Abstraction.Agents.Options;
12
using BotSharp.Abstraction.Functions.Models;
23
using BotSharp.Abstraction.Plugins.Models;
34
using BotSharp.Abstraction.Repositories.Filters;
@@ -65,4 +66,13 @@ public interface IAgentService
6566
Task<List<UserAgent>> GetUserAgents(string userId);
6667

6768
PluginDef GetPlugin(string agentId);
69+
70+
Task<List<AgentCodeScript>> GetAgentCodeScripts(string agentId, AgentCodeScriptFilter? filter = null)
71+
=> Task.FromResult(new List<AgentCodeScript>());
72+
73+
Task<string?> GetAgentCodeScript(string agentId, string scriptName, string scriptType = AgentCodeScriptType.Src)
74+
=> Task.FromResult(string.Empty);
75+
76+
Task<bool> UpdateAgentCodeScripts(string agentId, List<AgentCodeScript> codeScripts, AgentCodeScriptUpdateOptions? options = null)
77+
=> Task.FromResult(false);
6878
}

src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentLlmConfig.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,49 @@ public class AgentLlmConfig
4141
[JsonPropertyName("reasoning_effort_level")]
4242
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
4343
public string? ReasoningEffortLevel { get; set; }
44+
45+
/// <summary>
46+
/// Image generation config
47+
/// </summary>
48+
[JsonPropertyName("image_generation")]
49+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
50+
public LlmImageGenerationConfig? ImageGeneration { get; set; }
51+
52+
/// <summary>
53+
/// Image edit config
54+
/// </summary>
55+
[JsonPropertyName("image_edit")]
56+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
57+
public LlmImageEditConfig? ImageEdit { get; set; }
58+
59+
/// <summary>
60+
/// Audio transcription config
61+
/// </summary>
62+
[JsonPropertyName("audio_transcription")]
63+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
64+
public LlmAudioTranscriptionConfig? AudioTranscription { get; set; }
65+
66+
/// <summary>
67+
/// Realtime config
68+
/// </summary>
69+
[JsonPropertyName("realtime")]
70+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
71+
public LlmRealtimeConfig? Realtime { get; set; }
72+
}
73+
74+
75+
public class LlmImageGenerationConfig : LlmProviderModel
76+
{
77+
}
78+
79+
public class LlmImageEditConfig : LlmProviderModel
80+
{
4481
}
82+
83+
public class LlmAudioTranscriptionConfig : LlmProviderModel
84+
{
85+
}
86+
87+
public class LlmRealtimeConfig : LlmProviderModel
88+
{
89+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using BotSharp.Abstraction.Repositories.Models;
2+
3+
namespace BotSharp.Abstraction.Agents.Options;
4+
5+
public class AgentCodeScriptUpdateOptions : AgentCodeScriptDbUpdateOptions
6+
{
7+
public bool DeleteIfNotIncluded { get; set; }
8+
}

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public class RoleDialogModel : ITrackableMessage
141141
public bool IsFromAssistant => Role == AgentRole.Assistant || Role == AgentRole.Model;
142142

143143
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
144-
public string RoleContent
144+
public string LlmContent
145145
{
146146
get
147147
{
@@ -150,10 +150,6 @@ public string RoleContent
150150
{
151151
text = !string.IsNullOrWhiteSpace(Payload) ? Payload : Content;
152152
}
153-
else
154-
{
155-
text = !string.IsNullOrWhiteSpace(Content) ? Content : RichContent?.Message?.Text;
156-
}
157153

158154
return text;
159155
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
namespace BotSharp.Abstraction.Files.Models;
2+
3+
public class FileLlmProcessOptions
4+
{
5+
/// <summary>
6+
/// Llm provider
7+
/// </summary>
8+
public string? Provider { get; set; }
9+
10+
/// <summary>
11+
/// llm model
12+
/// </summary>
13+
public string? Model { get; set; }
14+
15+
/// <summary>
16+
/// Llm maximum output tokens
17+
/// </summary>
18+
public int? MaxOutputTokens { get; set; }
19+
20+
/// <summary>
21+
/// Reasoning effort level
22+
/// </summary>
23+
public string? ReasoningEfforLevel { get; set; }
24+
25+
/// <summary>
26+
/// Instruction
27+
/// </summary>
28+
public string? Instruction { get; set; }
29+
30+
/// <summary>
31+
/// Template name in Agent
32+
/// </summary>
33+
public string? TemplateName { get; set; }
34+
35+
/// <summary>
36+
/// Data that is used to render instruction
37+
/// </summary>
38+
public Dictionary<string, object>? Data { get; set; }
39+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class SelectFileOptions : LlmConfigBase
1010
/// <summary>
1111
/// Template (prompt) name
1212
/// </summary>
13-
public string? Template { get; set; }
13+
public string? TemplateName { get; set; }
1414

1515
/// <summary>
1616
/// Description that user provides to select files
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace BotSharp.Abstraction.Files.Proccessors;
2+
3+
public interface IFileLlmProcessor
4+
{
5+
public string Provider { get; }
6+
7+
Task<RoleDialogModel> GetFileLlmInferenceAsync(Agent agent, string text, IEnumerable<InstructFileModel> files, FileLlmProcessOptions? options = null)
8+
=> throw new NotImplementedException();
9+
}

src/Infrastructure/BotSharp.Abstraction/Instructs/IInstructService.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ public interface IInstructService
1313
/// <param name="templateName"></param>
1414
/// <param name="files"></param>
1515
/// <param name="codeOptions"></param>
16+
/// <param name="fileOptions"></param>
1617
/// <returns></returns>
1718
Task<InstructResult> Execute(string agentId, RoleDialogModel message,
1819
string? instruction = null, string? templateName = null,
19-
IEnumerable<InstructFileModel>? files = null, CodeInstructOptions? codeOptions = null);
20+
IEnumerable<InstructFileModel>? files = null,
21+
CodeInstructOptions? codeOptions = null,
22+
FileInstructOptions? fileOptions = null);
2023

2124
/// <summary>
2225
/// A generic way to execute completion by using specified instruction or template
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace BotSharp.Abstraction.Instructs.Models;
2+
3+
public class FileInstructOptions
4+
{
5+
public string? FileLlmProcessorProvider { get; set; }
6+
}

0 commit comments

Comments
 (0)