@runappsai/sdk 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/models.d.ts +26 -0
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +20 -0
- package/dist/models.js.map +1 -1
- package/dist/sdk.umd.js +3 -3
- package/dist/sdk.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/models.ts +31 -0
package/package.json
CHANGED
package/src/index.ts
CHANGED
package/src/models.ts
CHANGED
|
@@ -10,6 +10,15 @@ export interface Model {
|
|
|
10
10
|
object: string;
|
|
11
11
|
capability: string;
|
|
12
12
|
provider?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The model the platform uses for this capability when a request names
|
|
15
|
+
* none: the one the admin starred in the gateway settings, else the
|
|
16
|
+
* first of the capability. Exactly one model per capability carries it.
|
|
17
|
+
* Use `defaultModel` to pick it out of a list.
|
|
18
|
+
*/
|
|
19
|
+
is_default?: boolean;
|
|
20
|
+
/** One or two sentences about the model, set on the gateway. */
|
|
21
|
+
description?: string;
|
|
13
22
|
/**
|
|
14
23
|
* Server-derived "what this model can actually do" tags
|
|
15
24
|
* (e.g. {id:"t2v", label:"Text-to-Video"}, {id:"i2v", label:"Image-to-Video"}).
|
|
@@ -100,6 +109,18 @@ export const defaultVoice = (model: Model): string | null => {
|
|
|
100
109
|
return typeof v === "string" ? v : null;
|
|
101
110
|
};
|
|
102
111
|
|
|
112
|
+
/**
|
|
113
|
+
* The platform's default model among `models` — the admin-starred one for
|
|
114
|
+
* the capability, else the first of the capability. With `capability`
|
|
115
|
+
* given, only that capability is considered; without it, the first
|
|
116
|
+
* default in list order (so pass a list from
|
|
117
|
+
* `client.models.list({ capability })`). Null when the list has none.
|
|
118
|
+
*/
|
|
119
|
+
export const defaultModel = (models: Model[], capability?: string): Model | null => {
|
|
120
|
+
const pool = capability ? models.filter((m) => m.capability === capability) : models;
|
|
121
|
+
return pool.find((m) => m.is_default) ?? null;
|
|
122
|
+
};
|
|
123
|
+
|
|
103
124
|
export class ModelsService {
|
|
104
125
|
constructor(private readonly transport: Transport) {}
|
|
105
126
|
|
|
@@ -120,4 +141,14 @@ export class ModelsService {
|
|
|
120
141
|
const resp = await this.transport.getPublicJSON<{ data: Model[] }>(path, init);
|
|
121
142
|
return resp.data;
|
|
122
143
|
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The platform's default model for a capability (`"text"` unless given):
|
|
147
|
+
* the admin-starred one, else the first. What a request without `model`
|
|
148
|
+
* would use before the user's own preference. Null when the capability
|
|
149
|
+
* has no models.
|
|
150
|
+
*/
|
|
151
|
+
async default(capability = "text", init?: { signal?: AbortSignal }): Promise<Model | null> {
|
|
152
|
+
return defaultModel(await this.list({ capability }, init), capability);
|
|
153
|
+
}
|
|
123
154
|
}
|