import { PromptTemplate } from '@langchain/core/prompts'; import { IGraphNode, RunnableConfig } from '../../../graphs'; import { LLMProvider } from '../../../types'; import { DbSchemaHelperService } from '../services'; import { DbQueryState } from '../state'; import { DbQueryConfig } from '../types'; export declare class GetColumnsNode implements IGraphNode { private readonly llm; private readonly schemaHelper; private readonly config; private readonly checks?; constructor(llm: LLMProvider, schemaHelper: DbSchemaHelperService, config: DbQueryConfig, checks?: string[] | undefined); prompt: PromptTemplate\nYou are an AI assistant that identifies relevant columns from database tables based on a user's query.\nGiven a set of tables with their columns, you need to identify which columns are relevant to answer the user's query.\n\nFor each table, return only the column names that are relevant to the query. Include:\n1. Columns directly mentioned or implied in the query\n2. Primary key columns (always needed for joins and identification)\n3. Foreign key columns (needed for relationships)\n4. Columns that might be needed for filtering, sorting, or calculations\n5. It is better to include a few extra relevant columns than to miss important ones.\n\nDo not include:\n- Columns that are clearly irrelevant to the query\n- Descriptions, types, or any other metadata about the columns\n\nReturn the result as a JSON object where each table name is a key and the value is an array of relevant column names.\nIf you are not sure about which columns to select, return your doubt asking the user for more details in the following format:\nfailed attempt: \n\n\n\n{tablesWithColumns}\n\n\n\n{query}\n\n\n{checks}\n\n{feedbacks}\n\n\nReturn a valid JSON object with table names as keys and arrays of column names as values.\nExample format (do not copy these exact values):\n{{\n \"table_name1\": [\"column1\", \"column2\", \"column3\"],\n \"table_name2\": [\"column1\", \"column2\"]\n}}\n\nIn case of failure, return the failure message in the format:\nfailed attempt: \n">, any>; feedbackPrompt: PromptTemplate\nWe also need to consider the errors from last attempt at query generation.\n\nIn the last attempt, these were the columns selected:\n{lastColumns}\n\nBut it was rejected with the following errors:\n{feedback}\n\nUse these errors to refine your column selection. Consider if you need additional columns for joins, filtering, or calculations.\n\n">, any>; execute(state: DbQueryState, config: RunnableConfig): Promise; getFeedbacks(state: DbQueryState): Promise; private _getTablesWithColumns; private _validateColumns; private _createFilteredSchema; private _getSelectedColumnsFromSchema; }