klg-asutk-app/app/api/openapi/route.ts
Yuriy d47baa1782 refactor: удалены ссылки на knowledge/ (не относится к КЛГ АСУ ТК)
- Удалены API routes, rewrites и ссылки на knowledge/reglaments
- knowledge/ удалена из git-истории (6 ГБ PDF не относящихся к проекту)
- Нормативная база обслуживается через модуль legal (routes/legal/)

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-15 14:02:14 +03:00

151 lines
4.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export const dynamic = "force-dynamic";
import { NextResponse } from 'next/server';
/**
* OpenAPI спецификация для AI endpoints
*/
const openApiSpec = {
openapi: '3.0.0',
info: {
title: 'KLG ASUTK AI API',
version: '1.0.0',
description: 'API для взаимодействия с AI-системой контроля лётной годности воздушных судов',
contact: {
name: 'API Support',
},
},
servers: [
{
url: process.env.NEXT_PUBLIC_API_URL || '',
description: 'Production server',
},
],
paths: {
'/api/ai/agent': {
post: {
summary: 'Обработка естественного языка запроса',
description: 'Обрабатывает запрос на естественном языке и возвращает ответ с reasoning',
tags: ['AI Agent'],
requestBody: {
required: true,
content: {
'application/json': {
schema: {
type: 'object',
required: ['query'],
properties: {
query: {
type: 'string',
description: 'Запрос на естественном языке',
example: 'Покажи все активные воздушные суда',
},
mode: {
type: 'string',
enum: ['copilot', 'autonomous'],
default: 'copilot',
description: 'Режим работы агента',
},
context: {
type: 'object',
description: 'Дополнительный контекст для запроса',
},
},
},
},
},
},
responses: {
'200': {
description: 'Успешный ответ',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
answer: {
type: 'string',
description: 'Ответ на запрос',
},
reasoning: {
type: 'array',
items: {
type: 'string',
},
description: 'Цепочка рассуждений',
},
actions: {
type: 'array',
items: {
type: 'object',
properties: {
type: { type: 'string' },
description: { type: 'string' },
executed: { type: 'boolean' },
result: { type: 'object' },
},
},
},
confidence: {
type: 'number',
minimum: 0,
maximum: 1,
description: 'Уверенность в ответе',
},
mode: {
type: 'string',
enum: ['copilot', 'autonomous'],
},
intent: {
type: 'object',
properties: {
intent: { type: 'string' },
confidence: { type: 'number' },
},
},
},
},
},
},
},
'400': {
description: 'Неверный запрос',
},
'429': {
description: 'Превышен лимит запросов',
},
'500': {
description: 'Внутренняя ошибка сервера',
},
},
},
},
},
components: {
schemas: {
Error: {
type: 'object',
properties: {
error: {
type: 'string',
description: 'Сообщение об ошибке',
},
code: {
type: 'string',
description: 'Код ошибки',
},
},
},
},
},
tags: [
{
name: 'AI Agent',
description: 'Endpoints для взаимодействия с автономным агентом',
},
],
};
export async function GET() {
return NextResponse.json(openApiSpec);
}