moved string prep

pull/130/head
Alex 1 year ago
parent 99ac57c15b
commit 4011398b0c

@ -1,11 +1,24 @@
import { Answer } from './conversationModels';
import { Doc } from '../preferences/preferenceApi';
export function fetchAnswerApi(
question: string,
apiKey: string,
selectedDocs: string,
selectedDocs: Doc,
): Promise<Answer> {
// a mock answer generator, this is going to be replaced with real http call
let namePath = selectedDocs.name;
if (selectedDocs.language === namePath) {
namePath = '.project';
}
const docPath =
selectedDocs.language +
'/' +
namePath +
'/' +
selectedDocs.version +
'/' +
selectedDocs.model;
return new Promise((resolve, reject) => {
const activeDocs = 'default';
fetch('https://docsgpt.arc53.com/api/answer', {
@ -18,7 +31,7 @@ export function fetchAnswerApi(
api_key: apiKey,
embeddings_key: apiKey,
history: localStorage.getItem('chatHistory'),
active_docs: selectedDocs,
active_docs: docPath,
}),
})
.then((response) => response.json())

@ -14,23 +14,11 @@ export const fetchAnswer = createAsyncThunk<
{ state: RootState }
>('fetchAnswer', async ({ question }, { getState }) => {
const state = getState();
let namePath = state.preference.selectedDocs?.name;
if (state.preference.selectedDocs?.language === namePath) {
namePath = '.project';
}
const docPath =
state.preference.selectedDocs?.language +
'/' +
namePath +
'/' +
state.preference.selectedDocs?.version +
'/' +
state.preference.selectedDocs?.model;
const answer = await fetchAnswerApi(
question,
state.preference.apiKey,
docPath,
state.preference.selectedDocs,
);
return answer;
});

Loading…
Cancel
Save