feat: 完成ai message、session搭建
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Domain.Entities.Auditing;
|
||||
|
||||
namespace Yi.Framework.AiHub.Domain.Entities;
|
||||
|
||||
[SugarTable("Ai_Message")]
|
||||
[SugarIndex($"index_{{table}}_{nameof(UserId)}", $"{nameof(UserId)}", OrderByType.Asc)]
|
||||
public class MessageAggregateRoot : FullAuditedAggregateRoot<Guid>
|
||||
{
|
||||
public MessageAggregateRoot()
|
||||
{
|
||||
}
|
||||
|
||||
public MessageAggregateRoot(Guid userId, Guid sessionId, string content, string role, string modelId)
|
||||
{
|
||||
UserId = userId;
|
||||
SessionId = sessionId;
|
||||
Content = content;
|
||||
Role = role;
|
||||
ModelId = modelId;
|
||||
}
|
||||
|
||||
public Guid UserId { get; set; }
|
||||
public Guid SessionId { get; set; }
|
||||
public string Content { get; set; }
|
||||
public string Role { get; set; }
|
||||
public decimal DeductCost { get; set; }
|
||||
public decimal TotalTokens { get; set; }
|
||||
public string ModelId { get; set; }
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Domain.Entities.Auditing;
|
||||
|
||||
namespace Yi.Framework.AiHub.Domain.Entities;
|
||||
|
||||
[SugarTable("Ai_Session")]
|
||||
[SugarIndex($"index_{{table}}_{nameof(UserId)}",$"{nameof(UserId)}", OrderByType.Asc)]
|
||||
public class SessionAggregateRoot : FullAuditedAggregateRoot<Guid>
|
||||
{
|
||||
public Guid UserId { get; set; }
|
||||
public string SessionTitle { get; set; }
|
||||
public string SessionContent { get; set; }
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using Volo.Abp.Domain.Services;
|
||||
using Volo.Abp.Users;
|
||||
using Yi.Framework.AiHub.Application.Contracts.Dtos;
|
||||
using Yi.Framework.AiHub.Domain.Entities;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.AiHub.Domain.Managers;
|
||||
|
||||
public class AiMessageManager : DomainService
|
||||
{
|
||||
private readonly ISqlSugarRepository<MessageAggregateRoot> _repository;
|
||||
|
||||
public AiMessageManager(ISqlSugarRepository<MessageAggregateRoot> repository)
|
||||
{
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建消息
|
||||
/// </summary>
|
||||
/// <param name="sessionId"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task CreateMessageAsync(Guid userId, Guid sessionId, MessageInputDto input)
|
||||
{
|
||||
var message = new MessageAggregateRoot(userId, sessionId, input.Content, input.Role, input.ModelId);
|
||||
await _repository.InsertAsync(message);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user