diff --git a/docs/en_US/release_notes_9_14.rst b/docs/en_US/release_notes_9_14.rst index f841dcd5cd5..e9c9e6bf7af 100644 --- a/docs/en_US/release_notes_9_14.rst +++ b/docs/en_US/release_notes_9_14.rst @@ -28,6 +28,7 @@ Housekeeping Bug fixes ********* + | `Issue #9729 `_ - Fixed an issue where some LLM models would not use database tools in the AI assistant, instead returning text descriptions of tool calls. | `Issue #9279 `_ - Fixed an issue where OAuth2 authentication fails with 'object has no attribute' if OAUTH2_AUTO_CREATE_USER is False. | `Issue #9392 `_ - Ensure that the Geometry Viewer refreshes when re-running queries or switching geometry columns, preventing stale data from being displayed. | `Issue #9721 `_ - Fixed an issue where permissions page is not completely accessible on full scroll. diff --git a/web/pgadmin/llm/prompts/nlq.py b/web/pgadmin/llm/prompts/nlq.py index 78dd337466a..e40854292c4 100644 --- a/web/pgadmin/llm/prompts/nlq.py +++ b/web/pgadmin/llm/prompts/nlq.py @@ -13,12 +13,19 @@ integrated into pgAdmin 4. Your task is to generate SQL queries based on natural language requests. -You have access to database inspection tools: -- get_database_schema: Get list of schemas, tables, and views in the database +You have access to tools for inspecting the database. ALWAYS use \ +them when you need to understand the database structure: +- get_database_schema: Get list of schemas, tables, and views \ +in the database. Call this first to discover what's available. +- get_table_columns: Get column details for a specific table. - get_table_info: Get detailed column, constraint, and \ -index information for a table +index information for a table. - execute_sql_query: Run read-only queries to understand \ -data structure (SELECT only) +data structure (SELECT only). + +IMPORTANT: You MUST use these tools by calling them directly \ +(not by describing them in text). Start by calling \ +get_database_schema to discover available tables. Guidelines: - Use get_database_schema to discover available tables before writing queries @@ -28,11 +35,12 @@ - Use explicit column names instead of SELECT * - For UPDATE/DELETE, always include WHERE clauses -Your response MUST be a JSON object in this exact format: +Once you have explored the database structure using the tools above, \ +provide your final answer as a JSON object in this exact format: {"sql": "YOUR SQL QUERY HERE", "explanation": "Brief explanation"} -Rules: -- Return ONLY the JSON object, nothing else +Rules for the final response: +- Return ONLY the JSON object, no other text - No markdown code blocks - If you need clarification, set "sql" to null and put \ your question in "explanation"