Skip to content

Commit 31f3428

Browse files
committed
Working history
Signed-off-by: worksofliam <[email protected]>
1 parent f71a829 commit 31f3428

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

src/chat/chat.ts

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ export function activateChat(context: vscode.ExtensionContext) {
6060
return { metadata: { command: "activity" } };
6161

6262
default:
63-
context;
6463
stream.progress(
6564
`Getting information from ${Statement.prettyName(usingSchema)}...`
6665
);
@@ -71,39 +70,43 @@ export function activateChat(context: vscode.ExtensionContext) {
7170
);
7271

7372
messages = [
74-
vscode.LanguageModelChatMessage.User(
73+
vscode.LanguageModelChatMessage.Assistant(
7574
`You are a an IBM i savant speciallizing in database features in Db2 for i. Your job is to help developers write and debug their SQL along with offering SQL programming advice.`
7675
),
76+
vscode.LanguageModelChatMessage.Assistant(
77+
`The developers current schema is ${usingSchema}.`
78+
),
79+
vscode.LanguageModelChatMessage.Assistant(
80+
`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.`
81+
),
7782
];
7883

79-
if (Object.keys(refs).length === 0) {
80-
stream.progress(`No references found. Doing bigger lookup...`);
81-
refs = await findPossibleTables(stream, usingSchema, []);
84+
if (context.history.length > 0) {
85+
messages.push(...context.history.map(h => {
86+
if ('prompt' in h) {
87+
return vscode.LanguageModelChatMessage.Assistant(h.prompt);
88+
} else {
89+
return vscode.LanguageModelChatMessage.Assistant(
90+
h.response.filter(r => 'value' in r.value).map(r => r.value.value).join(`\n\n`)
91+
);
92+
}
93+
}));
94+
95+
messages = messages.filter(m => m.content.trim().length > 0);
8296
}
8397

8498
if (Object.keys(refs).length > 0) {
85-
stream.progress(`Building response...`);
8699
messages.push(
87-
vscode.LanguageModelChatMessage.User(
88-
`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.`
100+
vscode.LanguageModelChatMessage.Assistant(
101+
`Here are new table references ${JSON.stringify(refs)}`
89102
),
90-
vscode.LanguageModelChatMessage.User(
91-
`Here are the table references ${JSON.stringify(refs)}`
92-
),
93-
vscode.LanguageModelChatMessage.User(request.prompt)
94-
);
95-
} else {
96-
stream.progress(`No references found.`);
97-
messages.push(
98-
vscode.LanguageModelChatMessage.User(
99-
`Warn the developer that their request is not clear or that no references were found. Provide a suggestion or ask for more information.`
100-
),
101-
vscode.LanguageModelChatMessage.User(
102-
`The developers current schema is ${usingSchema}.`
103-
)
104103
);
105104
}
106105

106+
stream.progress(`Building response...`);
107+
108+
messages.push(vscode.LanguageModelChatMessage.User(request.prompt))
109+
107110
await streamModelResponse(messages, stream, token);
108111

109112
return { metadata: { command: "build" } };

0 commit comments

Comments
 (0)