Skip to content

Commit

Permalink
pipeline args names fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
pseusys committed Mar 2, 2024
1 parent 97c54a8 commit 738adff
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions dff/pipeline/pipeline/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Pipeline:
- key: :py:class:`~dff.script.ActorStage` - Stage in which the handler is called.
- value: List[Callable] - The list of called handlers for each stage. Defaults to an empty `dict`.
:param messenger_interface: An `AbsMessagingInterface` instance for this pipeline.
:param messenger_interfaces: An `AbsMessagingInterface` instance for this pipeline.
:param context_storage: An :py:class:`~.DBContextStorage` instance for this pipeline or
a dict to store dialog :py:class:`~.Context`.
:param services: (required) A :py:data:`~.ServiceGroupBuilder` object,
Expand Down Expand Up @@ -229,7 +229,7 @@ def from_script(
parallelize_processing: bool = False,
handlers: Optional[Dict[ActorStage, List[Callable]]] = None,
context_storage: Optional[Union[DBContextStorage, Dict]] = None,
messenger_interface: Optional[MessengerInterface] = None,
messenger_interfaces: Optional[Union[MessengerInterface, Iterable[MessengerInterface], Dict[str, MessengerInterface]]] = None,
pre_services: Optional[List[Union[ServiceBuilder, ServiceGroupBuilder]]] = None,
post_services: Optional[List[Union[ServiceBuilder, ServiceGroupBuilder]]] = None,
) -> "Pipeline":
Expand Down Expand Up @@ -261,7 +261,7 @@ def from_script(
:param context_storage: An :py:class:`~.DBContextStorage` instance for this pipeline
or a dict to store dialog :py:class:`~.Context`.
:param messenger_interface: An instance for this pipeline.
:param messenger_interfaces: An instance for this pipeline.
:param pre_services: List of :py:data:`~.ServiceBuilder` or
:py:data:`~.ServiceGroupBuilder` that will be executed before Actor.
:type pre_services: Optional[List[Union[ServiceBuilder, ServiceGroupBuilder]]]
Expand All @@ -282,7 +282,7 @@ def from_script(
verbose=verbose,
parallelize_processing=parallelize_processing,
handlers=handlers,
messenger_interface=messenger_interface,
messenger_interfaces=messenger_interfaces,
context_storage=context_storage,
components=[*pre_services, ACTOR, *post_services],
)
Expand Down
2 changes: 1 addition & 1 deletion dff/pipeline/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class ExtraHandlerRuntimeInfo(BaseModel):
PipelineBuilder: TypeAlias = TypedDict(
"PipelineBuilder",
{
"messenger_interface": NotRequired[Optional["MessengerInterface"]],
"messenger_interfaces": NotRequired[Optional[Union["MessengerInterface", Iterable["MessengerInterface"], Dict[str, "MessengerInterface"]]]],
"context_storage": NotRequired[Optional[Union[DBContextStorage, Dict]]],
"components": ServiceGroupBuilder,
"before_handler": NotRequired[Optional[ExtraHandlerBuilder]],
Expand Down
2 changes: 1 addition & 1 deletion tutorials/messengers/telegram/1_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class and [telebot](https://pytba.readthedocs.io/en/latest/index.html)
script=script,
start_label=("greeting_flow", "start_node"),
fallback_label=("greeting_flow", "fallback_node"),
messenger_interface=interface,
messenger_interfaces=interface,
# The interface can be passed as a pipeline argument.
)

Expand Down
2 changes: 1 addition & 1 deletion tutorials/messengers/telegram/2_buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class is used to represent telegram message,
script=script,
start_label=("root", "start"),
fallback_label=("root", "fallback"),
messenger_interface=interface,
messenger_interfaces=interface,
)


Expand Down
2 changes: 1 addition & 1 deletion tutorials/messengers/telegram/3_buttons_with_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class is used to represent telegram message,
script=script,
start_label=("root", "start"),
fallback_label=("root", "fallback"),
messenger_interface=interface,
messenger_interfaces=interface,
)


Expand Down
2 changes: 1 addition & 1 deletion tutorials/messengers/telegram/4_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
script=script,
start_label=("greeting_flow", "start_node"),
fallback_label=("greeting_flow", "fallback_node"),
messenger_interface=interface,
messenger_interfaces=interface,
)


