openai-python
openai-python copied to clipboard
ChatML: name property should support '@' character
Describe the bug
Lots of existing usernames contain @ as namespace and prefixing. Complete understand why this is defined narrowly, but you are pushing a bunch of work on to developers and this surprised me.
File "/Users/dmp/Library/Python/3.9/lib/python/site-packages/openai/api_requestor.py", line 679, in interpret_response_line raise self.handle_error_response( openai.error.InvalidRequestError: '@username' does not match '^[a-zA-Z0-9-]{1,64}$' - 'messages.6.name'
To Reproduce

`#add the user + message in the third argument whoiam = getpass.getuser() whoiam = "@" + whoiam prompt = {"role": "user", "content": sys.argv[3], "name": whoiam}
#talk to chatGPT completion = openai.ChatCompletion.create( model = "gpt-3.5-turbo", messages = chatml + [prompt] )`
Code snippets
#add the user + message in the third argument
whoiam = getpass.getuser()
whoiam = "@" + whoiam
prompt = {"role": "user", "content": sys.argv[3], "name": whoiam}
#talk to chatGPT
completion = openai.ChatCompletion.create(
model = "gpt-3.5-turbo",
messages = chatml + [prompt]
)
OS
macOS
Python version
Python
Library version
openai-python
Currently the chat API uses the role
value to identify the "speaker" as the user, assistant, or system. Do you have a link to any documentation that mentions using the name
value?
@FizzyAgent see:
- https://github.com/openai/openai-python/blob/main/chatml.md#few-shot-prompting
- https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb (section 6)
But I do agree that it's weird that it's not specified in the official documentation.
In addition to @ character I would strongly suggest we enable:
- Space. A full name contains first name and space and last name.
- Any unicode characters.
Very useful for a multi user chatbot.
ß should also be enabled. It is a very common char for a chatbot
Thanks for filing, this feature request makes sense to me and I've pass it along to the backend teams.
I'm going to close this since it's not a limitation imposed in the Python library; if you'd like to continue to advocate for it, I recommend community.openai.com