@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runappsai/sdk",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "description": "JavaScript / TypeScript client for the RunApps AI Gateway",
5
5
  "license": "MIT",
6
6
  "author": "RunApps",
package/src/index.ts CHANGED
@@ -88,6 +88,7 @@ export {
88
88
  supportsVoiceClone,
89
89
  supportsInstructText,
90
90
  defaultVoice,
91
+ defaultModel,
91
92
  } from "./models.js";
92
93
 
93
94
  // Model options schema (input validation + capability introspection)
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
  }