Expand Down
2 changes: 1 addition & 1 deletion tutorials/messengers/telegram/5_conditions_with_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def extract_data(ctx: Context, _: Pipeline): # A function to extract data with
script=script,
start_label=("root", "start"),
fallback_label=("root", "fallback"),
messenger_interface=interface,
messenger_interfaces=interface,
pre_services=[extract_data],
)

Expand Down
2 changes: 1 addition & 1 deletion tutorials/messengers/telegram/6_conditions_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
script=script,
start_label=("greeting_flow", "start_node"),
fallback_label=("greeting_flow", "fallback_node"),
messenger_interface=interface,
messenger_interfaces=interface,
)


Expand Down
2 changes: 1 addition & 1 deletion tutorials/messengers/telegram/7_polling_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
# %%
pipeline = Pipeline.from_script(
*TOY_SCRIPT_ARGS,
messenger_interface=interface,
messenger_interfaces=interface,
# The interface can be passed as a pipeline argument
)

Expand Down
2 changes: 1 addition & 1 deletion tutorials/messengers/telegram/8_webhook_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
# %%
pipeline = Pipeline.from_script(
*TOY_SCRIPT_ARGS,
messenger_interface=interface,
messenger_interfaces=interface,
# The interface can be passed as a pipeline argument
)

Expand Down
6 changes: 3 additions & 3 deletions tutorials/messengers/web_api_interface/1_fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@
"""

# %%
messenger_interface = CallbackMessengerInterface()
messenger_interfaces = CallbackMessengerInterface()
# CallbackMessengerInterface instantiating the dedicated messenger interface
pipeline = Pipeline.from_script(
*TOY_SCRIPT_ARGS, messenger_interface=messenger_interface
*TOY_SCRIPT_ARGS, messenger_interfaces=messenger_interfaces
)


Expand All @@ -102,7 +102,7 @@ async def respond(
user_id: str,
user_message: Message,
):
context = await messenger_interface.on_request_async(user_message, user_id)
context = await messenger_interfaces.on_request_async(user_message, user_id)
return {"user_id": user_id, "response": context.last_response}


Expand Down
6 changes: 3 additions & 3 deletions tutorials/messengers/web_api_interface/2_websocket_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@


# %%
messenger_interface = CallbackMessengerInterface()
messenger_interfaces = CallbackMessengerInterface()
pipeline = Pipeline.from_script(
*TOY_SCRIPT_ARGS, messenger_interface=messenger_interface
*TOY_SCRIPT_ARGS, messenger_interfaces=messenger_interfaces
)


Expand Down Expand Up @@ -93,7 +93,7 @@ async def websocket_endpoint(websocket: WebSocket, client_id: int):
data = await websocket.receive_text()
await websocket.send_text(f"User: {data}")
request = Message(data)
context = await messenger_interface.on_request_async(
context = await messenger_interfaces.on_request_async(
request, client_id
)
response = context.last_response.text
Expand Down
2 changes: 1 addition & 1 deletion tutorials/pipeline/2_pre_and_post_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def pong_processor(ctx: Context):
context_storage={}, # `context_storage` - a dictionary or
# a `DBContextStorage` instance,
# a place to store dialog contexts
messenger_interface=CLIMessengerInterface(),
messenger_interfaces=CLIMessengerInterface(),
# `messenger_interface` - a message channel adapter,
# it's not used in this tutorial
pre_services=[ping_processor],
Expand Down
2 changes: 1 addition & 1 deletion tutorials/pipeline/3_pipeline_dict_with_services_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def postprocess(ctx: Context, pl: Pipeline):
"script": TOY_SCRIPT,
"start_label": ("greeting_flow", "start_node"),
"fallback_label": ("greeting_flow", "fallback_node"),
"messenger_interface": CLIMessengerInterface(
"messenger_interfaces": CLIMessengerInterface(
intro="Hi, this is a brand new Pipeline running!",
prompt_request="Request: ",
prompt_response="Response: ",
Expand Down

0 comments on commit 738adff

Please sign in to comment.