Skip to content

Commit 48967e2

Browse files
author
Jicheng Lu
committed
merge with upstream
2 parents ad7d9a1 + 7756b7a commit 48967e2

File tree

83 files changed

+642
-498
lines changed

Some content is hidden

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

83 files changed

+642
-498
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public interface IAgentService
1212
Task<Agent> CreateAgent(Agent agent);
1313
Task<string> RefreshAgents();
1414
Task<PagedItems<Agent>> GetAgents(AgentFilter filter);
15+
Task<List<IdName>> GetAgentOptions();
1516

1617
/// <summary>
1718
/// Load agent configurations and trigger hooks

src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,5 @@ Task<bool> SendMessage(string agentId,
7171
/// <param name="convLimit">conversation limit</param>
7272
/// <param name="preLoad">if pre-loading, then keys are not filter by the search query</param>
7373
/// <returns></returns>
74-
Task<List<string>> GetConversationStateSearhKeys(string query, int convlimit = 100, int keyLimit = 10, bool preLoad = false);
74+
Task<List<string>> GetConversationStateSearhKeys(string query, int convLimit = 100, int keyLimit = 10, bool preload = false);
7575
}

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

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ public class Conversation
1616
public string TitleAlias { get; set; } = string.Empty;
1717

1818
[JsonIgnore]
19-
public List<DialogElement> Dialogs { get; set; } = new();
19+
public List<DialogElement> Dialogs { get; set; } = [];
2020

2121
[JsonIgnore]
22-
public Dictionary<string, string> States { get; set; } = new();
22+
public Dictionary<string, string> States { get; set; } = [];
2323

2424
public string Status { get; set; } = ConversationStatus.Open;
2525

@@ -28,11 +28,11 @@ public class Conversation
2828
/// <summary>
2929
/// Channel id, like phone number, email address, etc.
3030
/// </summary>
31-
public string ChannelId { get; set; }
31+
public string ChannelId { get; set; } = default!;
3232

3333
public int DialogCount { get; set; }
3434

35-
public List<string> Tags { get; set; } = new();
35+
public List<string> Tags { get; set; } = [];
3636

3737
public DateTime UpdatedTime { get; set; } = DateTime.UtcNow;
3838
public DateTime CreatedTime { get; set; } = DateTime.UtcNow;
@@ -41,10 +41,10 @@ public class Conversation
4141
public class DialogElement
4242
{
4343
[JsonPropertyName("meta_data")]
44-
public DialogMetaData MetaData { get; set; }
44+
public DialogMetaData MetaData { get; set; } = new();
4545

4646
[JsonPropertyName("content")]
47-
public string Content { get; set; }
47+
public string Content { get; set; } = default!;
4848

4949
[JsonPropertyName("secondary_content")]
5050
public string? SecondaryContent { get; set; }
@@ -58,41 +58,46 @@ public class DialogElement
5858
[JsonPropertyName("payload")]
5959
public string? Payload { get; set; }
6060

61+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
62+
[JsonPropertyName("data")]
63+
public object? Data { get; set; }
64+
6165
public DialogElement()
6266
{
6367

6468
}
6569

6670
public DialogElement(DialogMetaData meta, string content, string? richContent = null,
67-
string? secondaryContent = null, string? secondaryRichContent = null, string? payload = null)
71+
string? secondaryContent = null, string? secondaryRichContent = null, string? payload = null, object? data = null)
6872
{
6973
MetaData = meta;
7074
Content = content;
7175
RichContent = richContent;
7276
SecondaryContent = secondaryContent;
7377
SecondaryRichContent = secondaryRichContent;
7478
Payload = payload;
79+
Data = data;
7580
}
7681

7782
public override string ToString()
7883
{
79-
return $"{MetaData.Role}: {Content} [{MetaData?.CreateTime}]";
84+
return $"{MetaData.Role}: {Content} [{MetaData?.CreatedTime}]";
8085
}
8186
}
8287

