add confidence

This commit is contained in:
Jicheng Lu 2025-02-25 11:56:37 -06:00
parent 899f03feee
commit 80fc2f6c78
5 changed files with 18 additions and 4 deletions

View file

@ -6,16 +6,22 @@ public class AgentKnowledgeBase
public string Type { get; set; }
public bool Disabled { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public decimal? Confidence { get; set; }
public AgentKnowledgeBase()
{
}
public AgentKnowledgeBase(string name, string type, bool enabled)
public AgentKnowledgeBase(
string name, string type,
bool enabled, decimal? confidence = null)
{
Name = name;
Type = type;
Disabled = enabled;
Confidence = confidence;
}
public override string ToString()

View file

@ -4,6 +4,7 @@ public class ConversationDialogDocument : MongoBase
{
public string ConversationId { get; set; } = default!;
public string AgentId { get; set; } = default!;
public string UserId { get; set; } = default!;
public DateTime UpdatedTime { get; set; }
public List<DialogMongoElement> Dialogs { get; set; } = [];
}

View file

@ -4,6 +4,7 @@ public class ConversationStateDocument : MongoBase
{
public string ConversationId { get; set; } = default!;
public string AgentId { get; set; } = default!;
public string UserId { get; set; } = default!;
public DateTime UpdatedTime { get; set; }
public List<StateMongoElement> States { get; set; } = [];
public List<BreakpointMongoElement> Breakpoints { get; set; } = [];

View file

@ -8,6 +8,7 @@ public class AgentKnowledgeBaseMongoElement
public string Name { get; set; } = default!;
public string Type { get; set; } = default!;
public bool Disabled { get; set; }
public decimal? Confidence { get; set; }
public static AgentKnowledgeBaseMongoElement ToMongoElement(AgentKnowledgeBase knowledgeBase)
{
@ -15,7 +16,8 @@ public class AgentKnowledgeBaseMongoElement
{
Name = knowledgeBase.Name,
Type = knowledgeBase.Type,
Disabled = knowledgeBase.Disabled
Disabled = knowledgeBase.Disabled,
Confidence = knowledgeBase.Confidence
};
}
@ -25,7 +27,8 @@ public class AgentKnowledgeBaseMongoElement
{
Name = knowledgeBase.Name,
Type = knowledgeBase.Type,
Disabled = knowledgeBase.Disabled
Disabled = knowledgeBase.Disabled,
Confidence = knowledgeBase.Confidence
};
}
}

View file

@ -10,11 +10,12 @@ public partial class MongoRepository
if (conversation == null) return;
var utcNow = DateTime.UtcNow;
var userId = !string.IsNullOrEmpty(conversation.UserId) ? conversation.UserId : string.Empty;
var convDoc = new ConversationDocument
{
Id = !string.IsNullOrEmpty(conversation.Id) ? conversation.Id : Guid.NewGuid().ToString(),
AgentId = conversation.AgentId,
UserId = !string.IsNullOrEmpty(conversation.UserId) ? conversation.UserId : string.Empty,
UserId = userId,
Title = conversation.Title,
Channel = conversation.Channel,
ChannelId = conversation.ChannelId,
@ -30,6 +31,7 @@ public partial class MongoRepository
Id = Guid.NewGuid().ToString(),
ConversationId = convDoc.Id,
AgentId = conversation.AgentId,
UserId = userId,
Dialogs = [],
UpdatedTime = utcNow
};
@ -39,6 +41,7 @@ public partial class MongoRepository
Id = Guid.NewGuid().ToString(),
ConversationId = convDoc.Id,
AgentId = conversation.AgentId,
UserId = userId,
States = [],
Breakpoints = [],
UpdatedTime = utcNow