-
Notifications
You must be signed in to change notification settings - Fork 28
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
feat: preserve extra fields in text event responses #127
Conversation
- 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: | |||
... |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some comments
Allows direct access to additional fields (e.g.,some_metrics) through BotMessage.data