AndraxDev / speak-gpt

Your personal voice assistant based on OpenAI ChatGPT.
https://play.google.com/store/apps/details?id=org.teslasoft.assistant
Apache License 2.0
202 stars 38 forks source link

Crash: endpoints don't always list models with the same keys, seen with openrouter.ai #105

Closed thiswillbeyourgithub closed 2 weeks ago

thiswillbeyourgithub commented 2 weeks ago

Selecting the openrouter endpoint (i.e. https://openrouter.ai/api/v1/) then clicking "models" in the quick settings to list the available models crashes SpeakGPT because Caused by: w9.b: Fields [created, owned_by] are required for type with serial name 'com.aallam.openai.api.model.Model', but they were missing

Full log:

Expand ``` ===== BEGIN OF CRASH ===== m2.j: Illegal input: Fields [created, owned_by] are required for type with serial name 'com.aallam.openai.api.model.Model', but they were missing at path: $.data[0] at w2.d.a(Unknown Source:77) at w2.d.e(Unknown Source:122) at w2.b.m(Unknown Source:12) at x8.a.g(Unknown Source:5) at n9.k0.run(Unknown Source:101) at android.os.Handler.handleCallback(Handler.java:959) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loopOnce(Looper.java:232) at android.os.Looper.loop(Looper.java:317) at android.app.ActivityThread.main(ActivityThread.java:8532) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) at com.android.internal.os.ExecInit.main(ExecInit.java:50) at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:359) Suppressed: r9.f: [p1{Cancelling}@c04cf55, Dispatchers.Main] Caused by: u7.f: Illegal input: Fields [created, owned_by] are required for type with serial name 'com.aallam.openai.api.model.Model', but they were missing at path: $.data[0] at v7.j.a(Unknown Source:316) at u7.b.a(Unknown Source:178) at p9.e.a(Unknown Source:185) at u7.c.a(Unknown Source:49) at j9.k.e(Unknown Source:73) at d5.f0.a(Unknown Source:82) at i7.g.b(Unknown Source:245) at a7.b.m(Unknown Source:365) at a7.b.h(Unknown Source:52) at b8.m.f(Unknown Source:35) at b8.m.d(Unknown Source:27) at a7.d.m(Unknown Source:678) at a7.d.h(Unknown Source:132) at b8.m.f(Unknown Source:35) at b8.m.d(Unknown Source:27) at b8.m.e(Unknown Source:2) at a7.b.m(Unknown Source:517) at a7.b.h(Unknown Source:106) at b8.m.f(Unknown Source:35) at b8.m.d(Unknown Source:27) at b8.m.a(Unknown Source:18) at b8.e.a(Unknown Source:177) at b7.c.a(Unknown Source:177) at w2.d.e(Unknown Source:106) at w2.b.m(Unknown Source:12) at x8.a.g(Unknown Source:5) at n9.k0.run(Unknown Source:109) ... 10 more Caused by: w9.b: Fields [created, owned_by] are required for type with serial name 'com.aallam.openai.api.model.Model', but they were missing at path: $.data[0] at ca.g0.y(Unknown Source:122) at ca.g0.f(Unknown Source:40) at aa.s.k(Unknown Source:6) at aa.a.j(Unknown Source:29) at aa.a.a(Unknown Source:0) at ca.g0.y(Unknown Source:66) at ca.g0.f(Unknown Source:40) at l2.d.a(Unknown Source:100) at ca.g0.y(Unknown Source:66) at ba.b.a(Unknown Source:19) at v7.j.a(Unknown Source:204) ... 36 more Caused by: w9.b: Fields [created, owned_by] are required for type with serial name 'com.aallam.openai.api.model.Model', but they were missing at aa.c1.h(Unknown Source:104) at r2.c.(Unknown Source:27) at r2.a.a(Unknown Source:96) at ca.g0.y(Unknown Source:66) ... 46 more ===== END OF CRASH ===== ```
AndraxDev commented 2 weeks ago

Mistran is not supported or api endpoind is invalid. It's not a SpeakGPT bug. AAllam Kotlin library does not support it so please head your issue there. This will not be fixed or it may take a while while library will support this api endpoint. Thanks!

AndraxDev commented 2 weeks ago

You can use groq API. Now it's free and faster than OpenAI. Read documentation before writing a new issue as I don't give any warranties that non-OpenAI endpoints will fully compatible and all subsequent issues will be closed.

AndraxDev commented 2 weeks ago

Please write down your issue here: https://github.com/aallam/openai-kotlin

You can include your message: Fields [created, owned_by] are required for type with serial name 'com.aallam.openai.api.model.Model', but they were missing

thiswillbeyourgithub commented 2 weeks ago

Thank you for the quick answer, I created the issue as you said.

You can use groq API. Now it's free and faster than OpenAI.

groq only supports Mixtral 8x7B, but mistral now has many more models notably Mixtral 8x22B and Mistral Large.

Openrouter is a simple way to support many models including routing to OpenAI, Anthropic, Mistral etc. That's why I was eager to try it because supporting openrouter means than I have a decent chance of being able to try any LLM on speakGPT regardless of how exotic their endpoint or API is. It's too bad there's this issue. I keep my fingers cross for aallam to fix it shortly!

Thanks!

AndraxDev commented 2 weeks ago

Just imagine how it's hard to rewrite the whole codebase from scratch to move it to a new library. Currently SpeakGPT has over than 15k lines of code so I think there's no sense to explain you why this issue is rejected. Thanks!

AndraxDev commented 2 weeks ago

I checked OpenRouter and noted that you can fill the blank "fine-tuned" model in control center if you want to use some models from here. I understand that it is a rough solution but I think it a temporary acceptable solution for now.

AndraxDev commented 2 weeks ago

Screenshot_2024-04-29-14-03-20-614_org.teslasoft.assistant.jpg

Screenshot_2024-04-29-14-03-26-618_org.teslasoft.assistant.jpg

AndraxDev commented 2 weeks ago

Screenshot_2024-04-29-14-03-50-211_org.teslasoft.assistant.jpg

Proofs of working OpenRouter models in the current SpeakGPT versions. Advanced models dialog or models list in quick settings will lead to crash unfortunatedly. I think OpenRouter will add a list of models in future.

thiswillbeyourgithub commented 2 weeks ago

Just imagine how it's hard to rewrite the whole codebase from scratch to move it to a new library.

I'm sorry I did not mean at all that you should change library! Just that it's too bad if that fails currently.

I made an untested PR that might fix the issue, we'll see how it goes...

I checked OpenRouter and noted that you can fill the blank "fine-tuned" model in control center if you want to use some models from here. I understand that it is a rough solution but I think it a temporary acceptable solution for now.

Thank you so much for taking this time. I'll keep that in mind but that's too troublesome for me currently (for example I sometimes have my prompt censored because they are about medical stuff and would like to quickly change to less censored models)

I think OpenRouter will add a list of models in future.

Well curl https://openrouter.ai/api/v1/models |jq shows me that they already do, it's just that they included much more information like pricing, description etc, and lack the "owned_by" and "created" fields.

AndraxDev commented 2 weeks ago

Now I'm working on bare http request to fix this error so you can wait it in the next release.

thiswillbeyourgithub commented 2 weeks ago

Now I'm working on bare http request to fix this error so you can wait it in the next release.

Thank you so much!! As you can see in #107 there can be some issues with other endpoints (in that case mistral and probably anthropic) so that makes me hopeful that better support for openrouter would actually be a usable solution for anthropic and mistral to avoid having to make you change the code too much!

AndraxDev commented 2 weeks ago

In the next releases if you don't changed params or it have the default values it will not be passed to the models.

AndraxDev commented 2 weeks ago

Screenshot_2024-04-29-14-48-44-543_org.teslasoft.assistant.jpg

Now it's work. Wait for the next release. Due to a large amount of models I will add favorites models window.