API conversation

This commit is contained in:
Alex
2023-02-25 13:36:03 +00:00
parent 6cd98d631d
commit 6eef53cb1b
4 changed files with 46 additions and 21 deletions

View File

@@ -14,7 +14,24 @@ export const fetchAnswer = createAsyncThunk<
{ state: RootState }
>('fetchAnswer', async ({ question }, { getState }) => {
const state = getState();
const answer = await fetchAnswerApi(question, state.preference.apiKey);
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,
);
return answer;
});