Skip to content

Commit 0912cbb

Browse files
committed
Merge branch 'master' of https://github.com/SciSharp/BotSharp
2 parents 1a1919f + b3c02b3 commit 0912cbb

30 files changed

Lines changed: 699 additions & 378 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace BotSharp.Abstraction.Agents;
2+
3+
public interface IInstructionResolver
4+
{
5+
string Name { get; }
6+
7+
Task<string> ResolveAsync(Agent agent, string instruction, IEnumerable<object?> args, IDictionary<string, object?> kwArgs)
8+
=> Task.FromResult(instruction);
9+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public class CleanConversationSetting
2323
public int BatchSize { get; set; }
2424
public int MessageLimit { get; set; }
2525
public int BufferHours { get; set; }
26+
public int LogRetentionDays { get; set; }
27+
public int LogBatchSize { get; set; } = 2000;
2628
public IEnumerable<string> ExcludeAgentIds { get; set; } = new List<string>();
2729
}
2830

src/Infrastructure/BotSharp.Abstraction/Models/Gpt4xModelConstants.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,8 @@ namespace BotSharp.Abstraction.Models;
33
public static class Gpt4xModelConstants
44
{
55
public const string GPT_4o = "gpt-4o";
6-
public const string GPT_4o_2024_11_20 = "gpt-4o-2024-11-20";
76
public const string GPT_4o_Mini = "gpt-4o-mini";
8-
public const string GPT_4_1 = "gpt-4.1";
9-
public const string GPT_4_1_Mini = "gpt-4.1-mini";
10-
public const string GPT_4_1_Nano = "gpt-4.1-nano";
117
public const string GPT_4o_Mini_Realtime_Preview = "gpt-4o-mini-realtime-preview";
12-
public const string GPT_4o_Realtime_Preview = "gpt-4o-realtime-preview";
138
public const string GPT_4o_Mini_Search_Preview = "gpt-4o-mini-search-preview";
149
public const string GPT_4o_Mini_Transcribe = "gpt-4o-mini-transcribe";
1510
public const string GPT_4o_Transcribe = "gpt-4o-transcribe";

src/Infrastructure/BotSharp.Abstraction/Realtime/Settings/RealtimeModelSettings.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ namespace BotSharp.Abstraction.Realtime.Settings;
44

55
public class RealtimeModelSettings
66
{
7-
public string Provider { get; set; } = "openai";
8-
public string Model { get; set; } = Gpt4xModelConstants.GPT_4o_Mini_Realtime_Preview;
7+
public string Provider { get; set; }
8+
public string Model { get; set; }
99
public string[] Modalities { get; set; } = ["text", "audio"];
1010
public bool InterruptResponse { get; set; } = true;
1111
public string InputAudioFormat { get; set; } = "g711_ulaw";

src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ Task<DateTimePagination<ConversationStateLogModel>> GetConversationStateLogs(str
198198
=> throw new NotImplementedException();
199199
#endregion
200200

201+
#region Log Cleanup
202+
Task<int> DeleteOldConversationLogs(int retentionDays, int batchSize)
203+
=> throw new NotImplementedException();
204+
#endregion
205+
201206
#region Instruction Log
202207
Task<bool> SaveInstructionLogs(IEnumerable<InstructionLogModel> logs)
203208
=> throw new NotImplementedException();

src/Infrastructure/BotSharp.Abstraction/Rules/RuleGraph.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ public class RuleNode : GraphItem
177177
/// <summary>
178178
/// Node type: root, criteria, action, etc.
179179
/// </summary>
180+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
180181
public override string Type { get; set; } = "action";
181182

182183
/// <summary>
@@ -229,15 +230,28 @@ public override string ToString()
229230

230231
public class GraphItem
231232
{
233+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
232234
public virtual string Id { get; set; } = Guid.NewGuid().ToString();
235+
236+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
233237
public virtual string Name { get; set; } = null!;
238+
239+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
234240
public virtual string Type { get; set; } = null!;
241+
242+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
235243
public virtual IEnumerable<string> Labels { get; set; } = [];
236244
public virtual double Weight { get; set; } = 1.0;
245+
246+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
237247
public virtual string? Description { get; set; }
248+
249+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
238250
public virtual Dictionary<string, string?> Config { get; set; } = [];
239251

240252
private string? _alias;
253+
254+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
241255
public virtual string Alias
242256
{
243257
get => string.IsNullOrEmpty(_alias) ? Name : _alias;
@@ -267,6 +281,8 @@ public class EdgeItemPayload : GraphItem
267281

268282
public class RuleGraphInfo
269283
{
284+
[JsonPropertyName("graph_id")]
285+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
270286
public string GraphId { get; set; }
271287
public IEnumerable<RuleNode> Nodes { get; set; } = [];
272288
public IEnumerable<RuleEdge> Edges { get; set; } = [];
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace BotSharp.Abstraction.Templating;
2+
3+
public interface IRenderConfiguration
4+
{
5+
string Render(IServiceProvider services, string template, IDictionary<string, object> dict);
6+
void RegisterType(Type type);
7+
}

src/Infrastructure/BotSharp.Abstraction/Templating/ITemplateRender.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ namespace BotSharp.Abstraction.Templating;
33
public interface ITemplateRender
44
{
55
string Render(string template, IDictionary<string, object> dict);
6-
void RegisterType(Type type);
76
}

src/Infrastructure/BotSharp.Core/Agents/AgentPlugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void RegisterDI(IServiceCollection services, IConfiguration config)
4444
services.AddScoped(provider =>
4545
{
4646
var settingService = provider.GetRequiredService<ISettingService>();
47-
var render = provider.GetRequiredService<ITemplateRender>();
47+
var render = provider.GetRequiredService<IRenderConfiguration>();
4848
render.RegisterType(typeof(AgentSettings));
4949
return settingService.Bind<AgentSettings>("Agent");
5050
});

src/Infrastructure/BotSharp.Core/BotSharpCoreExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public static IServiceCollection AddBotSharpCore(this IServiceCollection service
2525
{
2626
services.AddSingleton<IDistributedLocker, DistributedLocker>();
2727
// Register template render
28-
services.AddSingleton<ITemplateRender, TemplateRender>();
28+
services.AddSingleton<IRenderConfiguration, RenderConfiguration>();
29+
services.AddScoped<ITemplateRender, TemplateRender>();
2930

3031
services.AddScoped<ISettingService, SettingService>();
3132
services.AddScoped<IRoleService, RoleService>();

0 commit comments

Comments
 (0)