feat: 全面支持deepseek

This commit is contained in:
橙子
2025-02-03 01:18:15 +08:00
parent 25929483c3
commit 9a73789788
6 changed files with 214 additions and 194 deletions

View File

@@ -41,7 +41,7 @@ namespace Yi.Framework.ChatHub.Application.Services
var str = stringQueue.Dequeue();
currentStr.Append(str);
}
await _userMessageManager.SendMessageAsync(MessageContext.CreateAi(currentStr.ToString(), CurrentUser.Id!.Value, contextId));
await _userMessageManager.SendMessageAsync(MessageContext.CreateAi(currentStr.ToString(), CurrentUser.Id!.Value, contextId),model);
}
}
@@ -51,7 +51,7 @@ namespace Yi.Framework.ChatHub.Application.Services
var str = stringQueue.Dequeue();
currentEndStr.Append(str);
}
await _userMessageManager.SendMessageAsync(MessageContext.CreateAi(currentEndStr.ToString(), CurrentUser.Id!.Value, contextId));
await _userMessageManager.SendMessageAsync(MessageContext.CreateAi(currentEndStr.ToString(), CurrentUser.Id!.Value, contextId),model);
}
}
}

View File

@@ -31,7 +31,14 @@ namespace Yi.Framework.ChatHub.Domain.Managers
private IRedisClient RedisClient => LazyServiceProvider.LazyGetRequiredService<IRedisClient>();
private string CacheKeyPrefix => LazyServiceProvider.LazyGetRequiredService<IOptions<AbpDistributedCacheOptions>>().Value.KeyPrefix;
public async Task SendMessageAsync(MessageContext context)
/// <summary>
/// 发送消息
/// </summary>
/// <param name="context">消息内容</param>
/// <param name="relStr">关联字符</param>
/// <exception cref="NotImplementedException"></exception>
public async Task SendMessageAsync(MessageContext context,string relStr=null)
{
switch (context.MessageType)
{
@@ -39,20 +46,20 @@ namespace Yi.Framework.ChatHub.Domain.Managers
var userModel = await GetUserAsync(context.ReceiveId.Value);
if (userModel is not null)
{
await _hubContext.Clients.Client(userModel.ClientId).SendAsync(ChatConst.ClientActionReceiveMsg, context.MessageType, context);
await _hubContext.Clients.Client(userModel.ClientId).SendAsync(ChatConst.ClientActionReceiveMsg, context.MessageType,relStr, context);
}
break;
case MessageTypeEnum.Group:
throw new NotImplementedException();
break;
case MessageTypeEnum.All:
await _hubContext.Clients.All.SendAsync(ChatConst.ClientActionReceiveMsg, context.MessageType, context);
await _hubContext.Clients.All.SendAsync(ChatConst.ClientActionReceiveMsg, context.MessageType,relStr, context);
break;
case MessageTypeEnum.Ai:
var userModel2 = await GetUserAsync(context.ReceiveId.Value);
if (userModel2 is not null)
{
await _hubContext.Clients.Client(userModel2.ClientId).SendAsync(ChatConst.ClientActionReceiveMsg, context.MessageType, context);
await _hubContext.Clients.Client(userModel2.ClientId).SendAsync(ChatConst.ClientActionReceiveMsg, context.MessageType,relStr, context);
}
break;