-
-
Save KyMidd/e4b21130598e7e29aa22f379a588d0ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Iterate over streamed chunks | |
| for chunk in streaming_response["stream"]: | |
| if "contentBlockDelta" in chunk: | |
| text = chunk["contentBlockDelta"]["delta"]["text"] | |
| response += text | |
| buffer += text | |
| token_counter += 1 | |
| if token_counter >= 10: | |
| client.chat_update( | |
| text=response, | |
| channel=channel_id, | |
| ts=message_ts | |
| ) | |
| # Every time we update to slack, we zero out the token counter and buffer | |
| token_counter = 0 | |
| buffer = "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment