Replies: 2 comments
-
Hey @garmeeh! Great to see you back. Hope you've been doing well since our last interaction. 😊 Based on the context provided, it seems like the issue you're encountering is related to how sessions and roles are managed when using the SQL agent in LangChain JS. The SQL agent in LangChain JS does not inherently manage sessions or roles. It is designed to execute SQL queries and return the results. Any session or role management needs to be handled externally before invoking the SQL agent. In your case, you're setting the role and session using To resolve this issue, you need to set the session and role within the context of the SQL agent. Here's an example of how you can do this: const executor = createSqlAgent(model, toolkit, {
beforeInvoke: async () => {
// Set the role to anon
await datasource.query("SET ROLE 'anon';");
// Set session to the incorrect user id
await datasource.query(`SET myapp.user_id = '123';`);
},
}); In this example, the Please note that this is a workaround and might not be the most efficient solution, especially if you're invoking the SQL agent multiple times in a short period, as it sets the session and role for each invocation. A more efficient solution would be to enhance the SQL agent to support session and role management, but that would require changes to the LangChain JS framework itself. I hope this helps! If you have any further questions, feel free to ask. Sources
|
Beta Was this translation helpful? Give feedback.
-
This code achieves the desired outcome. I could be missing something simple that will make this far more optimal without the extra step. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Beta Was this translation helpful? Give feedback.
All reactions