Skip to content
Discussion options

You must be logged in to vote

In case someone is facing this in the future: my solution was to not use the community tool here the code.

def create_query_sql_database_tool(db, description: str):
    """
    Factory function to create a SQL query execution tool with an internal DB connection.

    This ensures that the LLM does not need to pass the `db` object directly.
    """

    @tool
    async def query_sql_database(
        query: str,
        variable_name: str,
        state: Annotated[dict, InjectedState],
        tool_call_id: Annotated[str, InjectedToolCallId],
        config: RunnableConfig = None,  # Optional, keeps tool compatible with LangGraph
    ) -> Union[str, Dict[str, Any]]:
        """
        Exe…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by MischaRauch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant