File tree Expand file tree Collapse file tree 4 files changed +40
-30
lines changed Expand file tree Collapse file tree 4 files changed +40
-30
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,6 @@ import { JobManager } from "../config";
4
4
import Schemas , { AllSQLTypes , SQLType } from "../database/schemas" ;
5
5
import Statement from "../database/statement" ;
6
6
import { DB2_SYSTEM_PROMPT } from "./continue/prompts" ;
7
- import Configuration from "../configuration" ;
8
7
9
8
export function canTalkToDb ( ) {
10
9
return JobManager . getSelection ( ) !== undefined ;
@@ -109,14 +108,8 @@ export async function buildSchemaDefinition(schema: string): Promise<Partial<Bas
109
108
return data . map ( filterBasicSQLObject ) ;
110
109
}
111
110
112
- const useSchemaDef : boolean = Configuration . get < boolean > ( `ai.useSchemaDefinition` ) ;
113
- if ( useSchemaDef ) {
114
- const compressedData = filterBasicSQLObjects ( allInfo ) ;
115
- return compressedData ;
116
- }
117
-
118
- return undefined ;
119
-
111
+ const compressedData = filterBasicSQLObjects ( allInfo ) ;
112
+ return compressedData ;
120
113
}
121
114
122
115
/**
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import {
16
16
generateTableDefinition
17
17
} from "../context" ;
18
18
import { DB2_SELF_PROMPT , DB2_SYSTEM_PROMPT } from "./prompts" ;
19
+ import Configuration from "../../configuration" ;
19
20
20
21
export let isContinueActive = false ;
21
22
@@ -142,14 +143,19 @@ export class db2ContextProvider implements IContextProvider {
142
143
const fullInput = extras . fullInput ;
143
144
144
145
// 1. SCHEMA Definiton (semantic)
145
- const schemaSemantic = await buildSchemaDefinition ( schema ) ;
146
- if ( schemaSemantic ) {
147
- contextItems . push ( {
148
- name : `SCHEMA Definition` ,
149
- description : `${ schema } definition` ,
150
- content : JSON . stringify ( schemaSemantic ) ,
151
- } ) ;
146
+ const useSchemaDef : boolean = Configuration . get < boolean > ( `ai.useSchemaDefinition` ) ;
147
+
148
+ if ( useSchemaDef ) {
149
+ const schemaSemantic = await buildSchemaDefinition ( schema ) ;
150
+ if ( schemaSemantic ) {
151
+ contextItems . push ( {
152
+ name : `SCHEMA Definition` ,
153
+ description : `${ schema } definition` ,
154
+ content : JSON . stringify ( schemaSemantic ) ,
155
+ } ) ;
156
+ }
152
157
}
158
+
153
159
try {
154
160
switch ( true ) {
155
161
case fullInput . includes ( `*SELF` ) || query ?. includes ( `*SELF` ) :
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import {
13
13
buildSchemaDefinition ,
14
14
generateTableDefinition
15
15
} from "../context" ;
16
+ import Configuration from "../../configuration" ;
16
17
17
18
const listDb2Table : ContextProviderDescription = {
18
19
title : "list Db2i Tables" ,
@@ -69,14 +70,19 @@ class ListDb2iTables implements IContextProvider {
69
70
) : Promise < ContextItem [ ] > {
70
71
let contextItems : ContextItem [ ] = [ ] ;
71
72
if ( query . toUpperCase ( ) === this . schema . toUpperCase ( ) ) {
72
- const schemaSemantic = await buildSchemaDefinition ( this . schema ) ;
73
- if ( schemaSemantic ) {
74
- contextItems . push ( {
75
- name : `SCHEMA Definition` ,
76
- description : `${ this . schema } definition` ,
77
- content : JSON . stringify ( schemaSemantic ) ,
78
- } ) ;
73
+
74
+ const useSchemaDef : boolean = Configuration . get < boolean > ( `ai.useSchemaDefinition` ) ;
75
+ if ( useSchemaDef ) {
76
+ const schemaSemantic = await buildSchemaDefinition ( this . schema ) ;
77
+ if ( schemaSemantic ) {
78
+ contextItems . push ( {
79
+ name : `SCHEMA Definition` ,
80
+ description : `${ this . schema } definition` ,
81
+ content : JSON . stringify ( schemaSemantic ) ,
82
+ } ) ;
83
+ }
79
84
}
85
+
80
86
} else {
81
87
const tablesRefs = await generateTableDefinition (
82
88
this . schema ,
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import {
11
11
} from "../context" ;
12
12
import { JobManager } from "../../config" ;
13
13
import { DB2_SYSTEM_PROMPT } from "../continue/prompts" ;
14
+ import Configuration from "../../configuration" ;
14
15
15
16
const CHAT_ID = `vscode-db2i.chat` ;
16
17
@@ -62,13 +63,17 @@ export function activateChat(context: vscode.ExtensionContext) {
62
63
if ( canTalkToDb ( ) ) {
63
64
// 1. SCHEMA Definiton (semantic)
64
65
let usingSchema = getCurrentSchema ( ) ;
65
- const schemaSemantic = await buildSchemaDefinition ( usingSchema ) ;
66
- if ( schemaSemantic ) {
67
- messages . push (
68
- vscode . LanguageModelChatMessage . Assistant (
69
- JSON . stringify ( schemaSemantic )
70
- )
71
- ) ;
66
+
67
+ const useSchemaDef : boolean = Configuration . get < boolean > ( `ai.useSchemaDefinition` ) ;
68
+ if ( useSchemaDef ) {
69
+ const schemaSemantic = await buildSchemaDefinition ( usingSchema ) ;
70
+ if ( schemaSemantic ) {
71
+ messages . push (
72
+ vscode . LanguageModelChatMessage . Assistant (
73
+ JSON . stringify ( schemaSemantic )
74
+ )
75
+ ) ;
76
+ }
72
77
}
73
78
74
79
switch ( request . command ) {
You can’t perform that action at this time.
0 commit comments