fixes on comments

This commit is contained in:
Alex 2023-02-25 18:43:54 +00:00
parent 4769eb31e9
commit fdc8a509de
2 changed files with 25 additions and 24 deletions

View File

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

View File

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