-
Notifications
You must be signed in to change notification settings - Fork 37
Open
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Message.to_dict returns bytes fields as Base-64 encoded strings instead of proper bytes strings. It also returns integers as strings instead of int.
Environment details
- Programming language: Python
- OS: Linux
- Language runtime version: 3.10
- Package version: 1.24
Steps to reproduce
model = GenerativeModel("gemini-pro")
compute_tokens_response = model.compute_tokens(["Hello world!", "How are you?"])
token_info = compute_tokens_response.tokens_info[1]
>>> token_info
tokens: "How"
tokens: " are"
tokens: " you"
tokens: "?"
token_ids: 2299
token_ids: 708
token_ids: 692
token_ids: 235336
role: "user"
>>> type(token_info).to_dict(token_info)
{'tokens': ['SG93', 'IGFyZQ==', 'IHlvdQ==', 'Pw=='],
'token_ids': ['2299', '708', '692', '235336'],
'role': 'user'}
Metadata
Metadata
Assignees
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.