MCPcopy Index your code
hub / github.com/microsoft/TypeChat / processRequests

Function processRequests

typescript/src/interactive/interactive.ts:12–35  ·  view source on GitHub ↗
(interactivePrompt: string, inputFileName: string | undefined, processRequest: (request: string) => Promise<void>)

Source from the content-addressed store, hash-verified

10 * @param processRequest Async callback function that is invoked for each interactive input or each line in text file.
11 */
12export async function processRequests(interactivePrompt: string, inputFileName: string | undefined, processRequest: (request: string) => Promise<void>) {
13 if (inputFileName) {
14 const lines = fs.readFileSync(inputFileName).toString().split(/\r?\n/);
15 for (const line of lines) {
16 if (line.length) {
17 console.log(interactivePrompt + line);
18 await processRequest(line);
19 }
20 }
21 }
22 else {
23 const stdio = readline.createInterface({ input: process.stdin, output: process.stdout });
24 while (true) {
25 const input = await stdio.question(interactivePrompt);
26 if (input.toLowerCase() === "quit" || input.toLowerCase() === "exit") {
27 break;
28 }
29 else if (input.length) {
30 await processRequest(input);
31 }
32 }
33 stdio.close();
34 }
35}

Callers 11

main.tsFile · 0.90
main.tsFile · 0.90
main.tsFile · 0.90
main.tsFile · 0.90
main.tsFile · 0.90
main.tsFile · 0.90
main.tsFile · 0.90
main.tsFile · 0.90
main.tsFile · 0.90
main.tsFile · 0.90
main.tsFile · 0.90

Calls 1

closeMethod · 0.80

Tested by

no test coverage detected