Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions listeners/assistant/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,23 +118,23 @@ def respond_in_assistant_thread(

returned_message = call_llm(messages_in_thread)

stream_response = client.chat_startStream(
streamer = client.chat_stream(
channel=channel_id,
recipient_team_id=team_id,
recipient_user_id=user_id,
thread_ts=thread_ts,
)
stream_ts = stream_response["ts"]

# use of this for loop is specific to openai response method
# Loop over OpenAI response stream
# https://platform.openai.com/docs/api-reference/responses/create
Comment on lines +128 to +129
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added commit 15d6bce to keep the comments consistent between the assistant and app_mention files.

for event in returned_message:
if event.type == "response.output_text.delta":
client.chat_appendStream(channel=channel_id, ts=stream_ts, markdown_text=f"{event.delta}")
streamer.append(markdown_text=f"{event.delta}")
else:
continue

feedback_block = create_feedback_block()
client.chat_stopStream(channel=channel_id, ts=stream_ts, blocks=feedback_block)
streamer.stop(blocks=feedback_block)

except Exception as e:
logger.exception(f"Failed to handle a user message event: {e}")
Expand Down
14 changes: 7 additions & 7 deletions listeners/events/app_mentioned.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@ def app_mentioned_callback(client: WebClient, event: dict, logger: Logger, say:

returned_message = call_llm([{"role": "user", "content": text}])

stream_response = client.chat_startStream(
channel=channel_id, recipient_team_id=team_id, recipient_user_id=user_id, thread_ts=thread_ts
streamer = client.chat_stream(
channel=channel_id,
recipient_team_id=team_id,
recipient_user_id=user_id,
thread_ts=thread_ts,
Comment on lines +37 to +41
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: Thanks @srtaalej for improving this formatting!

)

stream_ts = stream_response["ts"]

# Loop over OpenAI response stream
# https://platform.openai.com/docs/api-reference/responses/create
for event in returned_message:
if event.type == "response.output_text.delta":
client.chat_appendStream(channel=channel_id, ts=stream_ts, markdown_text=f"{event.delta}")
streamer.append(markdown_text=f"{event.delta}")
else:
continue

feedback_block = create_feedback_block()
client.chat_stopStream(channel=channel_id, ts=stream_ts, blocks=feedback_block)

streamer.stop(blocks=feedback_block)
except Exception as e:
logger.exception(f"Failed to handle a user message event: {e}")
say(f":warning: Something went wrong! ({e})")
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
slack-sdk==3.36.0.dev5
slack-bolt==1.26.0.dev2
slack-sdk==3.36.0.dev6
slack-bolt==1.26.0.dev3

# If you use a different LLM vendor, replace this dependency
openai
Expand Down