Adds mock conversation api layer, adds reducers to handle various asyc

state and wires it with conversation UI
This commit is contained in:
ajaythapliyal
2023-02-20 09:04:24 +05:30
parent 63859a814b
commit a036a6b979
7 changed files with 122 additions and 34 deletions

View File

@@ -0,0 +1,24 @@
import { Answer } from './conversationModels';
export function fetchAnswerApi(
question: string,
apiKey: string,
): Promise<Answer> {
// a mock answer generator, this is going to be replaced with real http call
return new Promise((resolve) => {
setTimeout(() => {
let result = '';
const characters =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const charactersLength = characters.length;
let counter = 0;
while (counter < 5) {
result += characters.charAt(
Math.floor(Math.random() * charactersLength),
);
counter += 1;
}
resolve({ answer: result, query: question, result });
}, 3000);
});
}