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

Class Codepilot

lib/Codepilot.js:44–178  ·  view source on GitHub ↗

* The main class for the Codepilot application.

Source from the content-addressed store, hash-verified

42 * The main class for the Codepilot application.
43 */
44class Codepilot {
45 /**
46 * Creates a new `Codepilot` instance.
47 * @param index The code index to use.
48 */
49 constructor(index) {
50 this._functions = new Map();
51 this._index = index;
52 }
53 /**
54 * Gets the code index.
55 */
56 get index() {
57 return this._index;
58 }
59 /**
60 * Registers a new function to be used in the chat completion.
61 * @remarks
62 * This is used to add new capabilities to Codepilot's chat feature
63 * @param name The name of the function.
64 * @param schema The schema of the function.
65 * @param fn The function to be executed.
66 */
67 addFunction(schema, fn) {
68 this._functions.set(schema.name, { schema, fn });
69 return this;
70 }
71 /**
72 * Starts the chat session and listens for user input.
73 */
74 chat() {
75 return __awaiter(this, void 0, void 0, function* () {
76 // Create a readline interface object with the standard input and output streams
77 const rl = readline.createInterface({
78 input: process.stdin,
79 output: process.stdout
80 });
81 // Create model and wave
82 const model = this.createModel();
83 const wave = new alphawave_1.AlphaWave({
84 model,
85 prompt: new promptrix_1.Prompt([
86 new promptrix_1.SystemMessage([
87 `You are an expert software developer.`,
88 `You are chatting with another developer who is asking for help with the project they're working on.`,
89 ].join('\n')),
90 new SourceCodeSection_1.SourceCodeSection(this._index, 0.6),
91 new promptrix_1.ConversationHistory('history', 0.4),
92 new promptrix_1.UserMessage('{{$input}}', 500)
93 ])
94 });
95 // Define main chat loop
96 const _that = this;
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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected