openai / openai-python

The official Python library for the OpenAI API
https://pypi.org/project/openai/
Apache License 2.0
21.81k stars 2.99k forks source link

ChatML: name property should support '@' character #309

Closed cancelself closed 9 months ago

cancelself commented 1 year ago

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_errorresponse( openai.error.InvalidRequestError: '@username' does not match '^[a-zA-Z0-9-]{1,64}$' - 'messages.6.name'

To Reproduce

image

`#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

tanpinxi commented 1 year ago

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?

ghost commented 1 year ago

@FizzyAgent see:

But I do agree that it's weird that it's not specified in the official documentation.

hzeng-otterai commented 1 year ago

In addition to @ character I would strongly suggest we enable:

  1. Space. A full name contains first name and space and last name.
  2. Any unicode characters.

Very useful for a multi user chatbot.

lucajung commented 11 months ago

ß should also be enabled. It is a very common char for a chatbot

rattrayalex commented 9 months ago

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