Issue Description:
When a KEY contains spaces, it triggers the error h11._util.LocalProtocolError: Illegal header value. However, the openai library, upon encountering this exception, rethrows it as openai.APIConnectionError: Connection error., which can mislead users into thinking there is a problem with their network connection. To prevent this misunderstanding and avoid such exceptions, it would be prudent to implement a preprocessing step that trims whitespace from the beginning and end of the KEY before any operations are executed.
Suggested Solution:
Implement a trim operation on the KEY value to remove any leading or trailing spaces before it is used in operations. This can help in ensuring that users do not encounter the misleading connection error and understand the actual issue at hand without confusion.
Issue Description: When a KEY contains spaces, it triggers the error
h11._util.LocalProtocolError: Illegal header value
. However, the openai library, upon encountering this exception, rethrows it asopenai.APIConnectionError: Connection error.
, which can mislead users into thinking there is a problem with their network connection. To prevent this misunderstanding and avoid such exceptions, it would be prudent to implement a preprocessing step that trims whitespace from the beginning and end of the KEY before any operations are executed.Suggested Solution: Implement a trim operation on the KEY value to remove any leading or trailing spaces before it is used in operations. This can help in ensuring that users do not encounter the misleading connection error and understand the actual issue at hand without confusion.