Skip to content

Commit

Permalink
Merge pull request #297 from codefori/fix/continue-context
Browse files Browse the repository at this point in the history
ignore context item it its empty
  • Loading branch information
worksofliam authored Nov 6, 2024
2 parents 28f9fb4 + 88eba79 commit 38895ed
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/aiProviders/continue/continueContextProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,20 @@ export class db2ContextProvider implements IContextProvider {
);
for (const table of Object.keys(tableRefs)) {
const columnData: TableColumn[] = tableRefs[table];
const tableSchema =
columnData.length > 0 ? columnData[0].TABLE_SCHEMA : null;

// create context item
let prompt = `Db2 for i Table meta data for schema ${tableSchema} table ${table}\n`;
prompt += `Column Info: ${JSON.stringify(columnData)}\n\n`;

contextItems.push({
name: `${job.name}-${tableSchema}-${table}`,
description: `Schema and table information for ${table}`,
content: prompt,
});
if (columnData && columnData.length > 0) {
const tableSchema =
columnData.length > 0 ? columnData[0].TABLE_SCHEMA : null;

// create context item
let prompt = `Db2 for i Table meta data for schema ${tableSchema} table ${table}\n`;
prompt += `Column Info: ${JSON.stringify(columnData)}\n\n`;

contextItems.push({
name: `${job.name}-${tableSchema}-${table}`,
description: `Schema and table information for ${table}`,
content: prompt,
});
}
}

return contextItems;
Expand Down Expand Up @@ -195,6 +197,5 @@ export async function registerContinueProvider() {
const continueAPI = continueEx?.exports;
continueAPI?.registerCustomContextProvider(provider);
vscode.commands.executeCommand('setContext', 'vscode-db2i:continueExtensionActive', true);
vscode.window.showInformationMessage(`@Db2i context provider enabled in Continue!`);
}
}

0 comments on commit 38895ed

Please sign in to comment.