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

Connection to OpenAI API failed: Please check your internet connection #10

Closed
kikoas1995 opened this issue Nov 1, 2023 · 10 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@kikoas1995
Copy link

Hello,

I've finally written the API key in the app. I've triple checked it's correct, and also I've ensured that I can use that API key using it in a python script on my laptop. But on the Smartwatch all I see when sending a prompt is Connection to OpenAI API failed: Please check your internet connection. I have it synced with my phone via bluetooth. Any idea?

@kikoas1995
Copy link
Author

Using a Pixel Watch LTE Gen1 btw

@kikoas1995
Copy link
Author

Is there any way to enable seeing the actual stacktrace in the app?

@DevEmperor DevEmperor self-assigned this Nov 1, 2023
@DevEmperor DevEmperor added the bug Something isn't working label Nov 1, 2023
@DevEmperor
Copy link
Owner

Thank you for pointing out this error. Another user has already told me about the same problem. Unfortunately, I had no insight into the stack trace at exceptions until yesterday. Now I have installed Google Crashlytics so that I can better fix such errors in the future. Unfortunately, a stack trace cannot be displayed easily on the watch itself.
I submitted the update to Google Play yesterday and as soon as it is approved in the next few days, I will get back to you. Then you can trigger the bug so that I can examine it more closely and fix it. Thank you for your patience. :)

@DevEmperor
Copy link
Owner

Version 2.3.0 with Crashlytics has just been released in the PlayStore. Can you download the latest version to your watch and trigger the bug again? Then the stacktrace will be displayed and I can find and fix the bug.
It's also best to go to "About" in the menu and hold down on the icon. Then you will see your UserID, which I can use to find your error message.

@kikoas1995
Copy link
Author

406459936 is my userid.

@DevEmperor
Copy link
Owner

You have to close the app completely and reopen it so that crash reports are sent. I can't see anything yet.

@kikoas1995
Copy link
Author

Done, can you check?

@DevEmperor
Copy link
Owner

I have now received your report and was able to find the error:

You have a U+200E LEFT-TO-RIGHT MARK character in your API key. It's a non-printing typesetting directive, instructing anything that is displaying the text to switch to left-to-right mode, (which is usually the case).

You probably didn't type in the key by hand on the keyboard, did you? :)
If I set the API key in my test app as follows, I can reproduce your error:
apiKey = "\u200Esk-t0rFL...";
I change my code so that such characters are filtered out. Nevertheless, I wonder how such a Unicode character slipped in with you...

@DevEmperor
Copy link
Owner

DevEmperor commented Nov 2, 2023

This is your stack trace btw:

Non-fatal Exception: java.lang.IllegalArgumentException: Unexpected char 0x200e at 7 in Authorization value: Bearer ‎sk-t0r...
       at okhttp3.Headers.checkValue(Headers.java:284)
       at okhttp3.Headers$Builder.set(Headers.java:415)
       at okhttp3.Request$Builder.header(Request.java:184)
       at com.theokanning.openai.service.AuthenticationInterceptor.intercept(AuthenticationInterceptor.java:26)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
       at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
       at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:229)
       at okhttp3.RealCall.execute(RealCall.java:81)
       at retrofit2.OkHttpCall.execute(OkHttpCall.java:204)
       at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:46)
       at io.reactivex.Observable.subscribe(Observable.java:10151)
       at retrofit2.adapter.rxjava2.BodyObservable.subscribeActual(BodyObservable.java:35)
       at io.reactivex.Observable.subscribe(Observable.java:10151)
       at io.reactivex.internal.operators.observable.ObservableSingleSingle.subscribeActual(ObservableSingleSingle.java:35)
       at io.reactivex.Single.subscribe(Single.java:2517)
       at io.reactivex.Single.blockingGet(Single.java:2001)
       at com.theokanning.openai.service.OpenAiService.execute(OpenAiService.java:353)
       at com.theokanning.openai.service.OpenAiService.createChatCompletion(OpenAiService.java:138)
       at net.devemperor.wristassist.activities.ChatActivity.lambda$query$2$net-devemperor-wristassist-activities-ChatActivity(ChatActivity.java:261)
       at net.devemperor.wristassist.activities.ChatActivity$$ExternalSyntheticLambda0.run(:4)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
       at java.lang.Thread.run(Thread.java:1012)

@DevEmperor
Copy link
Owner

Just committed the fix. The update will be released in the next few days. Would be nice if you could try entering the key manually again if you haven't done so the last few times. As I said, I have no idea how this Unicode character got there... :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants