feat: 重构完成

This commit is contained in:
ccnetcore
2025-07-17 23:16:16 +08:00
parent e593f2cba4
commit c5b0f69b51
5 changed files with 14 additions and 8 deletions

View File

@@ -46,8 +46,7 @@ public class AiModelDescribe
/// 模型描述 /// 模型描述
/// </summary> /// </summary>
public string? Description { get; set; } public string? Description { get; set; }
/// <summary> /// <summary>
/// 额外url /// 额外url
/// </summary> /// </summary>

View File

@@ -20,6 +20,11 @@ public class AiAppAggregateRoot : FullAuditedAggregateRoot<Guid>, IOrderNum
/// </summary> /// </summary>
public string Endpoint { get; set; } public string Endpoint { get; set; }
/// <summary>
/// 额外url
/// </summary>
public string? ExtraUrl { get; set; }
/// <summary> /// <summary>
/// 应用key /// 应用key
/// </summary> /// </summary>

View File

@@ -44,4 +44,5 @@ public class AiModelEntity : Entity<Guid>, IOrderNum,ISoftDelete
/// ai应用id /// ai应用id
/// </summary> /// </summary>
public Guid AiAppId { get; set; } public Guid AiAppId { get; set; }
} }

View File

@@ -55,7 +55,8 @@ public class AiGateWayManager : DomainService
HandlerName = model.HandlerName, HandlerName = model.HandlerName,
ModelId = model.ModelId, ModelId = model.ModelId,
ModelName = model.Name, ModelName = model.Name,
Description = model.Description Description = model.Description,
ExtraUrl = app.ExtraUrl
}; };
} }
} }
@@ -75,7 +76,8 @@ public class AiGateWayManager : DomainService
[EnumeratorCancellation] CancellationToken cancellationToken) [EnumeratorCancellation] CancellationToken cancellationToken)
{ {
var modelDescribe = await GetModelAsync(request.Model); var modelDescribe = await GetModelAsync(request.Model);
var chatService = LazyServiceProvider.GetRequiredKeyedService<IChatCompletionService>(modelDescribe.HandlerName); var chatService =
LazyServiceProvider.GetRequiredKeyedService<IChatCompletionService>(modelDescribe.HandlerName);
await foreach (var result in chatService.CompleteChatStreamAsync(modelDescribe, request, cancellationToken)) await foreach (var result in chatService.CompleteChatStreamAsync(modelDescribe, request, cancellationToken))
{ {
yield return result; yield return result;
@@ -103,7 +105,8 @@ public class AiGateWayManager : DomainService
response.ContentType = "application/json; charset=UTF-8"; response.ContentType = "application/json; charset=UTF-8";
await using var writer = new StreamWriter(response.Body, Encoding.UTF8, leaveOpen: true); await using var writer = new StreamWriter(response.Body, Encoding.UTF8, leaveOpen: true);
var modelDescribe = await GetModelAsync(request.Model); var modelDescribe = await GetModelAsync(request.Model);
var chatService = LazyServiceProvider.GetRequiredKeyedService<IChatCompletionService>(modelDescribe.HandlerName); var chatService =
LazyServiceProvider.GetRequiredKeyedService<IChatCompletionService>(modelDescribe.HandlerName);
var data = await chatService.CompleteChatAsync(modelDescribe, request, cancellationToken); var data = await chatService.CompleteChatAsync(modelDescribe, request, cancellationToken);
if (userId is not null) if (userId is not null)
{ {

View File

@@ -1,8 +1,6 @@
using System.Xml.Linq; using Mapster;
using Mapster;
using Medallion.Threading; using Medallion.Threading;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.RateLimiting;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.DistributedLocking; using Volo.Abp.DistributedLocking;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;