Merge branch 'master' of http://8.137.159.94:3000/glz/QYZH.InteractiveMagazine
This commit is contained in:
@ -0,0 +1,50 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using QYZH.InteractiveMagazine.IService;
|
||||
using QYZH.InteractiveMagazine.Models.Common;
|
||||
using QYZH.InteractiveMagazine.Models.Dto;
|
||||
using QYZH.InteractiveMagazine.Models.Enum;
|
||||
|
||||
namespace QYZH.InteractiveMagazine.WebApi.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// AI聊天控制器
|
||||
/// </summary>
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[ApiExplorerSettings(GroupName = nameof(ApiVersionEnum.Platform))]
|
||||
public class AiChatController : BaseController
|
||||
{
|
||||
private readonly IAiChatService _aiChatService;
|
||||
private readonly ILogger<AiChatController> _logger;
|
||||
|
||||
public AiChatController(IAiChatService aiChatService, ILogger<AiChatController> logger)
|
||||
{
|
||||
_aiChatService = aiChatService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AI聊天,根据需求生成提示词
|
||||
/// </summary>
|
||||
/// <param name="input">用户需求消息</param>
|
||||
/// <returns>AI生成的提示词(Markdown格式)</returns>
|
||||
[HttpPost]
|
||||
public async Task<BaseResponse<AiChatOutput>> ChatAsync([FromBody] AiChatInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _aiChatService.ChatAsync(input);
|
||||
return Success(result, "AI聊天成功");
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "AI聊天业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<AiChatOutput>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "AI聊天系统异常,参数:{Input}", input);
|
||||
return BaseResponse<AiChatOutput>.Fail("AI聊天失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -47,6 +47,14 @@
|
||||
]
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"AiChat": {
|
||||
"ApiKey": "Ollama",
|
||||
"BaseUrl": "http://172.16.10.130:11434/v1/",
|
||||
"Model": "qwen2.5vl:7b",
|
||||
"TimeoutSeconds": 300,
|
||||
"MaxTokens": 2000,
|
||||
"Temperature": 0.5
|
||||
},
|
||||
"AliyunOSSConfigs": {
|
||||
"AccessKeyID": "LTAI5tEBXGewpHSLiSxyx6Bf",
|
||||
"AccessKeySecret": "w29b8wkw6XQVL8GWXgp3ZesgYeDKvf",
|
||||
|
||||
Reference in New Issue
Block a user