Skip to content

Commit 1ff565d

Browse files
authored
Add model status support, type reranking providers (#116)
* add model status support, type reranking providers * add couple tests
1 parent 65d62aa commit 1ff565d

File tree

7 files changed

+431
-43
lines changed

7 files changed

+431
-43
lines changed

src/administration/db-admin.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@
1313
// limitations under the License.
1414
// noinspection ExceptionCaughtLocallyJS
1515

16-
import type { FindEmbeddingProvidersResult } from '@/src/administration/types/db-admin/find-embedding-providers.js';
16+
import type {
17+
FindEmbeddingProvidersOptions,
18+
FindEmbeddingProvidersResult,
19+
} from '@/src/administration/types/db-admin/find-embedding-providers.js';
1720
import type { CommandOptions } from '@/src/lib/index.js';
1821
import { HierarchicalLogger } from '@/src/lib/index.js';
1922
import type { Db } from '@/src/db/index.js';
2023
import type { AdminCommandEventMap } from '@/src/administration/events.js';
21-
import type { FindRerankingProvidersResult } from '@/src/administration/types/db-admin/find-reranking-providers.js';
24+
import type {
25+
FindRerankingProvidersOptions,
26+
FindRerankingProvidersResult,
27+
} from '@/src/administration/types/db-admin/find-reranking-providers.js';
2228
import type { DataAPIHttpClient } from '@/src/lib/api/clients/index.js';
2329

2430
/**
@@ -171,7 +177,7 @@ export abstract class DbAdmin extends HierarchicalLogger<AdminCommandEventMap> {
171177
*
172178
* @returns The available embedding providers.
173179
*/
174-
public async findEmbeddingProviders(options?: CommandOptions<{ timeout: 'databaseAdminTimeoutMs' }>): Promise<FindEmbeddingProvidersResult> {
180+
public async findEmbeddingProviders(options?: FindEmbeddingProvidersOptions): Promise<FindEmbeddingProvidersResult> {
175181
const httpClient = this._getDataAPIHttpClient();
176182

177183
const resp = await httpClient.executeCommand({ findEmbeddingProviders: {} }, {
@@ -199,7 +205,7 @@ export abstract class DbAdmin extends HierarchicalLogger<AdminCommandEventMap> {
199205
*
200206
* @returns The available reranking providers.
201207
*/
202-
public async findRerankingProviders(options?: CommandOptions<{ timeout: 'databaseAdminTimeoutMs' }>): Promise<FindRerankingProvidersResult> {
208+
public async findRerankingProviders(options?: FindRerankingProvidersOptions): Promise<FindRerankingProvidersResult> {
203209
const httpClient = this._getDataAPIHttpClient();
204210

205211
const resp = await httpClient.executeCommand({ findRerankingProviders: {} }, {

src/administration/types/db-admin/astra-create-keyspace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import type { CommandOptions } from '@/src/lib/index.js';
2525
* yet created).
2626
*
2727
* @example
28-
* ```typescript
28+
* ```ts
2929
* // If using non-astra, this may be a common idiom:
3030
* const client = new DataAPIClient({ environment: 'dse' });
3131
* const db = client.db('<endpoint>', { token: '<token>' });
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright DataStax, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
/**
16+
* The lifecycle status of a model indicating its current support level.
17+
*
18+
* - `'SUPPORTED'`: The model is actively supported and recommended for use
19+
* - `'DEPRECATED'`: The model is still functional but deprecated and may be removed in the future
20+
* - `'END_OF_LIFE'`: The model is no longer supported and should not be used
21+
*
22+
* @example
23+
* ```ts
24+
* // A model with active support
25+
* status: 'SUPPORTED'
26+
*
27+
* // A model that's deprecated but still works
28+
* status: 'DEPRECATED'
29+
*
30+
* // A model that's no longer available
31+
* status: 'END_OF_LIFE'
32+
* ```
33+
*
34+
* @public
35+
*/
36+
export type ModelLifecycleStatus = 'SUPPORTED' | 'DEPRECATED' | 'END_OF_LIFE';

src/administration/types/db-admin/find-embedding-providers.ts

Lines changed: 93 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,41 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
import type { ModelLifecycleStatus } from '@/src/administration/types/db-admin/common.js';
16+
import type { CommandOptions, LitUnion } from '@/src/lib/index.js';
17+
18+
/**
19+
* Options for finding embedding providers.
20+
*
21+
* @field filterModelStatus - Filter models by their lifecycle status. If not provided, defaults to 'SUPPORTED' only. Use empty string '' to include all statuses.
22+
*
23+
* @see DbAdmin.findEmbeddingProviders
24+
*
25+
* @public
26+
*/
27+
export interface FindEmbeddingProvidersOptions extends CommandOptions<{ timeout: 'databaseAdminTimeoutMs' }> {
28+
/**
29+
* Filter models by their lifecycle status.
30+
*
31+
* - If not provided: defaults to `'SUPPORTED'` only
32+
* - If set to `''`: includes all statuses (`'SUPPORTED'`, `'DEPRECATED'`, `'END_OF_LIFE'`)
33+
* - If set to specific status: includes only models with that status
34+
*
35+
* @example
36+
* ```ts
37+
* // Only supported models (default behavior)
38+
* { filterModelStatus: 'SUPPORTED' }
39+
*
40+
* // All models regardless of status
41+
* { filterModelStatus: '' }
42+
*
43+
* // Only deprecated models
44+
* { filterModelStatus: 'DEPRECATED' }
45+
* ```
46+
*/
47+
filterModelStatus?: ModelLifecycleStatus | '';
48+
}
49+
1550
/**
1651
* The overarching result containing the `embeddingProviders` map.
1752
*
@@ -26,7 +61,7 @@ export interface FindEmbeddingProvidersResult {
2661
* A map of embedding provider names (e.g. `openai`), to information about said provider (e.g. models/auth).
2762
*
2863
* @example
29-
* ```typescript
64+
* ```ts
3065
* {
3166
* openai: {
3267
* displayName: 'OpenAI',
@@ -56,7 +91,7 @@ export interface EmbeddingProviderInfo {
5691
* The prettified name of the provider (as shown in the Astra portal).
5792
*
5893
* @example
59-
* ```typescript
94+
* ```ts
6095
* // openai.displayName:
6196
* 'OpenAI'
6297
* ```
@@ -69,7 +104,7 @@ export interface EmbeddingProviderInfo {
69104
* parameters (such as `huggingfaceDedicated` or `azureOpenAI`).
70105
*
71106
* @example
72-
* ```typescript
107+
* ```ts
73108
* // openai.url:
74109
* 'https://api.openai.com/v1/'
75110
*
@@ -85,7 +120,7 @@ export interface EmbeddingProviderInfo {
85120
*
86121
* - `HEADER`: Authentication using direct API keys passed through headers on every Data API call.
87122
* See {@link EmbeddingHeadersProvider} for more info.
88-
* ```typescript
123+
* ```ts
89124
* const collections = await db.createCollection('my_coll', {
90125
* vector: {
91126
* service: {
@@ -101,15 +136,15 @@ export interface EmbeddingProviderInfo {
101136
* ```
102137
*
103138
* - `SHARED_SECRET`: Authentication tied to a collections at collections creation time using the Astra KMS.
104-
* ```typescript
139+
* ```ts
105140
* const collections = await db.collections('my_coll', {
106141
* // Not tied to the collections; can be different every time.
107142
* embeddingApiKey: 'sk-...',
108143
* });
109144
* ```
110145
*
111146
* - `NONE`: For when a client doesn't need authentication to use (e.g. nvidia).
112-
* ```typescript
147+
* ```ts
113148
* const collections = await db.createCollection('my_coll', {
114149
* vector: {
115150
* service: {
@@ -121,7 +156,7 @@ export interface EmbeddingProviderInfo {
121156
* ```
122157
*
123158
* @example
124-
* ```typescript
159+
* ```ts
125160
* // openai.supportedAuthentication.HEADER:
126161
* {
127162
* enabled: true,
@@ -132,14 +167,14 @@ export interface EmbeddingProviderInfo {
132167
* }
133168
* ```
134169
*/
135-
supportedAuthentication: Record<string, EmbeddingProviderAuthInfo>,
170+
supportedAuthentication: Record<LitUnion<'HEADER' | 'SHARED_SECRET' | 'NONE'>, EmbeddingProviderAuthInfo>,
136171
/**
137172
* Any additional, arbitrary parameters the provider may take in. May or may not be required.
138173
*
139174
* Passed into the `parameters` block in {@link VectorizeServiceOptions} (except for `vectorDimension`).
140175
*
141176
* @example
142-
* ```typescript
177+
* ```ts
143178
* // openai.parameters[1]
144179
* {
145180
* name: 'projectId',
@@ -159,7 +194,7 @@ export interface EmbeddingProviderInfo {
159194
* may be truly arbitrary.
160195
*
161196
* @example
162-
* ```typescript
197+
* ```ts
163198
* // nvidia.models[0]
164199
* {
165200
* name: 'NV-Embed-QA',
@@ -194,7 +229,7 @@ export interface EmbeddingProviderInfo {
194229
* See {@link EmbeddingHeadersProvider} for more info about the `HEADER` auth through the client.
195230
*
196231
* @example
197-
* ```typescript
232+
* ```ts
198233
* // openai.supportedAuthentication.HEADER:
199234
* {
200235
* enabled: true,
@@ -231,7 +266,7 @@ export interface EmbeddingProviderAuthInfo {
231266
* Info on how exactly a method of auth may be used.
232267
*
233268
* @example
234-
* ```typescript
269+
* ```ts
235270
* // openai.supportedAuthentication.HEADER.tokens[0]:
236271
* {
237272
* accepted: 'x-embedding-api-key',
@@ -268,7 +303,7 @@ export interface EmbeddingProviderTokenInfo {
268303
* set in the upper-level `dimension: number` field).
269304
*
270305
* @example
271-
* ```typescript
306+
* ```ts
272307
* // openai.parameters[1]
273308
* {
274309
* name: 'vectorDimension',
@@ -300,7 +335,7 @@ export interface EmbeddingProviderModelParameterInfo {
300335
* `vector` block in {@link CollectionVectorOptions}/{@link TableVectorColumnDefinition}.
301336
*
302337
* @example
303-
* ```typescript
338+
* ```ts
304339
* // huggingface.parameters[0].name
305340
* endpointName
306341
* ```
@@ -312,7 +347,7 @@ export interface EmbeddingProviderModelParameterInfo {
312347
* Commonly `number` or `STRING`.
313348
*
314349
* @example
315-
* ```typescript
350+
* ```ts
316351
* // huggingface.parameters[0].type
317352
* STRING
318353
* ```
@@ -322,7 +357,7 @@ export interface EmbeddingProviderModelParameterInfo {
322357
* Whether the parameter is required to be passed in.
323358
*
324359
* @example
325-
* ```typescript
360+
* ```ts
326361
* // huggingface.parameters[0].required
327362
* true
328363
* ```
@@ -334,7 +369,7 @@ export interface EmbeddingProviderModelParameterInfo {
334369
* Will always be in string form (even if the `type` is `'number'`).
335370
*
336371
* @example
337-
* ```typescript
372+
* ```ts
338373
* // huggingface.parameters[0].defaultValue
339374
* ''
340375
* ```
@@ -346,7 +381,7 @@ export interface EmbeddingProviderModelParameterInfo {
346381
* Commonly either an empty record, or `{ numericRange: [<min>, <max>] }`.
347382
*
348383
* @example
349-
* ```typescript
384+
* ```ts
350385
* // huggingface.parameters[0].validation
351386
* {}
352387
* ```
@@ -356,7 +391,7 @@ export interface EmbeddingProviderModelParameterInfo {
356391
* Any additional help text/information about the parameter.
357392
*
358393
* @example
359-
* ```typescript
394+
* ```ts
360395
* // huggingface.parameters[0].help
361396
* 'The name of your Hugging Face dedicated endpoint, the first part of the Endpoint URL.'
362397
* ```
@@ -371,7 +406,7 @@ export interface EmbeddingProviderModelParameterInfo {
371406
* set in the upper-level `dimension: number` field).
372407
*
373408
* @example
374-
* ```typescript
409+
* ```ts
375410
* // openai.parameters[1]
376411
* {
377412
* name: 'projectId',
@@ -404,7 +439,7 @@ export interface EmbeddingProviderProviderParameterInfo extends EmbeddingProvide
404439
* Display name for the parameter.
405440
*
406441
* @example
407-
* ```typescript
442+
* ```ts
408443
* // openai.parameters[0].displayName
409444
* 'Organization ID'
410445
* ```
@@ -414,7 +449,7 @@ export interface EmbeddingProviderProviderParameterInfo extends EmbeddingProvide
414449
* Hint for parameter usage.
415450
*
416451
* @example
417-
* ```typescript
452+
* ```ts
418453
* // openai.parameters[0].hint
419454
* 'Add an (optional) organization ID'
420455
* ```
@@ -429,7 +464,7 @@ export interface EmbeddingProviderProviderParameterInfo extends EmbeddingProvide
429464
* may be truly arbitrary.
430465
*
431466
* @example
432-
* ```typescript
467+
* ```ts
433468
* // nvidia.models[0]
434469
* {
435470
* name: 'NV-Embed-QA',
@@ -454,7 +489,7 @@ export interface EmbeddingProviderModelInfo {
454489
* may be truly arbitrary.
455490
*
456491
* @example
457-
* ```typescript
492+
* ```ts
458493
* // openai.models[0].name
459494
* 'text-embedding-3-small'
460495
*
@@ -469,7 +504,7 @@ export interface EmbeddingProviderModelInfo {
469504
* If not present, a `vectorDimension` parameter will be present in the `model.parameters` block.
470505
*
471506
* @example
472-
* ```typescript
507+
* ```ts
473508
* // openai.models[3].vectorDimension (text-embedding-ada-002)
474509
* 1536
475510
*
@@ -484,7 +519,7 @@ export interface EmbeddingProviderModelInfo {
484519
* Passed into the `parameters` block in {@link VectorizeServiceOptions} (except for `vectorDimension`).
485520
*
486521
* @example
487-
* ```typescript
522+
* ```ts
488523
* // openai.models[0].parameters[0] (text-embedding-3-small)
489524
* {
490525
* name: 'vectorDimension',
@@ -497,4 +532,36 @@ export interface EmbeddingProviderModelInfo {
497532
* ```
498533
*/
499534
parameters: EmbeddingProviderModelParameterInfo[],
535+
/**
536+
* Information about the model's API support status.
537+
*
538+
* @example
539+
* ```ts
540+
* // openai.models[0].apiModelSupport
541+
* { status: 'SUPPORTED' }
542+
* ```
543+
*/
544+
apiModelSupport: EmbeddingProviderModelApiSupportInfo,
545+
}
546+
547+
/**
548+
* Information about the model's API support status and lifecycle.
549+
*
550+
* @field status - The current lifecycle status of the model
551+
*
552+
* @see EmbeddingProviderModelInfo
553+
*
554+
* @public
555+
*/
556+
export interface EmbeddingProviderModelApiSupportInfo {
557+
/**
558+
* The current lifecycle status of the model.
559+
*
560+
* @example
561+
* ```ts
562+
* // openai.models[0].apiModelSupport.status
563+
* 'SUPPORTED'
564+
* ```
565+
*/
566+
status: ModelLifecycleStatus,
500567
}

0 commit comments

Comments
 (0)