Skip to content

Commit 51db0a2

Browse files
committed
Copilot no longer a hard dependency
Signed-off-by: worksofliam <[email protected]>
1 parent 267b8e8 commit 51db0a2

File tree

2 files changed

+11
-55
lines changed

2 files changed

+11
-55
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
"onLanguage:sql"
2929
],
3030
"extensionDependencies": [
31-
"halcyontechltd.code-for-ibmi",
32-
"github.copilot-chat"
31+
"halcyontechltd.code-for-ibmi"
3332
],
3433
"main": "./dist/extension.js",
3534
"scripts": {

src/extension.ts

Lines changed: 10 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,6 @@ export interface Db2i {
2929
sqlJob: (options?: JDBCOptions) => OldSQLJob
3030
}
3131

32-
const CHAT_ID = `vscode-db2i.chat`;
33-
const LANGUAGE_MODEL_ID = `copilot-gpt-3.5-turbo`;
34-
35-
interface IDB2ChatResult extends vscode.ChatResult {
36-
metadata: {
37-
command: string;
38-
};
39-
}
40-
4132
// this method is called when your extension is activated
4233
// your extension is activated the very first time the command is executed
4334

@@ -113,51 +104,17 @@ export function activate(context: vscode.ExtensionContext): Db2i {
113104
});
114105
});
115106

116-
activateChat(context);
117-
118-
119-
// /**
120-
// * The Following is an experimental implemenation of chat extension for Db2 for i
121-
// */
122-
// const chatHandler: vscode.ChatRequestHandler = async (
123-
// request: vscode.ChatRequest,
124-
// context: vscode.ChatContext,
125-
// stream: vscode.ChatResponseStream,
126-
// token: vscode.CancellationToken
127-
// ): Promise<IDB2ChatResult> => {
128-
129-
// if (request.command == `build`) {
130-
// stream.progress(`Querying database for information...`);
131-
// // const text = processUserMessage(request.prompt);
132-
// const messages = [
133-
// new vscode.LanguageModelChatSystemMessage(`You are a an IBM i savant speciallizing in database features in Db2 for i. Your job is to help developers write and debug their SQL along with offering SQL programming advice. Help the developer write an SQL statement based on the prompt information. Always include code examples where is makes sense.`),
134-
// new vscode.LanguageModelChatUserMessage(request.prompt)
135-
// ];
136-
// try {
137-
// const chatResponse = await vscode.lm.sendChatRequest(LANGUAGE_MODEL_ID, messages, {}, token);
138-
// for await (const fragement of chatResponse.stream) {
139-
// stream.markdown(fragement);
140-
// }
141-
142-
// } catch (err) {
143-
// if (err instanceof vscode.LanguageModelError) {
144-
// console.log(err.message, err.code, err.stack);
145-
// } else {
146-
// console.log(err);
147-
// }
148-
// }
149-
150-
// return { metadata: { command: '' } };
151-
// }
152-
153-
// };
154-
155-
// const chat = vscode.chat.createChatParticipant(CHAT_ID, chatHandler);
156-
// chat.isSticky = true;
157-
// chat.iconPath = new vscode.ThemeIcon(`database`);
158-
159-
107+
const copilot = vscode.extensions.getExtension(`github.copilot-chat`);
160108

109+
if (copilot) {
110+
if (!copilot.isActive) {
111+
copilot.activate().then(() => {
112+
activateChat(context);
113+
});
114+
} else {
115+
activateChat(context);
116+
}
117+
}
161118

162119
instance.subscribe(context, `disconnected`, `db2i-disconnected`, () => ServerComponent.reset());
163120

0 commit comments

Comments
 (0)