Merge pull request #895 from iceljc/features/refine-llm-completion-log
refine llm completion log
This commit is contained in:
commit
8a18780f83
|
|
@ -7,5 +7,5 @@ public class LlmCompletionLog
|
||||||
public string AgentId { get; set; } = string.Empty;
|
public string AgentId { get; set; } = string.Empty;
|
||||||
public string Prompt { get; set; } = string.Empty;
|
public string Prompt { get; set; } = string.Empty;
|
||||||
public string? Response { get; set; }
|
public string? Response { get; set; }
|
||||||
public DateTime CreateDateTime { get; set; } = DateTime.UtcNow;
|
public DateTime CreatedTime { get; set; } = DateTime.UtcNow;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ public class CommonContentGeneratingHook : IContentGeneratingHook
|
||||||
AgentId = message.CurrentAgentId,
|
AgentId = message.CurrentAgentId,
|
||||||
Prompt = tokenStats.Prompt,
|
Prompt = tokenStats.Prompt,
|
||||||
Response = message.Content,
|
Response = message.Content,
|
||||||
CreateDateTime = DateTime.UtcNow
|
CreatedTime = DateTime.UtcNow
|
||||||
};
|
};
|
||||||
|
|
||||||
db.SaveLlmCompletionLog(completionLog);
|
db.SaveLlmCompletionLog(completionLog);
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,9 @@ namespace BotSharp.Plugin.MongoStorage.Collections;
|
||||||
public class LlmCompletionLogDocument : MongoBase
|
public class LlmCompletionLogDocument : MongoBase
|
||||||
{
|
{
|
||||||
public string ConversationId { get; set; } = default!;
|
public string ConversationId { get; set; } = default!;
|
||||||
public List<PromptLogMongoElement> Logs { get; set; } = [];
|
public string MessageId { get; set; } = default!;
|
||||||
|
public string AgentId { get; set; } = default!;
|
||||||
|
public string Prompt { get; set; } = default!;
|
||||||
|
public string? Response { get; set; }
|
||||||
|
public DateTime CreatedTime { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
namespace BotSharp.Plugin.MongoStorage.Models;
|
|
||||||
|
|
||||||
[BsonIgnoreExtraElements(Inherited = true)]
|
|
||||||
public class PromptLogMongoElement
|
|
||||||
{
|
|
||||||
public string MessageId { get; set; } = default!;
|
|
||||||
public string AgentId { get; set; } = default!;
|
|
||||||
public string Prompt { get; set; } = default!;
|
|
||||||
public string? Response { get; set; }
|
|
||||||
public DateTime CreateDateTime { get; set; }
|
|
||||||
}
|
|
||||||
|
|
@ -12,21 +12,17 @@ public partial class MongoRepository
|
||||||
var conversationId = log.ConversationId.IfNullOrEmptyAs(Guid.NewGuid().ToString());
|
var conversationId = log.ConversationId.IfNullOrEmptyAs(Guid.NewGuid().ToString());
|
||||||
var messageId = log.MessageId.IfNullOrEmptyAs(Guid.NewGuid().ToString());
|
var messageId = log.MessageId.IfNullOrEmptyAs(Guid.NewGuid().ToString());
|
||||||
|
|
||||||
var logElement = new PromptLogMongoElement
|
var data = new LlmCompletionLogDocument
|
||||||
{
|
{
|
||||||
|
Id = Guid.NewGuid().ToString(),
|
||||||
|
ConversationId = conversationId,
|
||||||
MessageId = messageId,
|
MessageId = messageId,
|
||||||
AgentId = log.AgentId,
|
AgentId = log.AgentId,
|
||||||
Prompt = log.Prompt,
|
Prompt = log.Prompt,
|
||||||
Response = log.Response,
|
Response = log.Response,
|
||||||
CreateDateTime = log.CreateDateTime
|
CreatedTime = log.CreatedTime
|
||||||
};
|
};
|
||||||
|
_dc.LlmCompletionLogs.InsertOne(data);
|
||||||
var filter = Builders<LlmCompletionLogDocument>.Filter.Eq(x => x.ConversationId, conversationId);
|
|
||||||
var update = Builders<LlmCompletionLogDocument>.Update
|
|
||||||
.SetOnInsert(x => x.Id, Guid.NewGuid().ToString())
|
|
||||||
.Push(x => x.Logs, logElement);
|
|
||||||
|
|
||||||
_dc.LlmCompletionLogs.UpdateOne(filter, update, _options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue