Skip to content

Commit bb20ae4

Browse files
authored
Merge pull request #289 from codefori/dev
Chat AI
2 parents ecb20dc + 51db0a2 commit bb20ae4

File tree

11 files changed

+925
-889
lines changed

11 files changed

+925
-889
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: 108 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Db2 for IBM i tools in VS Code",
55
"version": "1.5.2",
66
"engines": {
7-
"vscode": "^1.70.0"
7+
"vscode": "^1.90.0"
88
},
99
"icon": "media/logo.png",
1010
"keywords": [
@@ -37,39 +37,31 @@
3737
"language:test": "vitest",
3838
"dsc": "npx tsx src/dsc",
3939
"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",
40+
"vscode:prepublish": "rm -rf dist && webpack --mode production && npm run dsc",
41+
"webpack": "webpack --mode development",
42+
"webpack-dev": "webpack --mode development",
4343
"typings": "npx -p typescript tsc ./src/extension.ts --declaration --allowJs --emitDeclarationOnly --outDir types --esModuleInterop -t es2019 --moduleResolution node"
4444
},
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-
},
7245
"contributes": {
46+
"chatParticipants": [
47+
{
48+
"id": "vscode-db2i.chat",
49+
"name": "db2i",
50+
"fullName": "Db2 for i",
51+
"description": "Chat with the Db2 for i AI assistant",
52+
"isSticky": true,
53+
"commands": [
54+
{
55+
"name": "build",
56+
"description": "Build an SQL statement"
57+
},
58+
{
59+
"name": "activity",
60+
"description": "Summarize the activity on the system"
61+
}
62+
]
63+
}
64+
],
7365
"configuration": [
7466
{
7567
"id": "vscode-db2i",
@@ -128,6 +120,33 @@
128120
}
129121
}
130122
},
123+
{
124+
"id": "vscode-db2i.ai",
125+
"title": "Db2 for IBM i with AI",
126+
"properties": {
127+
"vscode-db2i.ai.provider": {
128+
"order": 0,
129+
"type": "string",
130+
"description": "Model Provider",
131+
"default": "none",
132+
"enum": [
133+
"none",
134+
"Ollama",
135+
"GitHub Copilot"
136+
],
137+
"enumDescriptions": [
138+
"Ollama instance, with specific model",
139+
"GitHub Copilot. Requires the GitHub Copilot extension to be installed"
140+
]
141+
},
142+
"vscode-db2i.ai.model": {
143+
"order": 1,
144+
"type": "string",
145+
"description": "Model to use with the provider",
146+
"default": "ibm-granite"
147+
}
148+
}
149+
},
131150
{
132151
"id": "vscode-db2i.resultsets",
133152
"title": "Viewing Data",
@@ -306,6 +325,24 @@
306325
]
307326
},
308327
"commands": [
328+
{
329+
"command": "vscode-db2i.ai.changeModel",
330+
"title": "Change AI Model",
331+
"category": "Db2 for i"
332+
},
333+
{
334+
"command": "vscode-db2i.notebook.open",
335+
"title": "New Notebook",
336+
"category": "IBM i Notebooks",
337+
"enablement": "code-for-ibmi:connected == true",
338+
"icon": "$(notebook)"
339+
},
340+
{
341+
"command": "vscode-db2i.notebook.fromSqlUri",
342+
"title": "Open as Notebook",
343+
"category": "IBM i Notebooks",
344+
"icon": "$(notebook)"
345+
},
309346
{
310347
"command": "vscode-db2i.json.pasteGenerator",
311348
"title": "Paste JSON as SQL",
@@ -1225,6 +1262,18 @@
12251262
}
12261263
],
12271264
"snippets": [
1265+
{
1266+
"language": "sql",
1267+
"path": "snippets/scalars.code-snippets"
1268+
},
1269+
{
1270+
"language": "sql",
1271+
"path": "snippets/variables.code-snippets"
1272+
},
1273+
{
1274+
"language": "sql",
1275+
"path": "snippets/aggregates.code-snippets"
1276+
},
12281277
{
12291278
"language": "sql",
12301279
"path": "snippets/http.code-snippets"
@@ -1246,5 +1295,33 @@
12461295
"path": "snippets/aggregates.code-snippets"
12471296
}
12481297
]
1298+
},
1299+
"devDependencies": {
1300+
"@halcyontech/vscode-ibmi-types": "^2.0.0",
1301+
"@types/glob": "^7.1.3",
1302+
"@types/node": "14.x",
1303+
"@types/vscode": "^1.90.0",
1304+
"esbuild-loader": "^3.0.1",
1305+
"eslint": "^7.32.0",
1306+
"glob": "^7.1.7",
1307+
"octokit": "^3.1.2",
1308+
"raw-loader": "^4.0.2",
1309+
"ts-loader": "^9.3.1",
1310+
"typescript": "^4.3.2",
1311+
"vitest": "^0.33.0",
1312+
"vscode-test": "^1.5.2",
1313+
"webpack": "^5.91.0",
1314+
"webpack-cli": "^4.5.0"
1315+
},
1316+
"dependencies": {
1317+
"@ibm/mapepire-js": "^0.3.0",
1318+
"chart.js": "^4.4.2",
1319+
"csv": "^6.1.3",
1320+
"json-to-markdown-table": "^1.0.0",
1321+
"lru-cache": "^6.0.0",
1322+
"node-fetch": "^3.3.1",
1323+
"ollama": "^0.5.2",
1324+
"showdown": "^2.1.0",
1325+
"sql-formatter": "^14.0.0"
12491326
}
12501327
}

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)