Skip to content

Commit

Permalink
Simplify assistants
Browse files Browse the repository at this point in the history
  • Loading branch information
markwaddle committed Oct 31, 2024
1 parent 7d84011 commit cec0a2f
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 27 deletions.
6 changes: 1 addition & 5 deletions assistants/explorer-assistant/assistant/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ async def on_message_created(
- @assistant.events.conversation.message.on_created
"""

# ignore messages from this assistant
if message.sender.participant_id == context.assistant.id:
return

# update the participant status to indicate the assistant is thinking
async with context.set_status_for_block("thinking..."):
config = await assistant_config.get(context.assistant)
Expand Down Expand Up @@ -413,7 +409,7 @@ async def respond_to_conversation(

# check if the completion total tokens exceed the warning threshold
if completion_total_tokens > token_count_for_warning:
content = f"{config.high_token_usage_warning.message}\n\n" f"Total tokens used: {completion_total_tokens}"
content = f"{config.high_token_usage_warning.message}\n\nTotal tokens used: {completion_total_tokens}"

# send a notice message to the conversation that the token usage is high
await context.send_messages(
Expand Down
4 changes: 0 additions & 4 deletions assistants/guided-conversation-assistant/assistant/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,6 @@ async def on_message_created(
- @assistant.events.conversation.message.on_created
"""

# ignore messages from this assistant
if message.sender.participant_id == context.assistant.id:
return

# update the participant status to indicate the assistant is thinking
await context.update_participant_me(UpdateParticipant(status="thinking..."))
try:
Expand Down
4 changes: 0 additions & 4 deletions assistants/prospector-assistant/assistant/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@ async def on_chat_message_created(
- @assistant.events.conversation.message.on_created
"""

# ignore messages from this assistant
if message.sender.participant_id == context.assistant.id:
return

# update the participant status to indicate the assistant is thinking
async with context.set_status_for_block("thinking..."):
config = await assistant_config.get(context.assistant)
Expand Down
8 changes: 0 additions & 8 deletions assistants/skill-assistant/assistant/skill_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ async def on_message_created(
- @assistant.events.conversation.message.on_created
"""

# ignore messages from this assistant
if message.sender.participant_id == context.assistant.id:
return

# pass the message to the core response logic
await respond_to_conversation(context, event, message)

Expand All @@ -118,10 +114,6 @@ async def on_command_message_created(
Handle the event triggered when a new command message is created in the conversation.
"""

# ignore messages from this assistant
if message.sender.participant_id == context.assistant.id:
return

# pass the message to the core response logic
await respond_to_conversation(context, event, message)

Expand Down
3 changes: 0 additions & 3 deletions examples/python/python-02-simple-chatbot/assistant/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ async def on_message_created(
- To handle all message types, you can use the root event handler for all message types:
- @assistant.events.conversation.message.on_created
"""
# ignore messages from this assistant
if message.sender.participant_id == context.assistant.id:
return

# update the participant status to indicate the assistant is thinking
await context.update_participant_me(UpdateParticipant(status="thinking..."))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ async def on_message_created(
- To handle all message types, you can use the root event handler for all message types:
- @assistant.events.conversation.message.on_created
"""
# ignore messages from this assistant
if message.sender.participant_id == context.assistant.id:
return

# update the participant status to indicate the assistant is thinking
await context.update_participant_me(UpdateParticipant(status="thinking..."))
Expand Down

0 comments on commit cec0a2f

Please sign in to comment.