8388
public class DialogMetaData
8489
{
8590
[JsonPropertyName("role")]
86-
public string Role { get; set; }
91+
public string Role { get; set; } = default!;
8792

8893
[JsonPropertyName("agent_id")]
89-
public string AgentId { get; set; }
94+
public string AgentId { get; set; } = default!;
9095

9196
[JsonPropertyName("message_id")]
92-
public string MessageId { get; set; }
97+
public string MessageId { get; set; } = default!;
9398

9499
[JsonPropertyName("message_type")]
95-
public string MessageType { get; set; }
100+
public string MessageType { get; set; } = default!;
96101

97102
[JsonPropertyName("function_name")]
98103
public string? FunctionName { get; set; }
@@ -101,5 +106,5 @@ public class DialogMetaData
101106
public string? SenderId { get; set; }
102107

103108
[JsonPropertyName("create_at")]
104-
public DateTime CreateTime { get; set; }
109+
public DateTime CreatedTime { get; set; }
105110
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ namespace BotSharp.Abstraction.Files;
33
public interface IFileInstructService
44
{
55
#region Image
6-
Task<string> ReadImages(string? provider, string? model, string text, IEnumerable<InstructFileModel> images);
7-
Task<RoleDialogModel> GenerateImage(string? provider, string? model, string text);
8-
Task<RoleDialogModel> VaryImage(string? provider, string? model, InstructFileModel image);
9-
Task<RoleDialogModel> EditImage(string? provider, string? model, string text, InstructFileModel image);
10-
Task<RoleDialogModel> EditImage(string? provider, string? model, string text, InstructFileModel image, InstructFileModel mask);
6+
Task<string> ReadImages(string? provider, string? model, string text, IEnumerable<InstructFileModel> images, string? agentId = null);
7+
Task<RoleDialogModel> GenerateImage(string? provider, string? model, string text, string? agentId = null);
8+
Task<RoleDialogModel> VaryImage(string? provider, string? model, InstructFileModel image, string? agentId = null);
9+
Task<RoleDialogModel> EditImage(string? provider, string? model, string text, InstructFileModel image, string? agentId = null);
10+
Task<RoleDialogModel> EditImage(string? provider, string? model, string text, InstructFileModel image, InstructFileModel mask, string? agentId = null);
1111
#endregion
1212

1313
#region Pdf
@@ -17,7 +17,7 @@ public interface IFileInstructService
1717
/// <param name="prompt"></param>
1818
/// <param name="files">Pdf files</param>
1919
/// <returns></returns>
20-
Task<string> ReadPdf(string? provider, string? model, string? modelId, string prompt, List<InstructFileModel> files);
20+
Task<string> ReadPdf(string? provider, string? model, string? modelId, string prompt, List<InstructFileModel> files, string? agentId = null);
2121
#endregion
2222

2323
#region Audio

src/Infrastructure/BotSharp.Abstraction/Loggers/Models/AgentQueueChangedLogModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ namespace BotSharp.Abstraction.Loggers.Models;
33
public class AgentQueueChangedLogModel
44
{
55
[JsonPropertyName("conversation_id")]
6-
public string ConversationId { get; set; }
6+
public string ConversationId { get; set; } = default!;
77

88
[JsonPropertyName("log")]
9-
public string Log { get; set; }
9+
public string Log { get; set; } = default!;
1010

1111
[JsonPropertyName("created_at")]
12-
public DateTime CreateTime { get; set; }
12+
public DateTime CreatedTime { get; set; }
1313
}

src/Infrastructure/BotSharp.Abstraction/Loggers/Models/ContentLogOutputModel.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ namespace BotSharp.Abstraction.Loggers.Models;
33
public class ContentLogOutputModel
44
{
55
[JsonPropertyName("conversation_id")]
6-
public string ConversationId { get; set; }
6+
public string ConversationId { get; set; } = default!;
77

88
[JsonPropertyName("message_id")]
9-
public string MessageId { get; set; }
9+
public string MessageId { get; set; } = default!;
1010

1111
[JsonPropertyName("name")]
1212
public string? Name { get; set; }
@@ -15,14 +15,14 @@ public class ContentLogOutputModel
1515
public string? AgentId { get; set; }
1616

1717
[JsonPropertyName("role")]
18-
public string Role { get; set; }
18+
public string Role { get; set; } = default!;
1919

2020
[JsonPropertyName("source")]
21-
public string Source { get; set; }
21+
public string Source { get; set; } = default!;
2222

2323
[JsonPropertyName("content")]
24-
public string Content { get; set; }
24+
public string Content { get; set; } = default!;
2525

2626
[JsonPropertyName("created_at")]
27-
public DateTime CreateTime { get; set; } = DateTime.UtcNow;
27+
public DateTime CreatedTime { get; set; } = DateTime.UtcNow;
2828
}

src/Infrastructure/BotSharp.Abstraction/Loggers/Models/ConversationStateLogModel.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@ namespace BotSharp.Abstraction.Loggers.Models;
22

33
public class ConversationStateLogModel
44
{
5-
[JsonPropertyName("conversation_id")]
6-
public string ConversationId { get; set; }
5+
[JsonPropertyName("conversation_id")] public string ConversationId { get; set; } = default!;
76

8-
[JsonPropertyName("agent_id")]
9-
public string AgentId { get; set; }
7+
[JsonPropertyName("agent_id")] public string AgentId { get; set; } = default!;
108

11-
[JsonPropertyName("message_id")]
12-
public string MessageId { get; set; }
9+
[JsonPropertyName("message_id")] public string MessageId { get; set; } = default!;
1310

1411
[JsonPropertyName("states")]
15-
public Dictionary<string, string> States { get; set; }
12+
public Dictionary<string, string> States { get; set; } = [];
1613

1714
[JsonPropertyName("created_at")]
18-
public DateTime CreateTime { get; set; } = DateTime.UtcNow;
15+
public DateTime CreatedTime { get; set; } = DateTime.UtcNow;
1916
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace BotSharp.Abstraction.Models;
2+
3+
public class IdName
4+
{
5+
[JsonPropertyName("id")]
6+
public string Id { get; set; } = default!;
7+
8+
[JsonPropertyName("name")]
9+
public string Name { get; set; } = default!;
10+
11+
public IdName(string id, string name)
12+
{
13+
Id = id;
14+
Name = name;
15+
}
16+
17+
public override string ToString()
18+
{
19+
return $"{Id}: {Name}";
20+
}
21+
}

src/Infrastructure/BotSharp.Abstraction/Plugins/Models/PluginMenuDef.cs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,30 @@
11
namespace BotSharp.Abstraction.Plugins.Models;
22

3-
public class PluginMenuDef
3+
public class PluginMenuDef(string label, string? link = null, string? icon = null, int weight = 0)
44
{
55
[JsonIgnore]
6-
public string Id { get; set; }
6+
public string Id { get; set; } = default!;
77

8-
public string Label { get; set; }
8+
public string Label { get; set; } = label;
99

1010
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
11-
public string? Icon { get; set; }
11+
public string? Icon { get; set; } = icon;
1212

1313
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
14-
public string? Link { get; set; }
14+
public string? Link { get; set; } = link;
1515

1616
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
1717
public bool? IsHeader { get; set; }
1818

1919
[JsonIgnore]
20-
public int Weight { get; set; }
20+
public int Weight { get; set; } = weight;
2121

2222
[JsonIgnore]
2323
public List<string>? Roles { get; set; }
2424

2525
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
2626
public List<PluginMenuDef>? SubMenu { get; set; }
2727

28-
public PluginMenuDef(string label, string? link = null, string? icon = null, int weight = 0)
29-
{
30-
Label = label;
31-
Link = link;
32-
Icon = icon;
33-
Weight = weight;
34-
}
35-
3628
public override string ToString()
3729
{
3830
return $"{Label} {Link} {Weight}";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ List<string> GetIdleConversations(int batchSize, int messageLimit, int bufferHou
148148
=> throw new NotImplementedException();
149149
List<string> TruncateConversation(string conversationId, string messageId, bool cleanLog = false)
150150
=> throw new NotImplementedException();
151-
List<string> GetConversationStateSearchKeys(int messageLowerLimit = 2, int convUpperlimit = 100)
151+
List<string> GetConversationStateSearchKeys(int messageLowerLimit = 2, int convUpperLimit = 100)
152152
=> throw new NotImplementedException();
153153
#endregion
154154

0 commit comments

Comments
 (0)