MCPcopy Create free account
hub / github.com/Stevenic/codepilot / completePrompt

Method completePrompt

lib/Codepilot.js:99–135  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

97 function respond(botMessage) {
98 return __awaiter(this, void 0, void 0, function* () {
99 function completePrompt(input) {
100 return __awaiter(this, void 0, void 0, function* () {
101 // Route users message to wave
102 const result = yield wave.completePrompt(input);
103 switch (result.status) {
104 case 'success':
105 const message = result.message;
106 if (message.function_call) {
107 // Call function and add result to history
108 const entry = _that._functions.get(message.function_call.name);
109 if (entry) {
110 const args = message.function_call.arguments ? JSON.parse(message.function_call.arguments) : {};
111 const result = yield entry.fn(args);
112 wave.addFunctionResultToHistory(message.function_call.name, result);
113 // Call back in with the function result
114 yield completePrompt('');
115 }
116 else {
117 respond(internals_1.Colorize.error(`Function '${message.function_call.name}' was not found.`));
118 }
119 }
120 else {
121 // Call respond to display response and wait for user input
122 yield respond(internals_1.Colorize.output(message.content));
123 }
124 break;
125 default:
126 if (result.message) {
127 yield respond(internals_1.Colorize.error(`${result.status}: ${result.message}`));
128 }
129 else {
130 yield respond(internals_1.Colorize.error(`A result status of '${result.status}' was returned.`));
131 }
132 break;
133 }
134 });
135 }
136 // Show the bots message
137 console.log(botMessage);
138 // Prompt the user for input

Callers

nothing calls this directly

Calls 2

errorMethod · 0.45
outputMethod · 0.45

Tested by

no test coverage detected