Skip to content

Commit 673fca6

Browse files
pythonHuangclaude
andcommitted
feat: 接入大模型能力-AI智能生成接口流程编排(OpenAI兼容接口支持DeepSeek/通义/Kimi等,设计器AI生成对话框+模型配置,需求对话自动选接口/映射入参出参/连线/条件分支,14种节点,JSON解析校验与归一化兜底)+README中英文新增AI智能编排说明与更新日志
Co-Authored-By: Claude Code <noreply@anthropic.com>
1 parent 53eab57 commit 673fca6

4 files changed

Lines changed: 645 additions & 24 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
using Juggle.Application.Models.Response;
2+
using Juggle.Application.Services.Impl;
3+
using Microsoft.AspNetCore.Authorization;
4+
using Microsoft.AspNetCore.Mvc;
5+
6+
namespace Juggle.Api.Controllers.Api;
7+
8+
/// <summary>
9+
/// AI 大模型控制器:模型配置 + 需求对话生成接口流程编排。
10+
/// 支持任意 OpenAI 兼容接口(DeepSeek / 通义千问 / Kimi / OpenAI 等)。
11+
/// </summary>
12+
[ApiController]
13+
[Route("api/ai")]
14+
[Authorize]
15+
public class AiController : ControllerBase
16+
{
17+
private readonly AiService _aiService;
18+
19+
public AiController(AiService aiService) => _aiService = aiService;
20+
21+
/// <summary>读取 AI 模型配置</summary>
22+
[HttpGet("config")]
23+
public async Task<ApiResult> GetConfig()
24+
{
25+
try
26+
{
27+
return ApiResult.Success(await _aiService.GetConfigAsync());
28+
}
29+
catch (Exception ex) { return ApiResult.Fail(ex.Message); }
30+
}
31+
32+
/// <summary>保存 AI 模型配置(OpenAI 兼容接口地址/密钥/模型名)</summary>
33+
[HttpPost("config")]
34+
public async Task<ApiResult> SaveConfig([FromBody] AiConfigRequest req)
35+
{
36+
try
37+
{
38+
await _aiService.SaveConfigAsync(req.BaseUrl, req.ApiKey, req.Model);
39+
return ApiResult.Success();
40+
}
41+
catch (Exception ex) { return ApiResult.Fail(ex.Message); }
42+
}
43+
44+
/// <summary>根据需求对话生成接口流程编排 JSON</summary>
45+
[HttpPost("generate-flow")]
46+
public async Task<ApiResult> GenerateFlow([FromBody] AiGenerateFlowRequest req)
47+
{
48+
try
49+
{
50+
var flow = await _aiService.GenerateFlowAsync(req.Requirement, req.Apis, req.InputParams, req.OutputParams);
51+
return ApiResult.Success(flow);
52+
}
53+
catch (Exception ex) { return ApiResult.Fail(ex.Message); }
54+
}
55+
}
56+
57+
public class AiConfigRequest
58+
{
59+
public string BaseUrl { get; set; } = "";
60+
public string ApiKey { get; set; } = "";
61+
public string Model { get; set; } = "";
62+
}
63+
64+
public class AiGenerateFlowRequest
65+
{
66+
public string Requirement { get; set; } = "";
67+
public List<Dictionary<string, object?>>? Apis { get; set; }
68+
public List<Dictionary<string, object?>>? InputParams { get; set; }
69+
public List<Dictionary<string, object?>>? OutputParams { get; set; }
70+
}

0 commit comments

Comments
 (0)