Skip to content

Commit 3ed6969

Browse files
authored
Merge pull request #281 from codefori/chatai
Chatai
2 parents 00428ed + ace6371 commit 3ed6969

17 files changed

+1362
-1075
lines changed

.vscode/tasks.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
"type": "npm",
88
"script": "webpack-dev",
99
"problemMatcher": "$ts-webpack-watch",
10+
"isBackground": false,
11+
1012
"presentation": {
1113
"reveal": "never"
1214
},
1315
"group": {
1416
"kind": "build",
15-
"isDefault": true
17+
"isDefault": true,
1618
}
1719
}
1820
]

package-lock.json

Lines changed: 300 additions & 851 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 111 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"name": "vscode-db2i",
33
"displayName": "Db2 for IBM i",
44
"description": "Db2 for IBM i tools in VS Code",
5-
"version": "1.5.1",
5+
"version": "1.5.2",
66
"engines": {
7-
"vscode": "^1.70.0"
7+
"vscode": "^1.90.0"
88
},
99
"icon": "media/logo.png",
1010
"keywords": [
@@ -28,7 +28,8 @@
2828
"onLanguage:sql"
2929
],
3030
"extensionDependencies": [
31-
"halcyontechltd.code-for-ibmi"
31+
"halcyontechltd.code-for-ibmi",
32+
"github.copilot-chat"
3233
],
3334
"main": "./dist/extension.js",
3435
"scripts": {
@@ -37,39 +38,31 @@
3738
"language:test": "vitest",
3839
"dsc": "mkdir -p dist && npx tsx src/dsc",
3940
"package": "vsce package",
40-
"vscode:prepublish": "rm -rf dist && npm run webpack && npm run dsc",
41-
"webpack": "vscd --clean && webpack --mode development",
42-
"webpack-dev": "vscd --clean && webpack --mode development",
41+
"vscode:prepublish": "rm -rf dist && webpack --mode production && npm run dsc",
42+
"webpack": "webpack --mode development",
43+
"webpack-dev": "webpack --mode development",
4344
"typings": "npx -p typescript tsc ./src/extension.ts --declaration --allowJs --emitDeclarationOnly --outDir types --esModuleInterop -t es2019 --moduleResolution node"
4445
},
45-
"devDependencies": {
46-
"@halcyontech/vscode-ibmi-types": "^2.12.1",
47-
"@types/glob": "^7.1.3",
48-
"@types/node": "14.x",
49-
"@types/vscode": "^1.70.0",
50-
"esbuild-loader": "^3.0.1",
51-
"eslint": "^7.32.0",
52-
"glob": "^7.1.7",
53-
"octokit": "^3.1.2",
54-
"raw-loader": "^4.0.2",
55-
"ts-loader": "^9.3.1",
56-
"typescript": "^4.3.2",
57-
"vitest": "^0.33.0",
58-
"vscd": "^1.0.0",
59-
"vscode-test": "^1.5.2",
60-
"webpack": "^5.91.0",
61-
"webpack-cli": "^4.5.0"
62-
},
63-
"dependencies": {
64-
"@ibm/mapepire-js": "^0.3.0",
65-
"chart.js": "^4.4.2",
66-
"csv": "^6.1.3",
67-
"json-to-markdown-table": "^1.0.0",
68-
"node-fetch": "^3.3.1",
69-
"showdown": "^2.1.0",
70-
"sql-formatter": "^14.0.0"
71-
},
7246
"contributes": {
47+
"chatParticipants": [
48+
{
49+
"id": "vscode-db2i.chat",
50+
"name": "db2i",
51+
"fullName": "Db2 for i",
52+
"description": "Chat with the Db2 for i AI assistant",
53+
"isSticky": true,
54+
"commands": [
55+
{
56+
"name": "build",
57+
"description": "Build an SQL statement"
58+
},
59+
{
60+
"name": "activity",
61+
"description": "Summarize the activity on the system"
62+
}
63+
]
64+
}
65+
],
7366
"configuration": [
7467
{
7568
"id": "vscode-db2i",
@@ -128,6 +121,33 @@
128121
}
129122
}
130123
},
124+
{
125+
"id": "vscode-db2i.ai",
126+
"title": "Db2 for IBM i with AI",
127+
"properties": {
128+
"vscode-db2i.ai.provider": {
129+
"order": 0,
130+
"type": "string",
131+
"description": "Model Provider",
132+
"default": "none",
133+
"enum": [
134+
"none",
135+
"Ollama",
136+
"GitHub Copilot"
137+
],
138+
"enumDescriptions": [
139+
"Ollama instance, with specific model",
140+
"GitHub Copilot. Requires the GitHub Copilot extension to be installed"
141+
]
142+
},
143+
"vscode-db2i.ai.model": {
144+
"order": 1,
145+
"type": "string",
146+
"description": "Model to use with the provider",
147+
"default": "ibm-granite"
148+
}
149+
}
150+
},
131151
{
132152
"id": "vscode-db2i.resultsets",
133153
"title": "Viewing Data",
@@ -306,6 +326,24 @@
306326
]
307327
},
308328
"commands": [
329+
{
330+
"command": "vscode-db2i.ai.changeModel",
331+
"title": "Change AI Model",
332+
"category": "Db2 for i"
333+
},
334+
{
335+
"command": "vscode-db2i.notebook.open",
336+
"title": "New Notebook",
337+
"category": "IBM i Notebooks",
338+
"enablement": "code-for-ibmi:connected == true",
339+
"icon": "$(notebook)"
340+
},
341+
{
342+
"command": "vscode-db2i.notebook.fromSqlUri",
343+
"title": "Open as Notebook",
344+
"category": "IBM i Notebooks",
345+
"icon": "$(notebook)"
346+
},
309347
{
310348
"command": "vscode-db2i.json.pasteGenerator",
311349
"title": "Paste JSON as SQL",
@@ -1225,6 +1263,18 @@
12251263
}
12261264
],
12271265
"snippets": [
1266+
{
1267+
"language": "sql",
1268+
"path": "snippets/scalars.code-snippets"
1269+
},
1270+
{
1271+
"language": "sql",
1272+
"path": "snippets/variables.code-snippets"
1273+
},
1274+
{
1275+
"language": "sql",
1276+
"path": "snippets/aggregates.code-snippets"
1277+
},
12281278
{
12291279
"language": "sql",
12301280
"path": "snippets/http.code-snippets"
@@ -1246,5 +1296,33 @@
12461296
"path": "snippets/aggregates.code-snippets"
12471297
}
12481298
]
1299+
},
1300+
"devDependencies": {
1301+
"@halcyontech/vscode-ibmi-types": "^2.0.0",
1302+
"@types/glob": "^7.1.3",
1303+
"@types/node": "14.x",
1304+
"@types/vscode": "^1.90.0",
1305+
"esbuild-loader": "^3.0.1",
1306+
"eslint": "^7.32.0",
1307+
"glob": "^7.1.7",
1308+
"octokit": "^3.1.2",
1309+
"raw-loader": "^4.0.2",
1310+
"ts-loader": "^9.3.1",
1311+
"typescript": "^4.3.2",
1312+
"vitest": "^0.33.0",
1313+
"vscode-test": "^1.5.2",
1314+
"webpack": "^5.91.0",
1315+
"webpack-cli": "^4.5.0"
1316+
},
1317+
"dependencies": {
1318+
"@ibm/mapepire-js": "^0.3.0",
1319+
"chart.js": "^4.4.2",
1320+
"csv": "^6.1.3",
1321+
"json-to-markdown-table": "^1.0.0",
1322+
"lru-cache": "^6.0.0",
1323+
"node-fetch": "^3.3.1",
1324+
"ollama": "^0.5.2",
1325+
"showdown": "^2.1.0",
1326+
"sql-formatter": "^14.0.0"
12491327
}
12501328
}

src/chat/aiConfig.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import Configuration from "../configuration";
2+
3+
/**
4+
* Matches config vscode-db2i.ai.provider
5+
*/
6+
export type AiProvider = "none"|"Ollama"|"GitHub Copilot";
7+
8+
export class AiConfig {
9+
10+
static getProvider(): AiProvider {
11+
return Configuration.get<AiProvider>(`ai.provider`);
12+
}
13+
14+
static getModel(): string {
15+
return Configuration.get<string>("ai.model");
16+
}
17+
18+
static setProvider(provider: AiProvider) {
19+
return Configuration.set(`ai.provider`, provider);
20+
}
21+
22+
static setModel(model: string) {
23+
return Configuration.set(`ai.model`, model);
24+
}
25+
}

0 commit comments

Comments
 (0)