Skip to content

Commit b99a158

Browse files
author
Jicheng Lu
committed
move log setting to conversation
1 parent 929487c commit b99a158

File tree

5 files changed

+6
-28
lines changed

5 files changed

+6
-28
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ public class ConversationSetting
77
public bool EnableKnowledgeBase { get; set; }
88
public bool ShowVerboseLog { get; set; }
99
public int MaxRecursiveDepth { get; set; } = 3;
10+
public bool EnableLlmCompletionLog { get; set; }
11+
public bool EnableExecutionLog { get; set; }
1012
}

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ public class BotSharpDatabaseSettings : DatabaseBasicSettings
66
public string FileRepository { get; set; }
77
public string BotSharpMongoDb { get; set; }
88
public string TablePrefix { get; set; }
9-
public BotSharpLogSetting Log { get; set; }
109
public DbConnectionSetting BotSharp { get; set; }
1110
}
1211

@@ -30,9 +29,3 @@ public DbConnectionSetting()
3029
Slavers = new string[0];
3130
}
3231
}
33-
34-
public class BotSharpLogSetting
35-
{
36-
public bool EnableLlmCompletionLog { get; set; }
37-
public bool EnableExecutionLog { get; set; }
38-
}

src/Infrastructure/BotSharp.Core/Repository/FileRepository.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -817,9 +817,6 @@ public void CreateUser(User user)
817817
#region Execution Log
818818
public void AddExecutionLogs(string conversationId, List<string> logs)
819819
{
820-
var isEnabled = _dbSettings.Log.EnableExecutionLog;
821-
if (!isEnabled) return;
822-
823820
if (string.IsNullOrEmpty(conversationId) || logs.IsNullOrEmpty()) return;
824821

825822
var dir = Path.Combine(_dbSettings.FileRepository, "conversations", conversationId);
@@ -849,9 +846,6 @@ public List<string> GetExecutionLogs(string conversationId)
849846
#region LLM Completion Log
850847
public void SaveLlmCompletionLog(LlmCompletionLog log)
851848
{
852-
var isEnabled = _dbSettings.Log.EnableLlmCompletionLog;
853-
if (!isEnabled) return;
854-
855849
var convDir = FindConversationDirectory(log.ConversationId);
856850
if (!Directory.Exists(convDir)) return;
857851

src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,19 @@
44
using BotSharp.Abstraction.Repositories.Filters;
55
using BotSharp.Abstraction.Routing.Models;
66
using BotSharp.Abstraction.Users.Models;
7-
using BotSharp.Abstraction.Utilities;
87
using BotSharp.Plugin.MongoStorage.Collections;
98
using BotSharp.Plugin.MongoStorage.Models;
109

1110
namespace BotSharp.Plugin.MongoStorage.Repository;
1211

1312
public class MongoRepository : IBotSharpRepository
1413
{
15-
private readonly BotSharpDatabaseSettings _dbSettings;
1614
private readonly MongoDbContext _dc;
1715
private readonly IServiceProvider _services;
1816
private UpdateOptions _options;
1917

20-
public MongoRepository(BotSharpDatabaseSettings dbSettings, MongoDbContext dc, IServiceProvider services)
18+
public MongoRepository(MongoDbContext dc, IServiceProvider services)
2119
{
22-
_dbSettings = dbSettings;
2320
_dc = dc;
2421
_services = services;
2522
_options = new UpdateOptions
@@ -844,9 +841,6 @@ public void CreateUser(User user)
844841
#region Execution Log
845842
public void AddExecutionLogs(string conversationId, List<string> logs)
846843
{
847-
var isEnabled = _dbSettings.Log.EnableExecutionLog;
848-
if (!isEnabled) return;
849-
850844
if (string.IsNullOrEmpty(conversationId) || logs.IsNullOrEmpty()) return;
851845

852846
var filter = Builders<ExectionLogCollection>.Filter.Eq(x => x.ConversationId, conversationId);
@@ -873,9 +867,6 @@ public List<string> GetExecutionLogs(string conversationId)
873867
#region LLM Completion Log
874868
public void SaveLlmCompletionLog(LlmCompletionLog log)
875869
{
876-
var isEnabled = _dbSettings.Log.EnableLlmCompletionLog;
877-
if (!isEnabled) return;
878-
879870
var completiongLog = new LlmCompletionLogCollection
880871
{
881872
Id = string.IsNullOrEmpty(log.Id) ? Guid.NewGuid().ToString() : log.Id,

src/WebStarter/appsettings.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434

3535
"Conversation": {
3636
"DataDir": "conversations",
37-
"ShowVerboseLog": false
37+
"ShowVerboseLog": false,
38+
"EnableLlmCompletionLog": false,
39+
"EnableExecutionLog": true
3840
},
3941

4042
"LlamaSharp": {
@@ -104,10 +106,6 @@
104106
"Master": "Data Source=(localdb)\\ProjectModels;Initial Catalog=BotSharp;Integrated Security=True;Connect Timeout=30;Encrypt=False;Trust Server Certificate=False;Application Intent=ReadWrite;Multi Subnet Failover=False",
105107
"Slavers": []
106108
},
107-
"Log": {
108-
"EnableLlmCompletionLog": false,
109-
"EnableExecutionLog": true
110-
},
111109
"FileRepository": "data",
112110
"UseCamelCase": true,
113111
"Assemblies": [ "BotSharp.Core" ]

0 commit comments

Comments
 (0)