python-slack-sdk
python-slack-sdk copied to clipboard
feat: accept chunks as arguments to chat.{start,append,stop}Stream methods
Summary
This PR introduces the chunks argument to the following methods:
⚠️ This feature is experimental at the moment!
Testing
The following code snippet might be interesting to experiment with:
import time
...
streamer = client.chat_startStream(
channel=channel_id,
recipient_team_id=team_id,
recipient_user_id=user_id,
thread_ts=thread_ts,
chunks=[
MarkdownTextChunk(text="**onwards processing**"),
TaskUpdateChunk(
id="12",
title="counting bytes...",
status="in_progress",
),
],
)
time.sleep(4)
client.chat_appendStream(
channel=channel_id,
ts=streamer.get("ts"),
markdown_text="",
chunks=[
TaskUpdateChunk(
id="12",
title="adding numbers...",
status="in_progress",
details="sums have increased",
)
],
)
time.sleep(4)
client.chat_stopStream(
channel=channel_id,
ts=streamer.get("ts"),
chunks=[
TaskUpdateChunk(
id="12",
title="solved equation!",
status="complete",
sources=[
URLSource(
url="https://oeis.org",
text="The On-Line Encyclopedia of Integer Sequences (OEIS)",
),
],
),
MarkdownTextChunk(text="that computes."),
],
)
Category
- [x] slack_sdk.web.WebClient (sync/async) (Web API client)
- [x] slack_sdk.models (UI component builders)
- [ ]
/docs(Documents) - [ ]
tests/integration_tests(Automated tests for this library)
Notes
- Planning to add tests alongside these methods soon!
- Unsure if these are the best naming for "models" and I'm open to suggestions!
Requirements
- [x] I've read and understood the Contributing Guidelines and have done my best effort to follow them.
- [x] I've read and agree to the Code of Conduct.
- [ ] I've run
python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.shafter making the changes.