langflow-ai / langflow

Langflow is a low-code app builder for RAG and multi-agent AI applications. It’s Python-based and agnostic to any model, API, or database.
http://www.langflow.org
MIT License
34.4k stars 4.14k forks source link

SQLAgent requiring "chat_history"? #4663

Open SavvySupport opened 4 hours ago

SavvySupport commented 4 hours ago

Bug Description

The SQLAgent shows error "chat_history not found in SQLAgentComponent".

Reproduction

  1. Build a flow with "OpenAI" (or equivalent LLM) and "SQLAgent" component
  2. Enter in API key for OpenAI, input and database URI for SQLAgent
  3. Run the SQLAgent
  4. Returns error below

Error building Component SQLAgent:

chat_history not found in SQLAgentComponent

Traceback (most recent call last): File "/langflow1.1.0/venv1.1.0/lib/python3.10/site-packages/langflow/graph/vertex/base.py", line 708, in _build_results result = await initialize.loading.get_instance_results( File "/langflow1.1.0/venv1.1.0/lib/python3.10/site-packages/langflow/interface/initialize/loading.py", line 68, in get_instance_results return await build_component(params=custom_params, custom_component=custom_component) File "/langflow1.1.0/venv1.1.0/lib/python3.10/site-packages/langflow/interface/initialize/loading.py", line 145, in build_component build_results, artifacts = await custom_component.build_results() File "/langflow1.1.0/venv1.1.0/lib/python3.10/site-packages/langflow/custom/custom_component/component.py", line 837, in build_results return await self._build_with_tracing() File "/langflow1.1.0/venv1.1.0/lib/python3.10/site-packages/langflow/custom/custom_component/component.py", line 819, in _build_with_tracing _results, _artifacts = await self._build_results() File "/langflow1.1.0/venv1.1.0/lib/python3.10/site-packages/langflow/custom/custom_component/component.py", line 883, in _build_results result = await method() File "/langflow1.1.0/venv1.1.0/lib/python3.10/site-packages/langflow/base/agents/agent.py", line 81, in message_response message = await self.run_agent(agent=agent) File "/langflow1.1.0/venv1.1.0/lib/python3.10/site-packages/langflow/base/agents/agent.py", line 136, in run_agent if self.chat_history: File "/langflow1.1.0/venv1.1.0/lib/python3.10/site-packages/langflow/custom/custom_component/component.py", line 665, in getattr raise AttributeError(msg) AttributeError: chat_history not found in SQLAgentComponent

Expected behavior

Expecting a response from the SQLAgent, instead of an error message for "chat_history"

Who can help?

No response

Operating System

MacOS

Langflow Version

1.1

Python Version

3.10

Screenshot

Screenshot 2024-11-18 at 5 03 33 pm Screenshot 2024-11-18 at 5 03 56 pm

Flow File

No response

dosubot[bot] commented 4 hours ago

The error you're encountering, "chat_history not found in SQLAgentComponent," suggests that the chat_history attribute is expected but not properly initialized or included in your setup. The chat_history is typically used to store previous interactions in a chat session, allowing the agent to maintain context or continuity in interactions [1][2].

To resolve this issue, you should ensure that the chat_history attribute is correctly initialized in your flow. This might involve explicitly defining or passing a chat_history parameter when setting up the SQLAgentComponent. If the component or flow setup does not automatically handle this, you may need to manually add a chat_history input or ensure that the component's configuration includes it as a DataInput.

If the issue persists, it might be helpful to check if there are any recent changes or updates in the codebase related to the SQLAgentComponent that could have introduced this requirement.

To continue talking to Dosu, mention @dosu.