Skip to content

Unicode Character Encoding #15

@AlexDuchnowski

Description

@AlexDuchnowski

I got an error with a trace that ends with this:

response = self.client.chat.completions.create(
  File "C:\Users\<USER>\AppData\Local\Programs\Python\Python310\lib\site-packages\superopenai\wrap_openai.py", line 39, in create
    logger.log(ChatCompletionLog.create(
  File "C:\Users\<USER>\AppData\Local\Programs\Python\Python310\lib\site-packages\superopenai\state.py", line 31, in log
    self.filestream.write(str(log) + "\n")
  File "C:\Users\<USER>\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2248' in position 38028: character maps to <undefined>

This seems to happen quite rarely (first time I'm getting the error after sending hundreds of prompts through the API with the logger enabled). However, the character in question here is simply "≈"--nothing super strange--so it would be nice if the logger could handle writing something like this to a file. Seems this SO post may be relevant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions