feat: 完成跨域处理

This commit is contained in:
ccnetcore
2025-07-04 00:16:58 +08:00
parent c637d412e6
commit a70dfb0769
3 changed files with 45 additions and 1 deletions

View File

@@ -0,0 +1,14 @@
namespace Yi.Framework.AiHub.Application.Contracts.Dtos.OpenAiDto;
public class ModelGetOutput
{
public List<ModelDataOutput> Data { get; set; }
}
public class ModelDataOutput
{
public string ModelId { get; set; }
public string Object { get; set; }
public string Owned_by { get; set; }
public List<string> Permission { get; set; }
}

View File

@@ -167,6 +167,36 @@ public class OpenApiService : ApplicationService
tokenUsage.OutputTokenCount);
}
/// <summary>
/// 获取模型列表
/// </summary>
/// <returns></returns>
[HttpGet("openApi/v1/models")]
public async Task<ModelGetOutput> ModelsAsync()
{
return new ModelGetOutput()
{
Data = new List<ModelDataOutput>()
{
new ModelDataOutput
{
ModelId = "gpt-4.1-mini",
Object = "model",
Owned_by = "organization-owner",
Permission = new List<string>()
},
new ModelDataOutput
{
ModelId = "gpt-4.1-nano",
Object = "model",
Owned_by = "organization-owner",
Permission = new List<string>()
}
}
};
}
private SendMessageOutputDto MapToMessage(string modelId, string content)
{
var output = new SendMessageOutputDto

View File

@@ -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": {