From a70dfb0769ed39d9865dea150d4c2fb8681f5dc2 Mon Sep 17 00:00:00 2001 From: ccnetcore Date: Fri, 4 Jul 2025 00:16:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E6=88=90=E8=B7=A8=E5=9F=9F?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/OpenAi/ModelGetOutput.cs | 14 +++++++++ .../Services/OpenApiService.cs | 30 +++++++++++++++++++ Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json | 2 +- 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/OpenAi/ModelGetOutput.cs diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/OpenAi/ModelGetOutput.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/OpenAi/ModelGetOutput.cs new file mode 100644 index 00000000..9c82310e --- /dev/null +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/OpenAi/ModelGetOutput.cs @@ -0,0 +1,14 @@ +namespace Yi.Framework.AiHub.Application.Contracts.Dtos.OpenAiDto; + +public class ModelGetOutput +{ + public List Data { get; set; } +} + +public class ModelDataOutput +{ + public string ModelId { get; set; } + public string Object { get; set; } + public string Owned_by { get; set; } + public List Permission { get; set; } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/OpenApiService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/OpenApiService.cs index 5444a3b8..f2b6e485 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/OpenApiService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/OpenApiService.cs @@ -167,6 +167,36 @@ public class OpenApiService : ApplicationService tokenUsage.OutputTokenCount); } + /// + /// 获取模型列表 + /// + /// + [HttpGet("openApi/v1/models")] + public async Task ModelsAsync() + { + return new ModelGetOutput() + { + Data = new List() + { + new ModelDataOutput + { + ModelId = "gpt-4.1-mini", + Object = "model", + Owned_by = "organization-owner", + Permission = new List() + }, + new ModelDataOutput + { + ModelId = "gpt-4.1-nano", + Object = "model", + Owned_by = "organization-owner", + Permission = new List() + } + } + }; + + } + private SendMessageOutputDto MapToMessage(string modelId, string content) { var output = new SendMessageOutputDto diff --git a/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json b/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json index e79c2086..41ad6324 100644 --- a/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json +++ b/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json @@ -21,7 +21,7 @@ //应用启动 "App": { "SelfUrl": "http://*:19001", - "CorsOrigins": "http://localhost:19001;http://localhost:18000" + "CorsOrigins": "http://localhost:19001;http://localhost:18000;vscode-file://vscode-app" }, //配置 "Settings": {