MCPcopy Create free account
hub / github.com/TAMustafa/Local_Chat_RAG / sendChat

Function sendChat

frontend/src/api/chatApi.ts:11–40  ·  view source on GitHub ↗
(
  optsOrFileId: ChatOptions | string | null,
  question?: string
)

Source from the content-addressed store, hash-verified

9}
10
11export const sendChat = async (
12 optsOrFileId: ChatOptions | string | null,
13 question?: string
14) => {
15 // Support both (fileId, question) and (ChatOptions) signatures
16 let payload: any;
17 if (
18 optsOrFileId &&
19 typeof optsOrFileId === 'object' &&
20 ('question' in optsOrFileId || 'fileId' in optsOrFileId)
21 ) {
22 // New hybrid API usage
23 const response = await axios.post('/api/chat', {
24 question: optsOrFileId.question,
25 file_id: optsOrFileId.fileId,
26 keywords: optsOrFileId.keywords,
27 metadata_filter: optsOrFileId.metadataFilter,
28 k: optsOrFileId.k,
29 });
30 return response.data;
31 }
32 // Legacy usage
33 payload = { question, file_id: optsOrFileId };
34 try {
35 const response = await axios.post('/api/chat', payload);
36 return response.data;
37 } catch (error: any) {
38 throw error?.response?.data?.detail || 'Chat request failed';
39 }
40};

Callers 1

handleSendFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected