Skip to content

Commit 6b91c01

Browse files
committed
feat(component): minor update in table selection
1 parent 3be121f commit 6b91c01

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ 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-
- Ensure that table names are exact and match the names in the input including schema if given.
36-
- Use only and only the tables that are relevant to the query.
35+
36+
- Consider not just the user query but also the context and the table descriptions while selecting the tables.
37+
- Carefully consider each and every table before including or excluding it.
38+
- If doubtful about a table's relevance, include it anyway to give the SQL generation step more options to choose from.
3739
- Assume that the table would have appropriate columns for relating them to any other table even if the description does not mention it.
3840
- 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 -
3941
failed attempt: reason for failure
@@ -53,6 +55,7 @@ failed attempt: reason for failure
5355
5456
<output-format>
5557
The output should be just a comma separated list of table names with no other text, comments or formatting.
58+
Ensure that table names are exact and match the names in the input including schema if given.
5659
<example-output>
5760
public.employees, public.departments
5861
</example-output>
@@ -111,8 +114,10 @@ Use these if they are relevant to the table selection, otherwise ignore them, th
111114
feedbacks: await this.getFeedbacks(state),
112115
checks: [
113116
`<must-follow-rules>`,
114-
...(this.checks ?? []),
115-
...this.schemaHelper.getTablesContext(dbSchema),
117+
...(this.checks ?? []).map(check => `- ${check}`),
118+
...this.schemaHelper
119+
.getTablesContext(dbSchema)
120+
.map(check => `- ${check}`),
116121
`</must-follow-rules>`,
117122
].join('\n'),
118123
});

0 commit comments

Comments
 (0)