Files
admin 13745e5874
CI / CD Pipeline / build (push) Failing after 4m57s
CI / CD Pipeline / deploy (push) Has been skipped
690419:1831 feat: update CI/CD to use SSH key authentication #05
2026-04-19 18:31:30 +07:00

37 lines
927 B
TypeScript

import { useMutation } from '@tanstack/react-query';
import apiClient from '../lib/api/client';
export interface RagCitation {
chunkId: string;
docNumber: string | null;
docType: string;
revision: string | null;
snippet: string;
score: number;
}
export interface RagQueryRequest {
question: string;
projectPublicId: string;
}
export interface RagQueryResponse {
answer: string;
citations: RagCitation[];
confidence: number;
usedFallbackModel: boolean;
cachedAt?: string;
}
export function useRagQuery() {
return useMutation<RagQueryResponse, Error, RagQueryRequest>({
mutationFn: async (payload) => {
const idempotencyKey = `rag-${Date.now()}-${Math.random().toString(36).slice(2)}`;
const res = await apiClient.post<{ data: RagQueryResponse }>('/rag/query', payload, {
headers: { 'Idempotency-Key': idempotencyKey },
});
return res.data.data;
},
});
}