diff --git a/src/Infrastructure/BotSharp.Abstraction/Instructs/Models/InstructResponseModel.cs b/src/Infrastructure/BotSharp.Abstraction/Instructs/Models/InstructResponseModel.cs index 62752bf4..42287b10 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Instructs/Models/InstructResponseModel.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Instructs/Models/InstructResponseModel.cs @@ -9,4 +9,5 @@ public class InstructResponseModel public string UserMessage { get; set; } = default!; public string? SystemInstruction { get; set; } public string CompletionText { get; set; } = default!; + public string LogId { get; set; } = default!; } diff --git a/src/Infrastructure/BotSharp.Abstraction/Instructs/Models/InstructResult.cs b/src/Infrastructure/BotSharp.Abstraction/Instructs/Models/InstructResult.cs index efaf4ffd..cfdd68aa 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Instructs/Models/InstructResult.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Instructs/Models/InstructResult.cs @@ -10,4 +10,7 @@ public class InstructResult : ITrackableMessage [JsonPropertyName("template")] public string? Template { get; set; } public Dictionary? States { get; set; } = new(); + + [JsonPropertyName("log_id")] + public string LogId { get; set; } = default!; } diff --git a/src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Execute.cs b/src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Execute.cs index f869ce35..1e6252d6 100644 --- a/src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Execute.cs +++ b/src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Execute.cs @@ -128,12 +128,14 @@ public partial class InstructService response.Text = result; } + response.LogId = Guid.NewGuid().ToString(); // After completion hooks foreach (var hook in hooks) { await hook.AfterCompletion(agent, response); await hook.OnResponseGenerated(new InstructResponseModel { + LogId = response.LogId, AgentId = agentId, Provider = provider, Model = model, diff --git a/src/Infrastructure/BotSharp.Logger/Hooks/InstructionLogHook.cs b/src/Infrastructure/BotSharp.Logger/Hooks/InstructionLogHook.cs index c95af0c1..484e82a8 100644 --- a/src/Infrastructure/BotSharp.Logger/Hooks/InstructionLogHook.cs +++ b/src/Infrastructure/BotSharp.Logger/Hooks/InstructionLogHook.cs @@ -48,6 +48,7 @@ public class InstructionLogHook : InstructHookBase { new InstructionLogModel { + Id = response.LogId, AgentId = response.AgentId, Provider = response.Provider, Model = response.Model, diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/InstructionLogDocument.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/InstructionLogDocument.cs index 91bcdc68..0796959b 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/InstructionLogDocument.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/InstructionLogDocument.cs @@ -19,6 +19,7 @@ public class InstructionLogDocument : MongoBase { return new InstructionLogDocument { + Id = log.Id, AgentId = log.AgentId, Provider = log.Provider, Model = log.Model,