Open Ark-kun opened 3 months ago
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.
Message.to_dict
bytes
int
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'}
Message.to_dict
returnsbytes
fields as Base-64 encoded strings instead of proper bytes strings. It also returns integers as strings instead ofint
.Environment details
Steps to reproduce