Closed thiswillbeyourgithub closed 6 months ago
Now you have all field in Model.kt object non-nullable. I propose to perform the following changes to Model.kt file:
package com.aallam.openai.api.model
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
/**
* OpenAI's Model.
*/
@Serializable
public data class Model(
@SerialName("id") public val id: ModelId,
@SerialName("created") public val created: Long?, /* make the following parameter nullable */
@SerialName("owned_by") public val ownedBy: String?, /* make the following parameter nullable */
@SerialName("permission") public val permission: List<ModelPermission>? = null,
)
In context of smart assistant I think params owned_by and create are not required and it can be made optional. For examle the OpenRouter (https://openrouter.ai/docs#models)(OpenAI API standard) which is a revolution among LLM providers uses the following JSON object of model:
{
"id": "openrouter/auto",
"name": "Auto (best for prompt)",
"description": "Depending on their size, subject, and complexity, your prompts will be sent to [Mistral Large](/models/mistralai/mistral-large) or [GPT-4 Turbo](/models/openai/gpt-4-turbo). To see which model was used, visit [Activity](/activity).",
"pricing": {
"prompt": "-1",
"completion": "-1",
"request": "-1",
"image": "-1"
},
"context_length": 128000,
"architecture": {
"modality": "text",
"tokenizer": "Router",
"instruct_type": null
},
"top_provider": {
"max_completion_tokens": null,
"is_moderated": false
},
"per_request_limits": null
}
So this object does not have owned_by and created fields. When we use https://openrouter.ai/api/v1/
everythong works except model list.
P.S: The temporary solution for me is to send bare HTTP request, but I would like to use the same library and engine to provide user with best experience.
Description
Got redirected here from this SpeakGPT issue.
This seems to happen when the function
openAI.models
is called and because the outputs do not contain "created" nor "owned_by" keys.Also, if you don't mind me asking, do you accept bounties for quick fix?
Here's the error message:
Fields [created, owned_by] are required for type with serial name 'com.aallam.openai.api.model.Model', but they were missing
Full log from the SpeakGPT crash:
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.Steps to Reproduce
https://openrouter.ai/api/v1/
openai.models()
Environment