SQL Visualization with

Describe the problem/error/question

Hey,
I’m trying to build a simple databse visualization worflow where

  • a chat input asks a question to the agent
  • the agent queries the database
  • the agent passes the result of the query to a chart visualization sub-workflow. This subworkflow is a copy pase of the one form the docs

What is the error message (if any)?

The agent generates a correct SQL query to the database which returns a correct result. The issue I have is that the agent passes the SQL query to the chart subworkflow instead of passing the result of the query

Here is the output of the database query (expected data in the output)

Here is the input of the “Generate chart” tool where the input is the SQL query instead of being the output of the SQL node.

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • **n8n version: ** [email protected]
  • **Database : Supabase **
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via n8n cloud
  • Operating system: macOS

Hi! so, your tool description a query describing the chart to generate and name of the field query confuses LLM, because of similarity to the SQL query. So, try the following:

  1. rename field name to chart_generation_data
  2. change description to something like data retrieved from get_patient_data tool, describing the chart to generate
  3. add an example flow of expected behavior in system prompt. E.g.
 when X, get data using `get_patient_data` tool. With the retrieved data format it as Y and pass to `generate_a_chart` tool in the following format:
{
"chart_generation_data": "[formatted data]"
}

please don’t just copy-paste 3rd step description, make it as detailed as possible. You can also write examples of negative paths, showing LLM how not to use the tool.

1 Like

thank you!

1 Like