Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnicodeEncodeError: 'ascii' codec can't encode character '\u200b' in position 117: ordinal not in range(128) #7

Closed
MediGenie opened this issue Feb 16, 2024 · 10 comments
Assignees

Comments

@MediGenie
Copy link

Hello! I got early access to the api and I just ran the example code, but there seems to be an error with ASCII? Would you please check?

Traceback (most recent call last): File "/home/ubuntu/sample.py", line 9, in <module> chat_completion = client.chat.completions.create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ubuntu/.pyenv/versions/3.11.4/lib/python3.11/site-packages/groq/resources/chat/completions.py", line 175, in create return self._post( ^^^^^^^^^^^ File "/home/ubuntu/.pyenv/versions/3.11.4/lib/python3.11/site-packages/groq/_base_client.py", line 1186, in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ubuntu/.pyenv/versions/3.11.4/lib/python3.11/site-packages/groq/_base_client.py", line 888, in request return self._request( ^^^^^^^^^^^^^^ File "/home/ubuntu/.pyenv/versions/3.11.4/lib/python3.11/site-packages/groq/_base_client.py", line 909, in _request request = self._build_request(options) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ubuntu/.pyenv/versions/3.11.4/lib/python3.11/site-packages/groq/_base_client.py", line 451, in _build_request headers = self._build_headers(options) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ubuntu/.pyenv/versions/3.11.4/lib/python3.11/site-packages/groq/_base_client.py", line 412, in _build_headers headers = httpx.Headers(headers_dict) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ubuntu/.pyenv/versions/3.11.4/lib/python3.11/site-packages/httpx/_models.py", line 70, in __init__ self._list = [ ^ File "/home/ubuntu/.pyenv/versions/3.11.4/lib/python3.11/site-packages/httpx/_models.py", line 74, in <listcomp> normalize_header_value(v, encoding), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ubuntu/.pyenv/versions/3.11.4/lib/python3.11/site-packages/httpx/_utils.py", line 53, in normalize_header_value return value.encode(encoding or "ascii") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnicodeEncodeError: 'ascii' codec can't encode character '\u200b' in position 117: ordinal not in range(128)

@MediGenie
Copy link
Author

So i just did a quick HTTPX library fix and now it seems to be working, but I encounter another error. I was just provided API Auth Token, hence i dont know what userID means. here

Traceback (most recent call last): File "/home/ubuntu/sample.py", line 9, in <module> chat_completion = client.chat.completions.create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ubuntu/.pyenv/versions/3.11.4/lib/python3.11/site-packages/groq/resources/chat/completions.py", line 175, in create return self._post( ^^^^^^^^^^^ File "/home/ubuntu/.pyenv/versions/3.11.4/lib/python3.11/site-packages/groq/_base_client.py", line 1186, in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ubuntu/.pyenv/versions/3.11.4/lib/python3.11/site-packages/groq/_base_client.py", line 888, in request return self._request( ^^^^^^^^^^^^^^ File "/home/ubuntu/.pyenv/versions/3.11.4/lib/python3.11/site-packages/groq/_base_client.py", line 979, in _request raise self._make_status_error_from_response(err.response) from None groq.BadRequestError: Failed getting metadata from request: error userID missing

@MediGenie
Copy link
Author

I tried with CURL and I get the same result.
image

@MediGenie
Copy link
Author

Just FYI i am running curl 8.6.0
image

@hozen-groq hozen-groq self-assigned this Feb 16, 2024
@hozen-groq
Copy link
Collaborator

Hello! Excited that you were able to get early access, but sad that you ran into some issues. Rest assured that the team is currently looking into this. We'll provide updates soon... 🚀

@MediGenie
Copy link
Author

Thanks! Looking forward to getting it fixed so i can try out the api.😇

@hozen-groq
Copy link
Collaborator

Hi! It's been a bit - hope you're doing well! 😄 I was wondering if you could please try this again and let me know your results?

@mac4281
Copy link

mac4281 commented Feb 21, 2024

I'm getting the same result today. Looking forward to diving in to Groq!

@rattrayalex
Copy link

It seems you may have a zero-width space character in your api key. Can you try removing it?

@mac4281
Copy link

mac4281 commented Feb 22, 2024

@rattrayalex Yep, that was it! Working great now.. Thanks!

@hozen-groq
Copy link
Collaborator

@rattrayalex Alex! You're the best! Thank you for lending a hand. So happy that these are resolved. Happy exploring, guys! 🙌

@hozen-groq hozen-groq pinned this issue Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants