Skip to content

Commit c8cb744

Browse files
dpageclaude
andauthored
Fix model tool prompt
* Fix NLQ system prompt to work with models that prioritize text instructions over tool calls. The previous prompt told the model to "Return ONLY the JSON object, nothing else" while also providing tool definitions. Models like Qwen 3.5 would follow the text instruction and never use tools. The updated prompt clearly separates the tool-use phase from the final JSON response phase, and explicitly instructs the model to call tools directly rather than describing them in text. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Update release notes for NLQ prompt fix. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix issue number in release notes for NLQ prompt fix. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b3aa78c commit c8cb744

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

docs/en_US/release_notes_9_14.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Housekeeping
2929
Bug fixes
3030
*********
3131

32+
| `Issue #9729 <https://github.com/pgadmin-org/pgadmin4/issues/9729>`_ - Fixed an issue where some LLM models would not use database tools in the AI assistant, instead returning text descriptions of tool calls.
3233
| `Issue #9279 <https://github.com/pgadmin-org/pgadmin4/issues/9279>`_ - Fixed an issue where OAuth2 authentication fails with 'object has no attribute' if OAUTH2_AUTO_CREATE_USER is False.
3334
| `Issue #9392 <https://github.com/pgadmin-org/pgadmin4/issues/9392>`_ - Ensure that the Geometry Viewer refreshes when re-running queries or switching geometry columns, preventing stale data from being displayed.
3435
| `Issue #9721 <https://github.com/pgadmin-org/pgadmin4/issues/9721>`_ - Fixed an issue where permissions page is not completely accessible on full scroll.

web/pgadmin/llm/prompts/nlq.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,19 @@
1313
integrated into pgAdmin 4.
1414
Your task is to generate SQL queries based on natural language requests.
1515
16-
You have access to database inspection tools:
17-
- get_database_schema: Get list of schemas, tables, and views in the database
16+
You have access to tools for inspecting the database. ALWAYS use \
17+
them when you need to understand the database structure:
18+
- get_database_schema: Get list of schemas, tables, and views \
19+
in the database. Call this first to discover what's available.
20+
- get_table_columns: Get column details for a specific table.
1821
- get_table_info: Get detailed column, constraint, and \
19-
index information for a table
22+
index information for a table.
2023
- execute_sql_query: Run read-only queries to understand \
21-
data structure (SELECT only)
24+
data structure (SELECT only).
25+
26+
IMPORTANT: You MUST use these tools by calling them directly \
27+
(not by describing them in text). Start by calling \
28+
get_database_schema to discover available tables.
2229
2330
Guidelines:
2431
- Use get_database_schema to discover available tables before writing queries
@@ -28,11 +35,12 @@
2835
- Use explicit column names instead of SELECT *
2936
- For UPDATE/DELETE, always include WHERE clauses
3037
31-
Your response MUST be a JSON object in this exact format:
38+
Once you have explored the database structure using the tools above, \
39+
provide your final answer as a JSON object in this exact format:
3240
{"sql": "YOUR SQL QUERY HERE", "explanation": "Brief explanation"}
3341
34-
Rules:
35-
- Return ONLY the JSON object, nothing else
42+
Rules for the final response:
43+
- Return ONLY the JSON object, no other text
3644
- No markdown code blocks
3745
- If you need clarification, set "sql" to null and put \
3846
your question in "explanation"

0 commit comments

Comments
 (0)