langflow icon indicating copy to clipboard operation
langflow copied to clipboard

No stream_url when using Tool Calling Agent

Open thiagotps opened this issue 1 year ago • 2 comments

Bug Description

When calling the run api with stream=true , on a flow that uses the tool calling agent component, there is no stream_url in the answer. The api returns as if stream was set to false.

Reproduction

Just create a flow with the tool calling agent component, and try to run it through the api with stream=true

curl -X POST \
    "http://127.0.0.1:7860/api/v1/run/ebf006d1-0bb0-483f-be5e-4869943170b0?stream=true" \
    -H 'Content-Type: application/json'\
    -d '{"input_value": "message",
    "output_type": "chat",
    "input_type": "chat",
    "tweaks": {
  "ChatInput-faGMo": {},
  "ChatOutput-ylRIj": {},
  "AmazonBedrockModel-bBEen": {},
  "ToolCallingAgent-J1Adc": {},
  "DuckDuckGoSearch-1jkk8": {}
}}'

{
    "session_id": "ebf006d1-0bb0-483f-be5e-4869943170b0",
    "outputs": [
        {
            "inputs": {
                "input_value": "message"
            },
            "outputs": [
                {
                    "results": {
                        "message": {
                            "timestamp": "2024-11-16T20:01:16",
                            "sender": "Machine",
                            "sender_name": "AI",
                            "session_id": "ebf006d1-0bb0-483f-be5e-4869943170b0",
                            "text": "It looks like you just sent a message. What would you like to talk about or ask? I'm here to help.",
                            "files": [

                            ],
                            "error": false,
                            "edit": false,
                            "properties": {
                                "text_color": "",
                                "background_color": "",
                                "edited": false,
                                "source": {
                                    "id": "ToolCallingAgent-J1Adc",
                                    "display_name": "Tool Calling Agent",
                                    "source": "Tool Calling Agent"
                                },
                                "icon": "LangChain",
                                "allow_markdown": false,
                                "state": "complete",
                                "targets": [

                                ]
                            },
                            "category": "message",
                            "content_blocks": [
                                {
                                    "title": "Agent Steps",
                                    "contents": [
                                        {
                                            "type": "text",
                                            "duration": 7,
                                            "header": {
                                                "title": "Input",
                                                "icon": "MessageSquare"
                                            },
                                            "text": ""
                                        },
                                        {
                                            "type": "text",
                                            "duration": 1837,
                                            "header": {
                                                "title": "Output",
                                                "icon": "MessageSquare"
                                            },
                                            "text": "It looks like you just sent a message. What would you like to talk about or ask? I'm here to help."
                                        }
                                    ],
                                    "allow_markdown": true,
                                    "media_url": null
                                }
                            ],
                            "id": "3b20650e-b074-4c63-855a-0229634d2334",
                            "flow_id": "ebf006d1-0bb0-483f-be5e-4869943170b0"
                        }
                    },
                    "artifacts": {
                        "message": "It looks like you just sent a message. What would you like to talk about or ask? I'm here to help.",
                        "sender": "Machine",
                        "sender_name": "AI",
                        "files": [

                        ],
                        "type": "object"
                    },
                    "outputs": {
                        "message": {
                            "message": {
                                "timestamp": "2024-11-16 20:01:16 ",
                                "sender": "Machine",
                                "sender_name": "AI",
                                "session_id": "ebf006d1-0bb0-483f-be5e-4869943170b0",
                                "text": "It looks like you just sent a message. What would you like to talk about or ask? I'm here to help.",
                                "files": [

                                ],
                                "error": false,
                                "edit": false,
                                "properties": {
                                    "text_color": "",
                                    "background_color": "",
                                    "edited": false,
                                    "source": {
                                        "id": "ToolCallingAgent-J1Adc",
                                        "display_name": "Tool Calling Agent",
                                        "source": "Tool Calling Agent"
                                    },
                                    "icon": "LangChain",
                                    "allow_markdown": false,
                                    "state": "complete",
                                    "targets": [

                                    ]
                                },
                                "category": "message",
                                "content_blocks": [
                                    {
                                        "title": "Agent Steps",
                                        "contents": [
                                            {
                                                "type": "text",
                                                "duration": 7,
                                                "header": {
                                                    "title": "Input",
                                                    "icon": "MessageSquare"
                                                },
                                                "text": ""
                                            },
                                            {
                                                "type": "text",
                                                "duration": 1837,
                                                "header": {
                                                    "title": "Output",
                                                    "icon": "MessageSquare"
                                                },
                                                "text": "It looks like you just sent a message. What would you like to talk about or ask? I'm here to help."
                                            }
                                        ],
                                        "allow_markdown": true,
                                        "media_url": null
                                    }
                                ],
                                "id": "3b20650e-b074-4c63-855a-0229634d2334",
                                "flow_id": "ebf006d1-0bb0-483f-be5e-4869943170b0"
                            },
                            "type": "object"
                        }
                    },
                    "logs": {
                        "message": [

                        ]
                    },
                    "messages": [

                    ],
                    "component_display_name": "Chat Output",
                    "component_id": "ChatOutput-ylRIj",
                    "used_frozen_result": false
                }
            ]
        }
    ]
}

Expected behavior

Instead of the call to block until the model returns the last message, the api should simply return reponse contaning a stream_url field.

Who can help?

No response

Operating System

Arch Linux

Langflow Version

1.1.0 (commit efe64073246a3884abefae72ac3e78b14aa2695d)

Python Version

3.12

Screenshot

image

Flow File

No response

thiagotps avatar Nov 16 '24 20:11 thiagotps

The issue you're experiencing, where the stream_url is not included in the response when using the tool calling agent component with stream=true, could be related to how the stream parameter is processed or how the tool calling agent component interacts with the streaming logic.

The build_stream_url method is responsible for generating the streaming URL when stream=true. It is called correctly in scenarios where the message is an instance of AsyncIterator or Iterator [1]. If the tool calling agent component does not produce a message in this form, the stream_url might not be generated.

To address this, you might want to check if the tool calling agent component is configured to support streaming and if it produces messages as iterators. Additionally, ensure that the component's logic aligns with the expected behavior for streaming, as any deviation might prevent the stream_url from being included in the response.

To continue talking to Dosu, mention @dosu.

dosubot[bot] avatar Nov 16 '24 20:11 dosubot[bot]

A faced same issue when using Agent Component, someone can help???

tamdqa avatar Dec 29 '24 16:12 tamdqa

Please test it with the latest version and provide feedback. We are currently closing the issue; feel free to reopen it if you experience the issue again.

Thank you for your feedback.

edwinjosechittilappilly avatar Feb 03 '25 16:02 edwinjosechittilappilly