@@ -4,6 +4,7 @@ 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 "./prompts" ;
7
+ import { Db2ContextItems } from "./prompt" ;
7
8
8
9
export function canTalkToDb ( ) {
9
10
return JobManager . getSelection ( ) !== undefined ;
@@ -23,12 +24,6 @@ interface MarkdownRef {
23
24
SCHMEA ?: string ;
24
25
}
25
26
26
- interface ContextDefinition {
27
- id : string ;
28
- type : string ;
29
- content : any ;
30
- }
31
-
32
27
/**
33
28
* Builds a semantic representation of a database schema by fetching all objects
34
29
* associated with the schema, cleaning them, and filtering out unnecessary properties.
@@ -167,7 +162,7 @@ function splitUpUserInput(input: string): string[] {
167
162
*
168
163
* @param {string } input - A string that may contain table references.
169
164
*/
170
- export async function getSqlContextItems ( input : string ) : Promise < { items : ContextDefinition [ ] , refs : ResolvedSqlObject [ ] } > {
165
+ export async function getSqlContextItems ( input : string ) : Promise < { items : Db2ContextItems [ ] , refs : ResolvedSqlObject [ ] } > {
171
166
// Parse all SCHEMA.TABLE references first
172
167
const tokens = splitUpUserInput ( input ) ;
173
168
@@ -209,8 +204,8 @@ export async function getSqlContextItems(input: string): Promise<{items: Context
209
204
} ;
210
205
}
211
206
212
- export async function getContentItemsForRefs ( allObjects : ResolvedSqlObject [ ] ) : Promise < ContextDefinition [ ] > {
213
- const items : ( ContextDefinition | undefined ) [ ] = await Promise . all (
207
+ export async function getContentItemsForRefs ( allObjects : ResolvedSqlObject [ ] ) : Promise < Db2ContextItems [ ] > {
208
+ const items : ( Db2ContextItems | undefined ) [ ] = await Promise . all (
214
209
allObjects . map ( async ( o ) => {
215
210
try {
216
211
if ( o . sqlType === `SCHEMA` ) {
@@ -221,9 +216,9 @@ export async function getContentItemsForRefs(allObjects: ResolvedSqlObject[]): P
221
216
const content = await Schemas . generateSQL ( o . schema , o . name , o . sqlType ) ;
222
217
223
218
return {
224
- id : o . name ,
225
- type : o . sqlType ,
226
- content : content ,
219
+ name : ` ${ o . sqlType . toLowerCase ( ) } definition for ${ o . name } ` ,
220
+ description : ` ${ o . sqlType } definition` ,
221
+ content : content
227
222
} ;
228
223
}
229
224
0 commit comments