fix: Add outputs support to SQLAgentComponent (#9173)

*  (sql.py): add new output definitions for the SQLAgentComponent to include 'Agent' and 'Response' outputs for better functionality and flexibility

* 📝 (sql.py): update import statement for Output class to match new file structure
♻️ (sql.py): refactor Output class usage to remove unnecessary attributes and improve code readability

---------

Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
This commit is contained in:
Cristhian Zanforlin Lousa 2025-08-01 11:23:59 -03:00 committed by GitHub
commit 73225f4d81
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5,6 +5,7 @@ from langchain_community.utilities import SQLDatabase
from langflow.base.agents.agent import LCAgentComponent
from langflow.inputs.inputs import HandleInput, MessageTextInput
from langflow.template.field.base import Output
class SQLAgentComponent(LCAgentComponent):
@ -25,6 +26,11 @@ class SQLAgentComponent(LCAgentComponent):
),
]
outputs = [
Output(display_name="Response", name="response", method="message_response"),
Output(display_name="Agent", name="agent", method="build_agent", tool_mode=False),
]
def build_agent(self) -> AgentExecutor:
db = SQLDatabase.from_uri(self.database_uri)
toolkit = SQLDatabaseToolkit(db=db, llm=self.llm)