-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LangChain await bug with SQLAgent #3778
Comments
Hey there, @ch4mploo! I'm Dosu, a bot here to help you with bug resolutions, questions, and contributions. I'm here to assist you while we wait for a human maintainer. To resolve the "Error building Component SQLAgent: object LangfuseResponseGeneratorSync can't be used in 'await' expression" issue when using OpenAI as the model component in LangFlow version 1.0.18, ensure that the Here is a general approach to resolve such issues:
Example CorrectionIncorrect Usage# Hypothetical incorrect usage
response_generator = LangfuseResponseGeneratorSync()
result = await response_generator.generate_response() # Incorrect: Awaiting a sync method Correct Usage# Correct usage
response_generator = LangfuseResponseGeneratorSync()
result = response_generator.generate_response() # Correct: No await for sync method If # If there is an async version
response_generator = LangfuseResponseGeneratorAsync()
result = await response_generator.generate_response() # Correct: Awaiting an async method Additionally, you can refer to the async def build_vertex(
flow_id: uuid.UUID,
vertex_id: str,
background_tasks: BackgroundTasks,
inputs: Annotated[InputValueRequest | None, Body(embed=True)] = None,
files: list[str] | None = None,
chat_service: "ChatService" = Depends(get_chat_service),
current_user=Depends(get_current_active_user),
telemetry_service: "TelemetryService" = Depends(get_telemetry_service),
):
# Function implementation
try:
vertex_build_result = await graph.build_vertex(
vertex_id=vertex_id,
user_id=current_user.id,
inputs_dict=inputs.model_dump() if inputs else {},
files=files,
get_cache=chat_service.get_cache,
set_cache=chat_service.set_cache,
)
# Further processing
except Exception as exc:
# Error handling By following these guidelines and reviewing the provided examples, you should be able to resolve the issue effectively [1][2]. |
I think I found the solution. Based on PR #3775, it seems that the code change in line 147 of src/backend/base/langflow/base/agents/agent.py is applied to the class LCToolsAgentComponent to modify the run_agent method. However, the same method for its parent class, LCAgentComponent, did not receive similar modification, which I assumed it should since it has its own run_agent method as well. So I've applied a similar change you did for line 147 to line 101. Modification of line 101:
After the modification, the SQLAgent component has run without error. |
maybe related to #3840 |
Bug Description
LangFlow version: 1.0.18
Problem: Same issue as mentioned in the fix from PR #3775.
Details:
a. The flow works with Ollama as the model component.
b. The same error occurs when OpenAI is used as the model component for the SQLAgent.
Reproduction
You may refer to the flow file as reference.
SQLAgent Flow.json
Expected behavior
An error occurs on SQLAgent component.
Error message from notification:
"Error building Component SQLAgent: object LangfuseResponseGeneratorSync can't be used in 'await' expression"
Who can help?
No response
Operating System
Windows 11
Langflow Version
1.0.18
Python Version
3.12
Screenshot
No response
Flow File
No response
The text was updated successfully, but these errors were encountered: