Skip to content

Commit b1e501c

Browse files
authored
Merge pull request #846 from iceljc/features/add-deep-seek
Features/add deep seek
2 parents 7bae527 + 453d4bc commit b1e501c

File tree

24 files changed

+698
-175
lines changed

24 files changed

+698
-175
lines changed

BotSharp.sln

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.Core.Crontab", "sr
125125
EndProject
126126
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.Core.Rules", "src\Infrastructure\BotSharp.Core.Rules\BotSharp.Core.Rules.csproj", "{AFD64412-4D6A-452E-82A2-79E5D8842E29}"
127127
EndProject
128+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.Plugin.DeepSeekAI", "src\Plugins\BotSharp.Plugin.DeepSeekAI\BotSharp.Plugin.DeepSeekAI.csproj", "{AF329442-B48E-4B48-A18A-1C869D1BA6F5}"
129+
EndProject
128130
Global
129131
GlobalSection(SolutionConfigurationPlatforms) = preSolution
130132
Debug|Any CPU = Debug|Any CPU
@@ -509,6 +511,14 @@ Global
509511
{AFD64412-4D6A-452E-82A2-79E5D8842E29}.Release|Any CPU.Build.0 = Release|Any CPU
510512
{AFD64412-4D6A-452E-82A2-79E5D8842E29}.Release|x64.ActiveCfg = Release|Any CPU
511513
{AFD64412-4D6A-452E-82A2-79E5D8842E29}.Release|x64.Build.0 = Release|Any CPU
514+
{AF329442-B48E-4B48-A18A-1C869D1BA6F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
515+
{AF329442-B48E-4B48-A18A-1C869D1BA6F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
516+
{AF329442-B48E-4B48-A18A-1C869D1BA6F5}.Debug|x64.ActiveCfg = Debug|Any CPU
517+
{AF329442-B48E-4B48-A18A-1C869D1BA6F5}.Debug|x64.Build.0 = Debug|Any CPU
518+
{AF329442-B48E-4B48-A18A-1C869D1BA6F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
519+
{AF329442-B48E-4B48-A18A-1C869D1BA6F5}.Release|Any CPU.Build.0 = Release|Any CPU
520+
{AF329442-B48E-4B48-A18A-1C869D1BA6F5}.Release|x64.ActiveCfg = Release|Any CPU
521+
{AF329442-B48E-4B48-A18A-1C869D1BA6F5}.Release|x64.Build.0 = Release|Any CPU
512522
EndGlobalSection
513523
GlobalSection(SolutionProperties) = preSolution
514524
HideSolutionNode = FALSE
@@ -569,6 +579,7 @@ Global
569579
{7DA2DCD0-551B-432E-AA5C-22DDD3ED459B} = {D5293208-2BEF-42FC-A64C-5954F61720BA}
570580
{F812BAAE-5A7D-4DF7-8E71-70696B51C61F} = {E29DC6C4-5E57-48C5-BCB0-6B8F84782749}
571581
{AFD64412-4D6A-452E-82A2-79E5D8842E29} = {E29DC6C4-5E57-48C5-BCB0-6B8F84782749}
582+
{AF329442-B48E-4B48-A18A-1C869D1BA6F5} = {D5293208-2BEF-42FC-A64C-5954F61720BA}
572583
EndGlobalSection
573584
GlobalSection(ExtensibilityGlobals) = postSolution
574585
SolutionGuid = {A9969D89-C98B-40A5-A12B-FC87E55B3A19}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace BotSharp.Abstraction.Statistics.Enums;
22

3-
public static class StatCategory
3+
public static class StatsCategory
44
{
5-
public static string LlmCost = "llm-cost";
5+
public static string AgentLlmCost = "agent-llm-cost";
66
public static string AgentCall = "agent-call";
77
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace BotSharp.Abstraction.Statistics.Enums;
2+
3+
public enum StatsOperation
4+
{
5+
Add = 1,
6+
Subtract = 2,
7+
Reset = 3
8+
}

src/Infrastructure/BotSharp.Abstraction/Statistics/Models/BotSharpStats.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class BotSharpStats
99
public string Group { get; set; } = null!;
1010

1111
[JsonPropertyName("data")]
12-
public IDictionary<string, object> Data { get; set; } = new Dictionary<string, object>();
12+
public IDictionary<string, double> Data { get; set; } = new Dictionary<string, double>();
1313

1414
private DateTime innerRecordTime;
1515

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace BotSharp.Abstraction.Statistics.Models;
2+
3+
public class BotSharpStatsInput
4+
{
5+
public string Category { get; set; }
6+
public string Group { get; set; }
7+
public List<StatsKeyValuePair> Data { get; set; } = [];
8+
public DateTime RecordTime { get; set; }
9+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using BotSharp.Abstraction.Statistics.Enums;
2+
3+
namespace BotSharp.Abstraction.Statistics.Models;
4+
5+
public class StatsKeyValuePair
6+
{
7+
public string Key { get; set; }
8+
public double Value { get; set; }
9+
public StatsOperation Operation { get; set; }
10+
11+
public StatsKeyValuePair()
12+
{
13+
14+
}
15+
16+
public StatsKeyValuePair(string key, double value, StatsOperation operation = StatsOperation.Add)
17+
{
18+
Key = key;
19+
Value = value;
20+
Operation = operation;
21+
}
22+
23+
public override string ToString()
24+
{
25+
return $"[{Key}]: {Value} ({Operation})";
26+
}
27+
}

src/Infrastructure/BotSharp.Abstraction/Statistics/Services/IBotSharpStatService.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using BotSharp.Abstraction.Statistics.Models;
2+
3+
namespace BotSharp.Abstraction.Statistics.Services;
4+
5+
public interface IBotSharpStatsService
6+
{
7+
bool UpdateStats(string resourceKey, BotSharpStatsInput input);
8+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void RegisterDI(IServiceCollection services, IConfiguration config)
3333
services.AddScoped<ILlmProviderService, LlmProviderService>();
3434
services.AddScoped<IAgentService, AgentService>();
3535
services.AddScoped<IAgentHook, BasicAgentHook>();
36-
services.AddScoped<IBotSharpStatService, BotSharpStatService>();
36+
services.AddScoped<IBotSharpStatsService, BotSharpStatsService>();
3737

3838
services.AddScoped(provider =>
3939
{

src/Infrastructure/BotSharp.Core/Conversations/Services/TokenStatistics.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,20 @@ public void AddToken(TokenStatsModel stats, RoleDialogModel message)
5959
stat.SetState("llm_total_cost", total_cost, isNeedVersion: false, source: StateSource.Application);
6060

6161

62-
var globalStats = _services.GetRequiredService<IBotSharpStatService>();
63-
var body = new BotSharpStats
62+
var globalStats = _services.GetRequiredService<IBotSharpStatsService>();
63+
var body = new BotSharpStatsInput
6464
{
65-
Category = StatCategory.LlmCost,
66-
Group = $"Agent: {message.CurrentAgentId}",
67-
Data = new Dictionary<string, object>
68-
{
69-
{ "prompt_token_count_total", stats.PromptCount },
70-
{ "completion_token_count_total", stats.CompletionCount },
71-
{ "prompt_cost_total", deltaPromptCost },
72-
{ "completion_cost_total", deltaCompletionCost }
73-
},
74-
RecordTime = DateTime.UtcNow
65+
Category = StatsCategory.AgentLlmCost,
66+
Group = message.CurrentAgentId,
67+
RecordTime = DateTime.UtcNow,
68+
Data = [
69+
new StatsKeyValuePair("prompt_token_count_total", stats.PromptCount),
70+
new StatsKeyValuePair("completion_token_count_total", stats.CompletionCount),
71+
new StatsKeyValuePair("prompt_cost_total", deltaPromptCost),
72+
new StatsKeyValuePair("completion_cost_total", deltaCompletionCost)
73+
]
7574
};
76-
globalStats.UpdateLlmCost(body);
75+
globalStats.UpdateStats("global-llm-cost", body);
7776
}
7877

7978
public void PrintStatistics()

0 commit comments

Comments
 (0)