Add TaskId to conversation.
This commit is contained in:
parent
1b559f75be
commit
596a83655e
|
|
@ -7,6 +7,11 @@ public class Conversation
|
|||
public string Id { get; set; } = string.Empty;
|
||||
public string AgentId { get; set; } = string.Empty;
|
||||
public string UserId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Agent task id
|
||||
/// </summary>
|
||||
public string? TaskId { get; set; }
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
[JsonIgnore]
|
||||
|
|
|
|||
|
|
@ -29,4 +29,9 @@ public class MessageConfig : TruncateMessageRequest
|
|||
/// Conversation states from input
|
||||
/// </summary>
|
||||
public List<string> States { get; set; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Agent task id
|
||||
/// </summary>
|
||||
public string? TaskId { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,4 +11,9 @@ public class ConversationFilter
|
|||
public string? Status { get; set; }
|
||||
public string? Channel { get; set; }
|
||||
public string? UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Agent task id
|
||||
/// </summary>
|
||||
public string? TaskId { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -223,6 +223,7 @@ namespace BotSharp.Core.Repository
|
|||
if (filter?.Status != null) matched = matched && record.Status == filter.Status;
|
||||
if (filter?.Channel != null) matched = matched && record.Channel == filter.Channel;
|
||||
if (filter?.UserId != null) matched = matched && record.UserId == filter.UserId;
|
||||
if (filter?.TaskId != null) matched = matched && record.TaskId == filter.TaskId;
|
||||
|
||||
if (!matched) continue;
|
||||
records.Add(record);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,8 @@ public class ConversationController : ControllerBase
|
|||
{
|
||||
AgentId = agentId,
|
||||
Channel = ConversationChannel.OpenAPI,
|
||||
UserId = _user.Id
|
||||
UserId = _user.Id,
|
||||
TaskId = config.TaskId
|
||||
};
|
||||
conv = await service.NewConversation(conv);
|
||||
service.SetConversationId(conv.Id, config.States);
|
||||
|
|
@ -50,7 +51,7 @@ public class ConversationController : ControllerBase
|
|||
item.User = UserViewModel.FromUser(user);
|
||||
|
||||
var agent = await agentService.GetAgent(item.AgentId);
|
||||
item.AgentName = agent.Name;
|
||||
item.AgentName = agent?.Name;
|
||||
}
|
||||
|
||||
return new PagedItems<ConversationViewModel>
|
||||
|
|
|
|||
|
|
@ -19,6 +19,13 @@ public class ConversationViewModel
|
|||
public string Event { get; set; }
|
||||
|
||||
public string Channel { get; set; } = ConversationChannel.OpenAPI;
|
||||
|
||||
/// <summary>
|
||||
/// Agent task id
|
||||
/// </summary>
|
||||
[JsonPropertyName("task_id")]
|
||||
public string? TaskId { get; set; }
|
||||
|
||||
public string Status { get; set; }
|
||||
public Dictionary<string, string> States { get; set; }
|
||||
|
||||
|
|
@ -40,6 +47,7 @@ public class ConversationViewModel
|
|||
Title = sess.Title,
|
||||
Channel = sess.Channel,
|
||||
Status = sess.Status,
|
||||
TaskId = sess.TaskId,
|
||||
CreatedTime = sess.CreatedTime,
|
||||
UpdatedTime = sess.UpdatedTime
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ public class ConversationDocument : MongoBase
|
|||
{
|
||||
public string AgentId { get; set; }
|
||||
public string UserId { get; set; }
|
||||
public string? TaskId { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Channel { get; set; }
|
||||
public string Status { get; set; }
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ public partial class MongoRepository
|
|||
UserId = !string.IsNullOrEmpty(conversation.UserId) ? conversation.UserId : string.Empty,
|
||||
Title = conversation.Title,
|
||||
Channel = conversation.Channel,
|
||||
TaskId = conversation.TaskId,
|
||||
Status = conversation.Status,
|
||||
CreatedTime = DateTime.UtcNow,
|
||||
UpdatedTime = DateTime.UtcNow,
|
||||
|
|
@ -215,6 +216,7 @@ public partial class MongoRepository
|
|||
if (!string.IsNullOrEmpty(filter.Status)) filters.Add(builder.Eq(x => x.Status, filter.Status));
|
||||
if (!string.IsNullOrEmpty(filter.Channel)) filters.Add(builder.Eq(x => x.Channel, filter.Channel));
|
||||
if (!string.IsNullOrEmpty(filter.UserId)) filters.Add(builder.Eq(x => x.UserId, filter.UserId));
|
||||
if (!string.IsNullOrEmpty(filter.TaskId)) filters.Add(builder.Eq(x => x.TaskId, filter.TaskId));
|
||||
|
||||
var filterDef = builder.And(filters);
|
||||
var sortDef = Builders<ConversationDocument>.Sort.Descending(x => x.CreatedTime);
|
||||
|
|
@ -230,6 +232,7 @@ public partial class MongoRepository
|
|||
Id = convId,
|
||||
AgentId = conv.AgentId.ToString(),
|
||||
UserId = conv.UserId.ToString(),
|
||||
TaskId = conv.TaskId,
|
||||
Title = conv.Title,
|
||||
Channel = conv.Channel,
|
||||
Status = conv.Status,
|
||||
|
|
|
|||
Loading…
Reference in a new issue