Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: preserve extra fields in text event responses #127

Closed

Conversation

YushengAuggie
Copy link
Contributor

  • Pass complete data_dict to BotMessage.data field
  • Add unit tests for extra fields handling

Allows direct access to additional fields (e.g.,some_metrics) through BotMessage.data

- Pass complete data_dict to BotMessage.data field
- Add unit tests for extra fields handling

Allows direct access to additional fields (e.g., waiting_time_us)
through BotMessage.data
- Pass complete data_dict to BotMessage.data field
- Add unit tests for extra fields handling

Allows direct access to additional fields (e.g., waiting_time_us)
through BotMessage.data
- Pass complete data_dict to BotMessage.data field
- Add unit tests for extra fields handling

Allows direct access to additional fields (e.g., waiting_time_us)
through BotMessage.data
@@ -297,7 +298,8 @@ async def post_message_attachment(
filename: Optional[str] = None,
content_type: Optional[str] = None,
is_inline: bool = False,
) -> AttachmentUploadResponse: ...
) -> AttachmentUploadResponse:
...

Choose a reason for hiding this comment

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

lol lint

def text_event(text: str) -> ServerSentEvent:
return ServerSentEvent(data=json.dumps({"text": text}), event="text")
def text_event(
text: str, data: Optional[Dict[str, Any]] = dict()

Choose a reason for hiding this comment

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

let's make this data: Optional[MappingProxyType] = None since we don't want default args and if we're passing this dict around, we prob want it to be read-only? (have ppl copy it like {**data} if they need to create a mutable copy)

assert isinstance(messages[0].raw_response, dict)
assert "text" in messages[0].raw_response
parsed_data = json.loads(messages[0].raw_response["text"])
assert parsed_data.get("extra_field") == "extra_value"

Choose a reason for hiding this comment

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

let's have different values for these between the messages

Copy link

@994125010 994125010 left a comment

Choose a reason for hiding this comment

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

some comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants