diff --git a/Yi.Abp.Net8/module/chat-hub/Yi.Framework.ChatHub.Application/Services/AiChatService.cs b/Yi.Abp.Net8/module/chat-hub/Yi.Framework.ChatHub.Application/Services/AiChatService.cs index 8604ab46..f16d371e 100644 --- a/Yi.Abp.Net8/module/chat-hub/Yi.Framework.ChatHub.Application/Services/AiChatService.cs +++ b/Yi.Abp.Net8/module/chat-hub/Yi.Framework.ChatHub.Application/Services/AiChatService.cs @@ -23,14 +23,13 @@ namespace Yi.Framework.ChatHub.Application.Services /// /// [Authorize] - [HttpPost] - - public async Task ChatAsync([FromBody] List chatContext) + [HttpPost("ai-chat/chat/{model}")] + public async Task ChatAsync([FromRoute]string model, [FromBody] List chatContext) { const int maxChar = 10; var contextId = Guid.NewGuid(); Queue stringQueue = new Queue(); - await foreach (var aiResult in _aiManager.ChatAsStreamAsync(chatContext)) + await foreach (var aiResult in _aiManager.ChatAsStreamAsync(model,chatContext)) { stringQueue.Enqueue(aiResult); @@ -53,8 +52,6 @@ namespace Yi.Framework.ChatHub.Application.Services currentEndStr.Append(str); } await _userMessageManager.SendMessageAsync(MessageContext.CreateAi(currentEndStr.ToString(), CurrentUser.Id!.Value, contextId)); - - //await _userMessageManager.SendMessageAsync(MessageContext.CreateAi(null, CurrentUser.Id!.Value, contextId)); } } } diff --git a/Yi.Abp.Net8/module/chat-hub/Yi.Framework.ChatHub.Domain/Managers/AiManager.cs b/Yi.Abp.Net8/module/chat-hub/Yi.Framework.ChatHub.Domain/Managers/AiManager.cs index ddc81fd3..a8571f2b 100644 --- a/Yi.Abp.Net8/module/chat-hub/Yi.Framework.ChatHub.Domain/Managers/AiManager.cs +++ b/Yi.Abp.Net8/module/chat-hub/Yi.Framework.ChatHub.Domain/Managers/AiManager.cs @@ -24,19 +24,8 @@ namespace Yi.Framework.ChatHub.Domain.Managers } private OpenAIService OpenAIService { get; } - public async IAsyncEnumerable ChatAsStreamAsync(List aiChatContextDtos) + public async IAsyncEnumerable ChatAsStreamAsync(string model, List aiChatContextDtos) { - //var temp = "站长正在接入ChatGpt,敬请期待~"; - - //for (var i = 0; i < temp.Length; i++) - //{ - // await Task.Delay(200); - // yield return temp[i].ToString(); - //} - - - - if (aiChatContextDtos.Count == 0) { yield return null; @@ -56,7 +45,7 @@ namespace Yi.Framework.ChatHub.Domain.Managers var completionResult = OpenAIService.ChatCompletion.CreateCompletionAsStream(new ChatCompletionCreateRequest { Messages = messages, - Model = Models.Gpt_4o_mini + Model =model }); HttpStatusCode? error = null; diff --git a/Yi.Bbs.Vue3/src/assets/chat_images/deepSeekAi.png b/Yi.Bbs.Vue3/src/assets/chat_images/deepSeekAi.png new file mode 100644 index 00000000..aa2fa513 Binary files /dev/null and b/Yi.Bbs.Vue3/src/assets/chat_images/deepSeekAi.png differ diff --git a/Yi.Bbs.Vue3/public/openAi.png b/Yi.Bbs.Vue3/src/assets/chat_images/openAi.png similarity index 100% rename from Yi.Bbs.Vue3/public/openAi.png rename to Yi.Bbs.Vue3/src/assets/chat_images/openAi.png diff --git a/Yi.Bbs.Vue3/src/views/chathub/Index.vue b/Yi.Bbs.Vue3/src/views/chathub/Index.vue index 3a7d4d26..e2b422e2 100644 --- a/Yi.Bbs.Vue3/src/views/chathub/Index.vue +++ b/Yi.Bbs.Vue3/src/views/chathub/Index.vue @@ -1,26 +1,32 @@