Replies: 1 comment
-
@Aoaoao7 你好! 我是Dosu,一个可以帮助解决 bug、回答问题并帮助你成为贡献者的机器人。我会在此等待人类维护者,有什么我可以帮助你的吗? To implement a streaming response when a Dify agent invokes a workflow, you can use the import json
from typing import Mapping
from werkzeug import Request, Response
from dify_plugin import Endpoint
class Duck(Endpoint):
def _invoke(self, r: Request, values: Mapping, settings: Mapping) -> Response:
"""
Invoke the endpoint with the given request.
"""
app_id = values["app_id"]
def generator():
response = self.session.app.workflow.invoke(
app_id=app_id, inputs={}, response_mode="streaming", files=[]
)
for data in response:
yield f"{json.dumps(data)} <br>"
return Response(generator(), status=200, content_type="text/html") In this example, the To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
Beta Was this translation helpful? Give feedback.
-
Self Checks
Provide a description of requested docs changes
I want my workflow conversations to return data in a stream when invoked.
Beta Was this translation helpful? Give feedback.
All reactions