Skip to content
Handling Repeated E...
 
Notifications
Clear all

Handling Repeated Execution of Postgres Tool with Split Data

5 Posts
2 Users
0 Reactions
4 Views
Winchell_yang
(@winchell_yang)
Posts: 3
Active Member
Topic starter
 

Hello callin.io community,

I'm running into a problem when attempting to run the PostgreSQL tool multiple times with data that has been split from a preceding node.

Here's my current workflow setup:

  1. Split Out Node: This node separates an array of items into individual entries.
  2. PostgreSQL Tool Node: This node executes the following SQL query:
    ```sql
    SELECT year, SUM(revenue) AS total_revenue FROM industry_output WHERE industry_label = 'AI' AND industry_track = 'SOC' AND year IN (2019, 2020, 2021, 2022, 2023) GROUP BY year ORDER BY year;
    ```

My objective is to have this PostgreSQL query executed for every item that the Split Out node produces. However, it appears that the PostgreSQL tool is only running once, utilizing the data from the initial item.

Here are my specific inquiries:

  • How can I set up the PostgreSQL tool to run the query for each item generated by the Split Out node?
  • Is it possible to incorporate data from the Split Out node into the PostgreSQL query, perhaps by using variables within the WHERE clause?
  • Are there any alternative methods or workarounds to accomplish this?

Any help or direction you can provide would be greatly appreciated.

Thank you!

 
Posted : 22/03/2025 11:49 am
lugnicca
(@lugnicca)
Posts: 2
New Member
 

Hello, is there a particular reason for designating PostgreSQL as a tool for the AI agent? Why not utilize an 'Execute SQL Query' node either before or after the AI agent node?

 
Posted : 22/03/2025 1:24 pm
Winchell_yang
(@winchell_yang)
Posts: 3
Active Member
Topic starter
 

The rationale for integrating PostgreSQL as a tool for the AI agent, as opposed to simply using an execute SQL query node before or after, stems from the fact that the preceding split node transmits a parameter that changes dynamically, referred to as industry_track. The AI agent is required to consistently query several distinct industry_track values, including but not limited to “AIchip,” “SoC,” and similar entries. Granting direct access to PostgreSQL enables the agent to manage these dynamic queries effectively within its operational flow.

 
Posted : 24/03/2025 1:59 pm
lugnicca
(@lugnicca)
Posts: 2
New Member
 

So, if I'm understanding correctly, your agent can only execute this specific query, and within your prompt, you have particular triggers for the AI to execute this query (for instance, if a certain condition is met, use the query tool X times)?

Normally, from my understanding of your workflow, the AI agent is invoked for each item generated by the split node. Therefore, I assume it's not calling the tool for a specific reason (perhaps the prompt or another factor?). Could you share the workflow so I can better understand the issue and conduct some tests?

 
Posted : 25/03/2025 8:42 am
Winchell_yang
(@winchell_yang)
Posts: 3
Active Member
Topic starter
 

Thanks for your help, I’ve managed to fix it with the loop node.

:grimacing:

 
Posted : 27/03/2025 6:43 am
Share: