Skip to content

Commit b1dc199

Browse files
zimegmwbrooks
andauthored
feat: add task_display_mode option to the start of chat streams (#1820)
Co-authored-by: Michael Brooks <mbrooks@slack-corp.com>
1 parent b031148 commit b1dc199

File tree

6 files changed

+24
-0
lines changed

6 files changed

+24
-0
lines changed

slack_sdk/web/async_chat_stream.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def __init__(
3939
buffer_size: int,
4040
recipient_team_id: Optional[str] = None,
4141
recipient_user_id: Optional[str] = None,
42+
task_display_mode: Optional[str] = None,
4243
**kwargs,
4344
):
4445
"""Initialize a new ChatStream instance.
@@ -54,6 +55,8 @@ def __init__(
5455
recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when
5556
streaming to channels.
5657
recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
58+
task_display_mode: Specifies how tasks are displayed in the message. A "timeline" displays individual tasks
59+
interleaved with text and "plan" displays all tasks together.
5760
buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
5861
decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
5962
**kwargs: Additional arguments passed to the underlying API calls.
@@ -66,6 +69,7 @@ def __init__(
6669
"thread_ts": thread_ts,
6770
"recipient_team_id": recipient_team_id,
6871
"recipient_user_id": recipient_user_id,
72+
"task_display_mode": task_display_mode,
6973
**kwargs,
7074
}
7175
self._buffer = ""

slack_sdk/web/async_client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2889,6 +2889,7 @@ async def chat_startStream(
28892889
recipient_team_id: Optional[str] = None,
28902890
recipient_user_id: Optional[str] = None,
28912891
chunks: Optional[Sequence[Union[Dict, Chunk]]] = None,
2892+
task_display_mode: Optional[str] = None, # timeline, plan
28922893
**kwargs,
28932894
) -> AsyncSlackResponse:
28942895
"""Starts a new streaming conversation.
@@ -2902,6 +2903,7 @@ async def chat_startStream(
29022903
"recipient_team_id": recipient_team_id,
29032904
"recipient_user_id": recipient_user_id,
29042905
"chunks": chunks,
2906+
"task_display_mode": task_display_mode,
29052907
}
29062908
)
29072909
_parse_web_class_objects(kwargs)
@@ -2944,6 +2946,7 @@ async def chat_stream(
29442946
thread_ts: str,
29452947
recipient_team_id: Optional[str] = None,
29462948
recipient_user_id: Optional[str] = None,
2949+
task_display_mode: Optional[str] = None,
29472950
**kwargs,
29482951
) -> AsyncChatStream:
29492952
"""Stream markdown text into a conversation.
@@ -2970,6 +2973,8 @@ async def chat_stream(
29702973
recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when
29712974
streaming to channels.
29722975
recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
2976+
task_display_mode: Specifies how tasks are displayed in the message. A "timeline" displays individual tasks
2977+
interleaved with text and "plan" displays all tasks together.
29732978
**kwargs: Additional arguments passed to the underlying API calls.
29742979
29752980
Returns:
@@ -2995,6 +3000,7 @@ async def chat_stream(
29953000
thread_ts=thread_ts,
29963001
recipient_team_id=recipient_team_id,
29973002
recipient_user_id=recipient_user_id,
3003+
task_display_mode=task_display_mode,
29983004
buffer_size=buffer_size,
29993005
**kwargs,
30003006
)

slack_sdk/web/chat_stream.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def __init__(
2929
buffer_size: int,
3030
recipient_team_id: Optional[str] = None,
3131
recipient_user_id: Optional[str] = None,
32+
task_display_mode: Optional[str] = None,
3233
**kwargs,
3334
):
3435
"""Initialize a new ChatStream instance.
@@ -44,6 +45,8 @@ def __init__(
4445
recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when
4546
streaming to channels.
4647
recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
48+
task_display_mode: Specifies how tasks are displayed in the message. A "timeline" displays individual tasks
49+
interleaved with text and "plan" displays all tasks together.
4750
buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
4851
decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
4952
**kwargs: Additional arguments passed to the underlying API calls.
@@ -56,6 +59,7 @@ def __init__(
5659
"thread_ts": thread_ts,
5760
"recipient_team_id": recipient_team_id,
5861
"recipient_user_id": recipient_user_id,
62+
"task_display_mode": task_display_mode,
5963
**kwargs,
6064
}
6165
self._buffer = ""

slack_sdk/web/client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2879,6 +2879,7 @@ def chat_startStream(
28792879
recipient_team_id: Optional[str] = None,
28802880
recipient_user_id: Optional[str] = None,
28812881
chunks: Optional[Sequence[Union[Dict, Chunk]]] = None,
2882+
task_display_mode: Optional[str] = None, # timeline, plan
28822883
**kwargs,
28832884
) -> SlackResponse:
28842885
"""Starts a new streaming conversation.
@@ -2892,6 +2893,7 @@ def chat_startStream(
28922893
"recipient_team_id": recipient_team_id,
28932894
"recipient_user_id": recipient_user_id,
28942895
"chunks": chunks,
2896+
"task_display_mode": task_display_mode,
28952897
}
28962898
)
28972899
_parse_web_class_objects(kwargs)
@@ -2934,6 +2936,7 @@ def chat_stream(
29342936
thread_ts: str,
29352937
recipient_team_id: Optional[str] = None,
29362938
recipient_user_id: Optional[str] = None,
2939+
task_display_mode: Optional[str] = None,
29372940
**kwargs,
29382941
) -> ChatStream:
29392942
"""Stream markdown text into a conversation.
@@ -2960,6 +2963,8 @@ def chat_stream(
29602963
recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when
29612964
streaming to channels.
29622965
recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
2966+
task_display_mode: Specifies how tasks are displayed in the message. A "timeline" displays individual tasks
2967+
interleaved with text and "plan" displays all tasks together.
29632968
**kwargs: Additional arguments passed to the underlying API calls.
29642969
29652970
Returns:
@@ -2985,6 +2990,7 @@ def chat_stream(
29852990
thread_ts=thread_ts,
29862991
recipient_team_id=recipient_team_id,
29872992
recipient_user_id=recipient_user_id,
2993+
task_display_mode=task_display_mode,
29882994
buffer_size=buffer_size,
29892995
**kwargs,
29902996
)

slack_sdk/web/legacy_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,6 +2890,7 @@ def chat_startStream(
28902890
recipient_team_id: Optional[str] = None,
28912891
recipient_user_id: Optional[str] = None,
28922892
chunks: Optional[Sequence[Union[Dict, Chunk]]] = None,
2893+
task_display_mode: Optional[str] = None, # timeline, plan
28932894
**kwargs,
28942895
) -> Union[Future, SlackResponse]:
28952896
"""Starts a new streaming conversation.
@@ -2903,6 +2904,7 @@ def chat_startStream(
29032904
"recipient_team_id": recipient_team_id,
29042905
"recipient_user_id": recipient_user_id,
29052906
"chunks": chunks,
2907+
"task_display_mode": task_display_mode,
29062908
}
29072909
)
29082910
_parse_web_class_objects(kwargs)

tests/slack_sdk/web/test_chat_stream.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ def test_streams_a_chunk_message(self):
185185
recipient_team_id="T0123456789",
186186
recipient_user_id="U0123456789",
187187
thread_ts="123.000",
188+
task_display_mode="timeline",
188189
)
189190
streamer.append(markdown_text="**this is ")
190191
streamer.append(markdown_text="buffered**")
@@ -223,6 +224,7 @@ def test_streams_a_chunk_message(self):
223224
)
224225
self.assertEqual(start_request.get("recipient_team_id"), "T0123456789")
225226
self.assertEqual(start_request.get("recipient_user_id"), "U0123456789")
227+
self.assertEqual(start_request.get("task_display_mode"), "timeline")
226228

227229
append_request = self.thread.server.chat_stream_requests.get("/chat.appendStream", {})
228230
self.assertEqual(append_request.get("channel"), "C0123456789")

0 commit comments

Comments
 (0)