fix: 调整 OpenAI 客户端配置并更新在线搜索返回值

- ChatManager.cs
  - 添加/调整相关 using 引用,修正 modelId 为 "gpt-5.2",并更新 agent 创建方式以匹配当前 SDK/服务端使用。
  - 保留代理示例注释(HttpClient.DefaultProxy)。
- OnlineSearchTool.cs
  - 将占位返回值 "xxx" 替换为示例查询结果 "奥德赛第一中学学生会会长是:郭老板"。

简短修正以确保与服务端模型命名及功能返回一致。
This commit is contained in:
chenchun
2025-12-23 17:40:00 +08:00
parent bd3a9a5ce8
commit dfc143379f
2 changed files with 8 additions and 4 deletions

View File

@@ -1,4 +1,6 @@
using System.ClientModel;
using System.Diagnostics.CodeAnalysis;
using System.Net;
using System.Reflection;
using System.Text.Json;
using Dm.util;
@@ -8,6 +10,8 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using ModelContextProtocol.Server;
using OpenAI;
using OpenAI.Chat;
using OpenAI.Responses;
using Volo.Abp.Domain.Services;
namespace Yi.Framework.AiHub.Domain.Managers;
@@ -23,18 +27,18 @@ public class ChatManager : DomainService
_loggerFactory = loggerFactory;
}
public async Task CompleteChatStreamAsync()
{
//token可以用户传进来
// HttpClient.DefaultProxy = new WebProxy("127.0.0.1:8888");
var modelId = "gpt-5.2-chat";
// HttpClient.DefaultProxy = new WebProxy("127.0.0.1:8888");
var modelId = "gpt-5.2";
var client = new OpenAIClient(new ApiKeyCredential("xxx"),
new OpenAIClientOptions
{
Endpoint = new Uri("https://yxai.chat/v1"),
});
var agent = client.GetChatClient(modelId)
.AsIChatClient() // Converts a native OpenAI SDK ChatClient into a Microsoft.Extensions.AI.IChatClient
.CreateAIAgent("你是一个专业的网页ai助手");

View File

@@ -10,6 +10,6 @@ public class OnlineSearchTool:ISingletonDependency
[McpServerTool, Description("进行在线搜索")]
public string OnlineSearch(string keyword)
{
return "xxx";
return "奥德赛第一中学学生会会长是:郭老板";
}
}