fixes on comments

pull/130/head
Alex 2 years ago
parent 4769eb31e9
commit fdc8a509de

@ -19,30 +19,31 @@ export function fetchAnswerApi(
selectedDocs.version + selectedDocs.version +
'/' + '/' +
selectedDocs.model; selectedDocs.model;
return new Promise((resolve, reject) => {
const activeDocs = 'default'; return fetch('https://docsgpt.arc53.com/api/answer', {
fetch('https://docsgpt.arc53.com/api/answer', { method: 'POST',
method: 'POST', headers: {
headers: { 'Content-Type': 'application/json',
'Content-Type': 'application/json', },
}, body: JSON.stringify({
body: JSON.stringify({ question: question,
question: question, api_key: apiKey,
api_key: apiKey, embeddings_key: apiKey,
embeddings_key: apiKey, history: localStorage.getItem('chatHistory'),
history: localStorage.getItem('chatHistory'), active_docs: docPath,
active_docs: docPath, }),
}), })
.then((response) => {
if (response.ok) {
return response.json();
} else {
Promise.reject(response);
}
}) })
.then((response) => response.json()) .then((data) => {
.then((data) => { const result = data.answer;
const result = data.answer; return { answer: result, query: question, result };
resolve({ answer: result, query: question, result }); });
})
.catch((error) => {
reject();
});
});
} }
function getRandomInt(min: number, max: number) { function getRandomInt(min: number, max: number) {

@ -18,7 +18,7 @@ export const fetchAnswer = createAsyncThunk<
const answer = await fetchAnswerApi( const answer = await fetchAnswerApi(
question, question,
state.preference.apiKey, state.preference.apiKey,
state.preference.selectedDocs, state.preference.selectedDocs!,
); );
return answer; return answer;
}); });

Loading…
Cancel
Save