File size: 821 Bytes
3b6afc0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import type { TConversation, TSubmission, EModelEndpoint } from './types';

export default function createPayload(submission: TSubmission) {
  const { conversation, message, endpointOption } = submission;
  const { conversationId } = conversation as TConversation;
  const { endpoint } = endpointOption as { endpoint: EModelEndpoint };

  const endpointUrlMap = {
    azureOpenAI: '/api/ask/azureOpenAI',
    openAI: '/api/ask/openAI',
    google: '/api/ask/google',
    bingAI: '/api/ask/bingAI',
    chatGPT: '/api/ask/chatGPT',
    chatGPTBrowser: '/api/ask/chatGPTBrowser',
    gptPlugins: '/api/ask/gptPlugins',
    anthropic: '/api/ask/anthropic',
  };

  const server = endpointUrlMap[endpoint];

  const payload = {
    ...message,
    ...endpointOption,
    conversationId,
  };

  return { server, payload };
}