/*
 * F092 자연어 조회(Text-to-SQL) + F025 규정 챗봇 로컬 API.
 * 백엔드: POST /api/ai/nlquery · POST /api/ai/rules-chat (com.zioinfo.kintex.ai.nlquery).
 * 공용 api/{client,endpoints,types}는 수정하지 않고 client의 `api`만 재사용한다.
 */
import { api } from '../../api/client';

export interface NlQueryResult {
  question: string;
  sql: string;
  tables: string[];
  columns: string[];
  rows: Record<string, unknown>[];
  rowCount: number;
  provider: string;
}

export interface RuleCitation {
  code: string;
  label: string;
  detail: string;
}

export interface RulesChatResult {
  question: string;
  answer: string;
  citations: RuleCitation[];
  grounded: boolean;
  provider: string;
  degraded: boolean;
}

export const aiConsoleApi = {
  nlquery: (question: string) =>
    api.post<NlQueryResult>('/api/ai/nlquery', { question }),
  rulesChat: (question: string) =>
    api.post<RulesChatResult>('/api/ai/rules-chat', { question }),
};
