feat: 支持多ai聊天

This commit is contained in:
橙子
2025-02-02 00:22:27 +08:00
parent 0e90c54dbb
commit 25929483c3
5 changed files with 331 additions and 353 deletions

View File

@@ -24,19 +24,8 @@ namespace Yi.Framework.ChatHub.Domain.Managers
}
private OpenAIService OpenAIService { get; }
public async IAsyncEnumerable<string> ChatAsStreamAsync(List<AiChatContextDto> aiChatContextDtos)
public async IAsyncEnumerable<string> ChatAsStreamAsync(string model, List<AiChatContextDto> 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;