Skip to content

Commit 00b8652

Browse files
committed
feat: add plan_update chunk for chat streaming
1 parent 7c32814 commit 00b8652

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

slack_sdk/models/messages/chunk.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,29 @@ def __init__(
6767
self.text = text
6868

6969

70+
class PlanUpdateChunk(Chunk):
71+
type = "plan_update"
72+
73+
@property
74+
def attributes(self) -> Set[str]: # type: ignore[override]
75+
return super().attributes.union({"title"})
76+
77+
def __init__(
78+
self,
79+
*,
80+
title: str,
81+
**others: Dict,
82+
):
83+
"""An updated title of plans for task and tool calls.
84+
85+
https://docs.slack.dev/messaging/sending-and-scheduling-messages#text-streaming
86+
"""
87+
super().__init__(type=self.type)
88+
show_unknown_key_warning(self, others)
89+
90+
self.title = title
91+
92+
7093
class URLSource(JsonObject):
7194
type = "url"
7295

tests/slack_sdk/models/test_chunks.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import unittest
22

3-
from slack_sdk.models.messages.chunk import MarkdownTextChunk, TaskUpdateChunk, URLSource
3+
from slack_sdk.models.messages.chunk import MarkdownTextChunk, PlanUpdateChunk, TaskUpdateChunk, URLSource
44

55

66
class MarkdownTextChunkTests(unittest.TestCase):
@@ -14,6 +14,17 @@ def test_json(self):
1414
)
1515

1616

17+
class PlanUpdateChunkTests(unittest.TestCase):
18+
def test_json(self):
19+
self.assertDictEqual(
20+
PlanUpdateChunk(title="Crunching numbers...").to_dict(),
21+
{
22+
"type": "plan_update",
23+
"text": "Crunching numbers...",
24+
},
25+
)
26+
27+
1728
class TaskUpdateChunkTests(unittest.TestCase):
1829
def test_json(self):
1930
self.assertDictEqual(

0 commit comments

Comments
 (0)