diff --git a/docs/swagger.json b/docs/swagger.json index e67a09d3..7479945c 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -1,5 +1,4 @@ { - "schemes": [], "swagger": "2.0", "info": { "description": "这是一个用于管理猪场设备的后端服务。", @@ -15,8 +14,6 @@ }, "version": "1.0" }, - "host": "", - "basePath": "", "paths": { "/api/v1/alarm/threshold/active-alarms": { "get": { @@ -3366,6 +3363,59 @@ } } }, + "/api/v1/feed/recipes/{id}/ai-diagnose": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "使用AI对指定配方进行点评,并针对目标猪类型给出建议。", + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理-配方" + ], + "summary": "AI点评配方", + "parameters": [ + { + "type": "integer", + "description": "配方ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "猪类型ID", + "name": "pig_type_id", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "业务码为200代表AI点评成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.ReviewRecipeResponse" + } + } + } + ] + } + } + } + } + }, "/api/v1/inventory/stock/adjust": { "post": { "security": [ @@ -9160,6 +9210,23 @@ } } }, + "dto.ReviewRecipeResponse": { + "type": "object", + "properties": { + "ai_model": { + "description": "使用的 AI 模型", + "allOf": [ + { + "$ref": "#/definitions/models.AIModel" + } + ] + }, + "review_message": { + "description": "点评内容", + "type": "string" + } + } + }, "dto.SellPigsRequest": { "type": "object", "required": [ @@ -10079,6 +10146,15 @@ } } }, + "models.AIModel": { + "type": "string", + "enum": [ + "Gemini" + ], + "x-enum-varnames": [ + "AI_MODEL_GEMINI" + ] + }, "models.AlarmCode": { "type": "string", "enum": [ diff --git a/src/api/feed.js b/src/api/feed.js index b60452de..c3712f30 100644 --- a/src/api/feed.js +++ b/src/api/feed.js @@ -327,6 +327,17 @@ import {PaginationDTO, Response} from '../enums'; * @property {string} description - 新生成的配方描述 */ +/** + * @typedef {string} AIModel - AI模型枚举 + * @enum {string} + * @property {"Gemini"} Gemini - Gemini模型 + */ + +/** + * @typedef {object} ReviewRecipeResponse + * @property {AIModel} ai_model - 使用的 AI 模型 + * @property {string} review_message - 点评内容 + */ // --- API Functions --- @@ -656,6 +667,16 @@ export const generatePrioritizedStockRecipe = (pigTypeId) => { return http.post(`/api/v1/feed/recipes/generate-prioritized-stock/${pigTypeId}`); }; +/** + * 使用AI对指定配方进行点评,并针对目标猪类型给出建议。 + * @param {number} id - 配方ID + * @param {number} pigTypeId - 猪类型ID + * @returns {Promise>} + */ +export const aiDiagnoseRecipe = (id, pigTypeId) => { + return http.get(`/api/v1/feed/recipes/${id}/ai-diagnose`, {params: {pig_type_id: pigTypeId}}); +}; + export const FeedApi = { getNutrients, @@ -692,4 +713,5 @@ export const FeedApi = { deleteRecipe, generateRecipeFromAllMaterials, generatePrioritizedStockRecipe, + aiDiagnoseRecipe, }; diff --git a/src/enums.js b/src/enums.js index 2bc7b1ea..104189bf 100644 --- a/src/enums.js +++ b/src/enums.js @@ -330,6 +330,14 @@ export const AlarmSourceType = { SYSTEM: '系统', }; +/** + * AI模型 + * @enum {string} + */ +export const AIModel = { + GEMINI: 'Gemini', +}; + /** * 操作符 * @enum {string}