mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-11-30 00:53:14 +00:00
Adds mock conversation api layer, adds reducers to handle various asyc
state and wires it with conversation UI
This commit is contained in:
24
frontend/src/conversation/conversationApi.ts
Normal file
24
frontend/src/conversation/conversationApi.ts
Normal 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);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user