mirror of
https://github.com/coaidev/coai.git
synced 2025-06-05 21:30:20 +09:00
feat: compatible older v1-models format
This commit is contained in:
parent
8079273428
commit
40cc84a863
@ -9,12 +9,14 @@ type v1Options = {
|
|||||||
|
|
||||||
type v1Models = {
|
type v1Models = {
|
||||||
object: string;
|
object: string;
|
||||||
data: {
|
data: v1ModelItem[];
|
||||||
|
};
|
||||||
|
|
||||||
|
type v1ModelItem = string | {
|
||||||
id: string;
|
id: string;
|
||||||
object: string;
|
object: string;
|
||||||
created: number;
|
created: number;
|
||||||
owned_by: string;
|
owned_by: string;
|
||||||
}[];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
type v1Resp<T> = {
|
type v1Resp<T> = {
|
||||||
@ -47,7 +49,10 @@ export async function getApiModels(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const data = res.data as v1Models;
|
const data = res.data as v1Models;
|
||||||
const models = data.data ? data.data.map((model) => model.id) : [];
|
|
||||||
|
// if data.data is an array of strings, we can just return it
|
||||||
|
|
||||||
|
const models = data.data ? data.data.map((model) => typeof model === "string" ? model : model.id) : [];
|
||||||
|
|
||||||
return models.length > 0
|
return models.length > 0
|
||||||
? { status: true, data: models }
|
? { status: true, data: models }
|
||||||
|
Loading…
Reference in New Issue
Block a user