mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-19 06:35:56 +08:00
fix: rename stream to streaming
This commit is contained in:
parent
527c1cf608
commit
c2983ecbb7
@ -26,7 +26,7 @@ class PluginAppBackwardsInvocation(BaseBackwardsInvocation):
|
||||
stream: bool,
|
||||
inputs: Mapping,
|
||||
files: list[dict],
|
||||
) -> Generator[dict | str, None, None] | dict:
|
||||
) -> Generator[Mapping | str, None, None] | Mapping:
|
||||
"""
|
||||
invoke app
|
||||
"""
|
||||
@ -60,7 +60,7 @@ class PluginAppBackwardsInvocation(BaseBackwardsInvocation):
|
||||
stream: bool,
|
||||
inputs: Mapping,
|
||||
files: list[dict],
|
||||
) -> Generator[dict | str, None, None] | dict:
|
||||
) -> Generator[Mapping | str, None, None] | Mapping:
|
||||
"""
|
||||
invoke chat app
|
||||
"""
|
||||
@ -80,7 +80,7 @@ class PluginAppBackwardsInvocation(BaseBackwardsInvocation):
|
||||
"conversation_id": conversation_id,
|
||||
},
|
||||
invoke_from=InvokeFrom.SERVICE_API,
|
||||
stream=stream,
|
||||
streaming=stream,
|
||||
)
|
||||
elif app.mode == AppMode.AGENT_CHAT.value:
|
||||
return AgentChatAppGenerator().generate(
|
||||
@ -93,7 +93,7 @@ class PluginAppBackwardsInvocation(BaseBackwardsInvocation):
|
||||
"conversation_id": conversation_id,
|
||||
},
|
||||
invoke_from=InvokeFrom.SERVICE_API,
|
||||
stream=stream,
|
||||
streaming=stream,
|
||||
)
|
||||
elif app.mode == AppMode.CHAT.value:
|
||||
return ChatAppGenerator().generate(
|
||||
@ -106,7 +106,7 @@ class PluginAppBackwardsInvocation(BaseBackwardsInvocation):
|
||||
"conversation_id": conversation_id,
|
||||
},
|
||||
invoke_from=InvokeFrom.SERVICE_API,
|
||||
stream=stream,
|
||||
streaming=stream,
|
||||
)
|
||||
else:
|
||||
raise ValueError("unexpected app type")
|
||||
@ -133,7 +133,7 @@ class PluginAppBackwardsInvocation(BaseBackwardsInvocation):
|
||||
user=user,
|
||||
args={"inputs": inputs, "files": files},
|
||||
invoke_from=InvokeFrom.SERVICE_API,
|
||||
stream=stream,
|
||||
streaming=stream,
|
||||
call_depth=1,
|
||||
)
|
||||
|
||||
@ -154,7 +154,7 @@ class PluginAppBackwardsInvocation(BaseBackwardsInvocation):
|
||||
user=user,
|
||||
args={"inputs": inputs, "files": files},
|
||||
invoke_from=InvokeFrom.SERVICE_API,
|
||||
stream=stream,
|
||||
streaming=stream,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
@ -1,12 +1,12 @@
|
||||
from collections.abc import Generator
|
||||
from typing import Generic, Optional, TypeVar
|
||||
from typing import Generic, Mapping, Optional, TypeVar
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class BaseBackwardsInvocation:
|
||||
@classmethod
|
||||
def convert_to_event_stream(cls, response: Generator[BaseModel | dict | str, None, None] | BaseModel | dict):
|
||||
def convert_to_event_stream(cls, response: Generator[BaseModel | Mapping | str, None, None] | BaseModel | Mapping):
|
||||
if isinstance(response, Generator):
|
||||
try:
|
||||
for chunk in response:
|
||||
@ -21,7 +21,7 @@ class BaseBackwardsInvocation:
|
||||
yield BaseBackwardsInvocationResponse(data=response).model_dump_json().encode() + b"\n\n"
|
||||
|
||||
|
||||
T = TypeVar("T", bound=dict | str | bool | int | BaseModel)
|
||||
T = TypeVar("T", bound=dict | Mapping | str | bool | int | BaseModel)
|
||||
|
||||
|
||||
class BaseBackwardsInvocationResponse(BaseModel, Generic[T]):
|
||||
|
Loading…
x
Reference in New Issue
Block a user