From c2983ecbb74b7c7098cf034f26a06870ece196f7 Mon Sep 17 00:00:00 2001 From: Yeuoly Date: Thu, 12 Dec 2024 13:50:34 +0800 Subject: [PATCH] fix: rename stream to streaming --- api/core/plugin/backwards_invocation/app.py | 14 +++++++------- api/core/plugin/backwards_invocation/base.py | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/api/core/plugin/backwards_invocation/app.py b/api/core/plugin/backwards_invocation/app.py index a98f4169a7..b2b93749b5 100644 --- a/api/core/plugin/backwards_invocation/app.py +++ b/api/core/plugin/backwards_invocation/app.py @@ -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 diff --git a/api/core/plugin/backwards_invocation/base.py b/api/core/plugin/backwards_invocation/base.py index a945e6ca05..50efa2eeb1 100644 --- a/api/core/plugin/backwards_invocation/base.py +++ b/api/core/plugin/backwards_invocation/base.py @@ -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]):