Skip to content

Commit cb3e7b5

Browse files
committed
feat(component): fix tests
1 parent 44dbfad commit cb3e7b5

4 files changed

Lines changed: 12 additions & 11 deletions

File tree

src/__tests__/db-query/unit/nodes/get-tables.node.unit.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ describe('GetTablesNode Unit', function () {
7878
expect(llmStub.getCalls()[0].args[0].value.trim()).equal(
7979
`<instructions>
8080
You are an AI assistant that extracts table names that are relevant to the users query that will be used to generate an SQL query later.
81-
- Ensure that table names are exact and match the names in the input including schema if given.
82-
- Use only and only the tables that are relevant to the query.
81+
- Consider not just the user query but also the context and the table descriptions while selecting the tables.
82+
- Carefully consider each and every table before including or excluding it.
83+
- If doubtful about a table's relevance, include it anyway to give the SQL generation step more options to choose from.
8384
- Assume that the table would have appropriate columns for relating them to any other table even if the description does not mention it.
8485
- If you are not sure about the tables to select from the given schema, just return your doubt asking the user for more details or to rephrase the question in the following format -
8586
failed attempt: reason for failure
@@ -96,14 +97,15 @@ Get me the employee with name Akshat
9697
</user-question>
9798
9899
<must-follow-rules>
99-
test context
100-
employee salary must be converted to USD, using the currency_id column and the exchange rate table
100+
- test context
101+
- employee salary must be converted to USD, using the currency_id column and the exchange rate table
101102
</must-follow-rules>
102103
103104
104105
105106
<output-format>
106107
The output should be just a comma separated list of table names with no other text, comments or formatting.
108+
Ensure that table names are exact and match the names in the input including schema if given.
107109
<example-output>
108110
public.employees, public.departments
109111
</example-output>

src/__tests__/db-query/unit/nodes/sql-generation.node.unit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ Do not use any DB concepts like enum numbers, joins, CTEs, subqueries etc. in th
463463
sinon.assert.calledOnce(llmStub);
464464
const prompt = llmStub.firstCall.args[0];
465465
expect(prompt.value).to.match(
466-
/Here is the last running SQL query that was generated by user that is supposed to be used as the base line for the next query generation\./,
466+
/Here is the last valid SQL query that was generated for the user that is supposed to be used as the base line for the next query generation\./,
467467
);
468468
expect(prompt.value).to.match(/SELECT name FROM employees WHERE id = 1/);
469469
expect(prompt.value).to.match(

src/__tests__/visualization/unit/visualizers/line.visualizer.unit.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('LineVisualizer Unit', function () {
3838
const validData = {
3939
xAxisColumn: 'date',
4040
yAxisColumn: 'value',
41-
seriesColumn: 'category',
41+
seriesColumns: 'category',
4242
};
4343

4444
const result = schema.safeParse(validData);
@@ -54,7 +54,7 @@ describe('LineVisualizer Unit', function () {
5454
const dataWithNullSeries = {
5555
xAxisColumn: 'date',
5656
yAxisColumn: 'value',
57-
seriesColumn: '',
57+
seriesColumns: '',
5858
};
5959

6060
const result = schema.safeParse(dataWithNullSeries);
@@ -143,7 +143,7 @@ describe('LineVisualizer Unit', function () {
143143
const mockLLMResponse = {
144144
xAxisColumn: 'month',
145145
yAxisColumn: 'revenue',
146-
seriesColumn: 'product_line',
146+
seriesColumns: 'product_line',
147147
};
148148

149149
const mockInvoke = sinon.stub().resolves(mockLLMResponse);
@@ -181,7 +181,7 @@ describe('LineVisualizer Unit', function () {
181181
const mockLLMResponse = {
182182
xAxisColumn: 'month',
183183
yAxisColumn: 'total_sales',
184-
seriesColumn: null,
184+
seriesColumns: null,
185185
};
186186

187187
const mockInvoke = sinon.stub().resolves(mockLLMResponse);
@@ -197,7 +197,7 @@ describe('LineVisualizer Unit', function () {
197197
const config = await visualizer.getConfig(validState);
198198

199199
expect(config).to.deepEqual(mockLLMResponse);
200-
expect(config.seriesColumn).to.be.null();
200+
expect(config.seriesColumns).to.be.null();
201201
});
202202

203203
it('should handle LLM errors gracefully', async () => {

src/components/db-query/nodes/get-tables.node.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export class GetTablesNode implements IGraphNode<DbQueryState> {
3232
prompt = PromptTemplate.fromTemplate(`
3333
<instructions>
3434
You are an AI assistant that extracts table names that are relevant to the users query that will be used to generate an SQL query later.
35-
3635
- Consider not just the user query but also the context and the table descriptions while selecting the tables.
3736
- Carefully consider each and every table before including or excluding it.
3837
- If doubtful about a table's relevance, include it anyway to give the SQL generation step more options to choose from.

0 commit comments

Comments
 (0)