Skip to content

Commit a23d4f0

Browse files
committed
use JSON string in chat messages
1 parent 0bfeaba commit a23d4f0

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/chat/chat.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ export function activateChat(context: vscode.ExtensionContext) {
8888
`Provide the developer with SQL statements or relevant information based on the user's prompt and referenced table structures. Always include practical code examples where applicable. Ensure all suggestions are directly applicable to the structures and data provided and avoid making suggestions outside the scope of the available information.`
8989
),
9090
vscode.LanguageModelChatMessage.User(
91-
`Here are the table references ${refsToMarkdown(
92-
refs
93-
)}`
91+
`Here are the table references ${JSON.stringify(refs)}`
9492
),
9593
vscode.LanguageModelChatMessage.User(request.prompt)
9694
);

src/chat/context.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,25 @@ export async function findPossibleTables(stream: vscode.ChatResponseStream, sche
114114
return tables;
115115
}
116116

117+
118+
/**
119+
* Converts a given set of table references to a Markdown string.
120+
*
121+
* Experimental feature for @db2i chat participant
122+
*
123+
* @param refs - An object containing table references, where each key is a table name
124+
* and the value is an array of column definitions for that table.
125+
*
126+
* @returns A string formatted in Markdown representing the table references.
127+
*
128+
* The function generates a Markdown representation of the table references. If the number
129+
* of tables is greater than 5, a condensed format is used, otherwise a detailed format is used.
130+
*
131+
* The condensed format includes columns: Column, Type, and Text.
132+
* The detailed format includes columns: Column, Type, Nullable, Identity, Text, and Constraint.
133+
*
134+
* Tables with names starting with 'SYS' are skipped.
135+
*/
117136
export function refsToMarkdown(refs: TableRefs) {
118137
const condensedResult = Object.keys(refs).length > 5;
119138

0 commit comments

Comments
 (0)