diff --git a/src/cloudflare/internal/ai-api.ts b/src/cloudflare/internal/ai-api.ts index cd7bd96059e..1196e8b09e6 100644 --- a/src/cloudflare/internal/ai-api.ts +++ b/src/cloudflare/internal/ai-api.ts @@ -32,6 +32,33 @@ export type AiOptions = { sessionOptions?: SessionOptions; }; +export type AiModelsSearchParams = { + author?: string; + hide_experimental?: boolean; + page?: number; + per_page?: number; + search?: string; + source?: number; + task?: string; +}; + +export type AiModelsSearchObject = { + id: string; + source: number; + name: string; + description: string; + task: { + id: string; + name: string; + description: string; + }; + tags: string[]; + properties: { + property_id: string; + value: string; + }[]; +}; + export class InferenceUpstreamError extends Error { public constructor(message: string, name = 'InferenceUpstreamError') { super(message); @@ -39,6 +66,13 @@ export class InferenceUpstreamError extends Error { } } +export class AiInternalError extends Error { + public constructor(message: string, name = 'AiInternalError') { + super(message); + this.name = name; + } +} + export class Ai { private readonly fetcher: Fetcher; @@ -163,6 +197,30 @@ export class Ai { } } + public async models( + params: AiModelsSearchParams = {} + ): Promise { + const url = new URL('https://workers-binding.ai/ai-api/models/search'); + + for (const [key, value] of Object.entries(params)) { + url.searchParams.set(key, value.toString()); + } + + const res = await this.fetcher.fetch(url, { method: 'GET' }); + + switch (res.status) { + case 200: { + const data = (await res.json()) as { result: AiModelsSearchObject[] }; + return data.result; + } + default: { + const data = (await res.json()) as { errors: { message: string }[] }; + + throw new AiInternalError(data.errors[0]?.message || 'Internal Error'); + } + } + } + public gateway(gatewayId: string): AiGateway { return new AiGateway(this.fetcher, gatewayId); } diff --git a/src/cloudflare/internal/test/ai/ai-api-test.js b/src/cloudflare/internal/test/ai/ai-api-test.js index 80f791814cd..fdc4266d51f 100644 --- a/src/cloudflare/internal/test/ai/ai-api-test.js +++ b/src/cloudflare/internal/test/ai/ai-api-test.js @@ -134,5 +134,67 @@ export const tests = { requestUrl: 'https://workers-binding.ai/ai-gateway/run?version=3', }); } + + { + // Test models + const resp = await env.ai.models(); + + assert.deepStrictEqual(resp, [ + { + id: 'f8703a00-ed54-4f98-bdc3-cd9a813286f3', + source: 1, + name: '@cf/qwen/qwen1.5-0.5b-chat', + description: + 'Qwen1.5 is the improved version of Qwen, the large language model series developed by Alibaba Cloud.', + task: { + id: 'c329a1f9-323d-4e91-b2aa-582dd4188d34', + name: 'Text Generation', + description: + 'Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.', + }, + tags: [], + properties: [ + { + property_id: 'debug', + value: 'https://workers-binding.ai/ai-api/models/search', + }, + ], + }, + ]); + } + + { + // Test models with params + const resp = await env.ai.models({ + search: 'test', + per_page: 3, + page: 1, + task: 'asd', + }); + + assert.deepStrictEqual(resp, [ + { + id: 'f8703a00-ed54-4f98-bdc3-cd9a813286f3', + source: 1, + name: '@cf/qwen/qwen1.5-0.5b-chat', + description: + 'Qwen1.5 is the improved version of Qwen, the large language model series developed by Alibaba Cloud.', + task: { + id: 'c329a1f9-323d-4e91-b2aa-582dd4188d34', + name: 'Text Generation', + description: + 'Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.', + }, + tags: [], + properties: [ + { + property_id: 'debug', + value: + 'https://workers-binding.ai/ai-api/models/search?search=test&per_page=3&page=1&task=asd', + }, + ], + }, + ]); + } }, }; diff --git a/src/cloudflare/internal/test/ai/ai-mock.js b/src/cloudflare/internal/test/ai/ai-mock.js index c85c6f23017..b6789855d30 100644 --- a/src/cloudflare/internal/test/ai/ai-mock.js +++ b/src/cloudflare/internal/test/ai/ai-mock.js @@ -4,6 +4,36 @@ export default { async fetch(request, env, ctx) { + const url = new URL(request.url); + + if (url.pathname === '/ai-api/models/search') { + return Response.json({ + success: true, + result: [ + { + id: 'f8703a00-ed54-4f98-bdc3-cd9a813286f3', + source: 1, + name: '@cf/qwen/qwen1.5-0.5b-chat', + description: + 'Qwen1.5 is the improved version of Qwen, the large language model series developed by Alibaba Cloud.', + task: { + id: 'c329a1f9-323d-4e91-b2aa-582dd4188d34', + name: 'Text Generation', + description: + 'Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.', + }, + tags: [], + properties: [ + { + property_id: 'debug', + value: request.url, + }, + ], + }, + ], + }); + } + const data = await request.json(); const modelName = request.headers.get('cf-consn-model-id'); diff --git a/types/README.md b/types/README.md index 40a5407ddec..e373bbf252b 100644 --- a/types/README.md +++ b/types/README.md @@ -34,3 +34,9 @@ $ bazel test //types:all - `src/{print,program}.ts`: helpers for printing nodes and creating programs - `defines`: additional TypeScript-only definitions that don't correspond to `workerd` runtime APIs, appended to the end of outputs + +## Updates types + +```shell +bazel build //types:types && rm -rf types/generated-snapshot && cp -r bazel-bin/types/definitions types/generated-snapshot +``` diff --git a/types/defines/ai.d.ts b/types/defines/ai.d.ts index 94e7276ca0a..c989ea3b412 100644 --- a/types/defines/ai.d.ts +++ b/types/defines/ai.d.ts @@ -280,6 +280,33 @@ export interface AiModels { "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText; } export type ModelListType = Record; +export type AiModelsSearchParams = { + author?: string, + hide_experimental?: boolean + page?: number + per_page?: number + search?: string + source?: number + task?: string +} +export type AiModelsSearchObject = { + id: string, + source: number, + name: string, + description: string, + task: { + id: string, + name: string, + description: string, + }, + tags: string[], + properties: { + property_id: string, + value: string, + }[], +} +export interface InferenceUpstreamError extends Error {} +export interface AiInternalError extends Error {} export declare abstract class Ai { aiGatewayLogId: string | null; gateway(gatewayId: string): AiGateway; @@ -288,4 +315,5 @@ export declare abstract class Ai { inputs: ModelList[Name]["inputs"], options?: AiOptions ): Promise; + public models(params?: AiModelsSearchParams): Promise; } diff --git a/types/generated-snapshot/2021-11-03/index.d.ts b/types/generated-snapshot/2021-11-03/index.d.ts index 659ad689fe6..bda796b40f1 100755 --- a/types/generated-snapshot/2021-11-03/index.d.ts +++ b/types/generated-snapshot/2021-11-03/index.d.ts @@ -3683,6 +3683,33 @@ interface AiModels { "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText; } type ModelListType = Record; +type AiModelsSearchParams = { + author?: string; + hide_experimental?: boolean; + page?: number; + per_page?: number; + search?: string; + source?: number; + task?: string; +}; +type AiModelsSearchObject = { + id: string; + source: number; + name: string; + description: string; + task: { + id: string; + name: string; + description: string; + }; + tags: string[]; + properties: { + property_id: string; + value: string; + }[]; +}; +interface InferenceUpstreamError extends Error {} +interface AiInternalError extends Error {} declare abstract class Ai { aiGatewayLogId: string | null; gateway(gatewayId: string): AiGateway; @@ -3691,6 +3718,7 @@ declare abstract class Ai { inputs: ModelList[Name]["inputs"], options?: AiOptions, ): Promise; + public models(params?: AiModelsSearchParams): Promise; } type GatewayOptions = { id: string; diff --git a/types/generated-snapshot/2021-11-03/index.ts b/types/generated-snapshot/2021-11-03/index.ts index e9582ba1a31..dd0afeca7d5 100755 --- a/types/generated-snapshot/2021-11-03/index.ts +++ b/types/generated-snapshot/2021-11-03/index.ts @@ -3695,6 +3695,33 @@ export interface AiModels { "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText; } export type ModelListType = Record; +export type AiModelsSearchParams = { + author?: string; + hide_experimental?: boolean; + page?: number; + per_page?: number; + search?: string; + source?: number; + task?: string; +}; +export type AiModelsSearchObject = { + id: string; + source: number; + name: string; + description: string; + task: { + id: string; + name: string; + description: string; + }; + tags: string[]; + properties: { + property_id: string; + value: string; + }[]; +}; +export interface InferenceUpstreamError extends Error {} +export interface AiInternalError extends Error {} export declare abstract class Ai { aiGatewayLogId: string | null; gateway(gatewayId: string): AiGateway; @@ -3703,6 +3730,7 @@ export declare abstract class Ai { inputs: ModelList[Name]["inputs"], options?: AiOptions, ): Promise; + public models(params?: AiModelsSearchParams): Promise; } export type GatewayOptions = { id: string; diff --git a/types/generated-snapshot/2022-01-31/index.d.ts b/types/generated-snapshot/2022-01-31/index.d.ts index 6c3ba3db2c0..93285e309e9 100755 --- a/types/generated-snapshot/2022-01-31/index.d.ts +++ b/types/generated-snapshot/2022-01-31/index.d.ts @@ -3709,6 +3709,33 @@ interface AiModels { "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText; } type ModelListType = Record; +type AiModelsSearchParams = { + author?: string; + hide_experimental?: boolean; + page?: number; + per_page?: number; + search?: string; + source?: number; + task?: string; +}; +type AiModelsSearchObject = { + id: string; + source: number; + name: string; + description: string; + task: { + id: string; + name: string; + description: string; + }; + tags: string[]; + properties: { + property_id: string; + value: string; + }[]; +}; +interface InferenceUpstreamError extends Error {} +interface AiInternalError extends Error {} declare abstract class Ai { aiGatewayLogId: string | null; gateway(gatewayId: string): AiGateway; @@ -3717,6 +3744,7 @@ declare abstract class Ai { inputs: ModelList[Name]["inputs"], options?: AiOptions, ): Promise; + public models(params?: AiModelsSearchParams): Promise; } type GatewayOptions = { id: string; diff --git a/types/generated-snapshot/2022-01-31/index.ts b/types/generated-snapshot/2022-01-31/index.ts index 3c731c385a6..18c39606f83 100755 --- a/types/generated-snapshot/2022-01-31/index.ts +++ b/types/generated-snapshot/2022-01-31/index.ts @@ -3721,6 +3721,33 @@ export interface AiModels { "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText; } export type ModelListType = Record; +export type AiModelsSearchParams = { + author?: string; + hide_experimental?: boolean; + page?: number; + per_page?: number; + search?: string; + source?: number; + task?: string; +}; +export type AiModelsSearchObject = { + id: string; + source: number; + name: string; + description: string; + task: { + id: string; + name: string; + description: string; + }; + tags: string[]; + properties: { + property_id: string; + value: string; + }[]; +}; +export interface InferenceUpstreamError extends Error {} +export interface AiInternalError extends Error {} export declare abstract class Ai { aiGatewayLogId: string | null; gateway(gatewayId: string): AiGateway; @@ -3729,6 +3756,7 @@ export declare abstract class Ai { inputs: ModelList[Name]["inputs"], options?: AiOptions, ): Promise; + public models(params?: AiModelsSearchParams): Promise; } export type GatewayOptions = { id: string; diff --git a/types/generated-snapshot/2022-03-21/index.d.ts b/types/generated-snapshot/2022-03-21/index.d.ts index 2868897506c..048ffbdbf1c 100755 --- a/types/generated-snapshot/2022-03-21/index.d.ts +++ b/types/generated-snapshot/2022-03-21/index.d.ts @@ -3734,6 +3734,33 @@ interface AiModels { "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText; } type ModelListType = Record; +type AiModelsSearchParams = { + author?: string; + hide_experimental?: boolean; + page?: number; + per_page?: number; + search?: string; + source?: number; + task?: string; +}; +type AiModelsSearchObject = { + id: string; + source: number; + name: string; + description: string; + task: { + id: string; + name: string; + description: string; + }; + tags: string[]; + properties: { + property_id: string; + value: string; + }[]; +}; +interface InferenceUpstreamError extends Error {} +interface AiInternalError extends Error {} declare abstract class Ai { aiGatewayLogId: string | null; gateway(gatewayId: string): AiGateway; @@ -3742,6 +3769,7 @@ declare abstract class Ai { inputs: ModelList[Name]["inputs"], options?: AiOptions, ): Promise; + public models(params?: AiModelsSearchParams): Promise; } type GatewayOptions = { id: string; diff --git a/types/generated-snapshot/2022-03-21/index.ts b/types/generated-snapshot/2022-03-21/index.ts index 644d47b6c0a..2879c25e8f7 100755 --- a/types/generated-snapshot/2022-03-21/index.ts +++ b/types/generated-snapshot/2022-03-21/index.ts @@ -3746,6 +3746,33 @@ export interface AiModels { "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText; } export type ModelListType = Record; +export type AiModelsSearchParams = { + author?: string; + hide_experimental?: boolean; + page?: number; + per_page?: number; + search?: string; + source?: number; + task?: string; +}; +export type AiModelsSearchObject = { + id: string; + source: number; + name: string; + description: string; + task: { + id: string; + name: string; + description: string; + }; + tags: string[]; + properties: { + property_id: string; + value: string; + }[]; +}; +export interface InferenceUpstreamError extends Error {} +export interface AiInternalError extends Error {} export declare abstract class Ai { aiGatewayLogId: string | null; gateway(gatewayId: string): AiGateway; @@ -3754,6 +3781,7 @@ export declare abstract class Ai { inputs: ModelList[Name]["inputs"], options?: AiOptions, ): Promise; + public models(params?: AiModelsSearchParams): Promise; } export type GatewayOptions = { id: string; diff --git a/types/generated-snapshot/2022-08-04/index.d.ts b/types/generated-snapshot/2022-08-04/index.d.ts index b351125be5f..25077047016 100755 --- a/types/generated-snapshot/2022-08-04/index.d.ts +++ b/types/generated-snapshot/2022-08-04/index.d.ts @@ -3735,6 +3735,33 @@ interface AiModels { "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText; } type ModelListType = Record; +type AiModelsSearchParams = { + author?: string; + hide_experimental?: boolean; + page?: number; + per_page?: number; + search?: string; + source?: number; + task?: string; +}; +type AiModelsSearchObject = { + id: string; + source: number; + name: string; + description: string; + task: { + id: string; + name: string; + description: string; + }; + tags: string[]; + properties: { + property_id: string; + value: string; + }[]; +}; +interface InferenceUpstreamError extends Error {} +interface AiInternalError extends Error {} declare abstract class Ai { aiGatewayLogId: string | null; gateway(gatewayId: string): AiGateway; @@ -3743,6 +3770,7 @@ declare abstract class Ai { inputs: ModelList[Name]["inputs"], options?: AiOptions, ): Promise; + public models(params?: AiModelsSearchParams): Promise; } type GatewayOptions = { id: string; diff --git a/types/generated-snapshot/2022-08-04/index.ts b/types/generated-snapshot/2022-08-04/index.ts index 63c668152d0..62d6d3a621f 100755 --- a/types/generated-snapshot/2022-08-04/index.ts +++ b/types/generated-snapshot/2022-08-04/index.ts @@ -3747,6 +3747,33 @@ export interface AiModels { "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText; } export type ModelListType = Record; +export type AiModelsSearchParams = { + author?: string; + hide_experimental?: boolean; + page?: number; + per_page?: number; + search?: string; + source?: number; + task?: string; +}; +export type AiModelsSearchObject = { + id: string; + source: number; + name: string; + description: string; + task: { + id: string; + name: string; + description: string; + }; + tags: string[]; + properties: { + property_id: string; + value: string; + }[]; +}; +export interface InferenceUpstreamError extends Error {} +export interface AiInternalError extends Error {} export declare abstract class Ai { aiGatewayLogId: string | null; gateway(gatewayId: string): AiGateway; @@ -3755,6 +3782,7 @@ export declare abstract class Ai { inputs: ModelList[Name]["inputs"], options?: AiOptions, ): Promise; + public models(params?: AiModelsSearchParams): Promise; } export type GatewayOptions = { id: string; diff --git a/types/generated-snapshot/2022-10-31/index.d.ts b/types/generated-snapshot/2022-10-31/index.d.ts index 594a890fcbf..6de3f1835f3 100755 --- a/types/generated-snapshot/2022-10-31/index.d.ts +++ b/types/generated-snapshot/2022-10-31/index.d.ts @@ -3738,6 +3738,33 @@ interface AiModels { "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText; } type ModelListType = Record; +type AiModelsSearchParams = { + author?: string; + hide_experimental?: boolean; + page?: number; + per_page?: number; + search?: string; + source?: number; + task?: string; +}; +type AiModelsSearchObject = { + id: string; + source: number; + name: string; + description: string; + task: { + id: string; + name: string; + description: string; + }; + tags: string[]; + properties: { + property_id: string; + value: string; + }[]; +}; +interface InferenceUpstreamError extends Error {} +interface AiInternalError extends Error {} declare abstract class Ai { aiGatewayLogId: string | null; gateway(gatewayId: string): AiGateway; @@ -3746,6 +3773,7 @@ declare abstract class Ai { inputs: ModelList[Name]["inputs"], options?: AiOptions, ): Promise; + public models(params?: AiModelsSearchParams): Promise; } type GatewayOptions = { id: string; diff --git a/types/generated-snapshot/2022-10-31/index.ts b/types/generated-snapshot/2022-10-31/index.ts index 35de138200f..c15275cd98a 100755 --- a/types/generated-snapshot/2022-10-31/index.ts +++ b/types/generated-snapshot/2022-10-31/index.ts @@ -3750,6 +3750,33 @@ export interface AiModels { "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText; } export type ModelListType = Record; +export type AiModelsSearchParams = { + author?: string; + hide_experimental?: boolean; + page?: number; + per_page?: number; + search?: string; + source?: number; + task?: string; +}; +export type AiModelsSearchObject = { + id: string; + source: number; + name: string; + description: string; + task: { + id: string; + name: string; + description: string; + }; + tags: string[]; + properties: { + property_id: string; + value: string; + }[]; +}; +export interface InferenceUpstreamError extends Error {} +export interface AiInternalError extends Error {} export declare abstract class Ai { aiGatewayLogId: string | null; gateway(gatewayId: string): AiGateway; @@ -3758,6 +3785,7 @@ export declare abstract class Ai { inputs: ModelList[Name]["inputs"], options?: AiOptions, ): Promise; + public models(params?: AiModelsSearchParams): Promise; } export type GatewayOptions = { id: string; diff --git a/types/generated-snapshot/2022-11-30/index.d.ts b/types/generated-snapshot/2022-11-30/index.d.ts index d2caca14f7b..e32f7da7001 100755 --- a/types/generated-snapshot/2022-11-30/index.d.ts +++ b/types/generated-snapshot/2022-11-30/index.d.ts @@ -3743,6 +3743,33 @@ interface AiModels { "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText; } type ModelListType = Record; +type AiModelsSearchParams = { + author?: string; + hide_experimental?: boolean; + page?: number; + per_page?: number; + search?: string; + source?: number; + task?: string; +}; +type AiModelsSearchObject = { + id: string; + source: number; + name: string; + description: string; + task: { + id: string; + name: string; + description: string; + }; + tags: string[]; + properties: { + property_id: string; + value: string; + }[]; +}; +interface InferenceUpstreamError extends Error {} +interface AiInternalError extends Error {} declare abstract class Ai { aiGatewayLogId: string | null; gateway(gatewayId: string): AiGateway; @@ -3751,6 +3778,7 @@ declare abstract class Ai { inputs: ModelList[Name]["inputs"], options?: AiOptions, ): Promise; + public models(params?: AiModelsSearchParams): Promise; } type GatewayOptions = { id: string; diff --git a/types/generated-snapshot/2022-11-30/index.ts b/types/generated-snapshot/2022-11-30/index.ts index fab2ff3ab52..8fc9786fe57 100755 --- a/types/generated-snapshot/2022-11-30/index.ts +++ b/types/generated-snapshot/2022-11-30/index.ts @@ -3755,6 +3755,33 @@ export interface AiModels { "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText; } export type ModelListType = Record; +export type AiModelsSearchParams = { + author?: string; + hide_experimental?: boolean; + page?: number; + per_page?: number; + search?: string; + source?: number; + task?: string; +}; +export type AiModelsSearchObject = { + id: string; + source: number; + name: string; + description: string; + task: { + id: string; + name: string; + description: string; + }; + tags: string[]; + properties: { + property_id: string; + value: string; + }[]; +}; +export interface InferenceUpstreamError extends Error {} +export interface AiInternalError extends Error {} export declare abstract class Ai { aiGatewayLogId: string | null; gateway(gatewayId: string): AiGateway; @@ -3763,6 +3790,7 @@ export declare abstract class Ai { inputs: ModelList[Name]["inputs"], options?: AiOptions, ): Promise; + public models(params?: AiModelsSearchParams): Promise; } export type GatewayOptions = { id: string; diff --git a/types/generated-snapshot/2023-03-01/index.d.ts b/types/generated-snapshot/2023-03-01/index.d.ts index 196c9dabbe8..9f0d576887a 100755 --- a/types/generated-snapshot/2023-03-01/index.d.ts +++ b/types/generated-snapshot/2023-03-01/index.d.ts @@ -3745,6 +3745,33 @@ interface AiModels { "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText; } type ModelListType = Record; +type AiModelsSearchParams = { + author?: string; + hide_experimental?: boolean; + page?: number; + per_page?: number; + search?: string; + source?: number; + task?: string; +}; +type AiModelsSearchObject = { + id: string; + source: number; + name: string; + description: string; + task: { + id: string; + name: string; + description: string; + }; + tags: string[]; + properties: { + property_id: string; + value: string; + }[]; +}; +interface InferenceUpstreamError extends Error {} +interface AiInternalError extends Error {} declare abstract class Ai { aiGatewayLogId: string | null; gateway(gatewayId: string): AiGateway; @@ -3753,6 +3780,7 @@ declare abstract class Ai { inputs: ModelList[Name]["inputs"], options?: AiOptions, ): Promise; + public models(params?: AiModelsSearchParams): Promise; } type GatewayOptions = { id: string; diff --git a/types/generated-snapshot/2023-03-01/index.ts b/types/generated-snapshot/2023-03-01/index.ts index e18feea7837..773256074f6 100755 --- a/types/generated-snapshot/2023-03-01/index.ts +++ b/types/generated-snapshot/2023-03-01/index.ts @@ -3757,6 +3757,33 @@ export interface AiModels { "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText; } export type ModelListType = Record; +export type AiModelsSearchParams = { + author?: string; + hide_experimental?: boolean; + page?: number; + per_page?: number; + search?: string; + source?: number; + task?: string; +}; +export type AiModelsSearchObject = { + id: string; + source: number; + name: string; + description: string; + task: { + id: string; + name: string; + description: string; + }; + tags: string[]; + properties: { + property_id: string; + value: string; + }[]; +}; +export interface InferenceUpstreamError extends Error {} +export interface AiInternalError extends Error {} export declare abstract class Ai { aiGatewayLogId: string | null; gateway(gatewayId: string): AiGateway; @@ -3765,6 +3792,7 @@ export declare abstract class Ai { inputs: ModelList[Name]["inputs"], options?: AiOptions, ): Promise; + public models(params?: AiModelsSearchParams): Promise; } export type GatewayOptions = { id: string; diff --git a/types/generated-snapshot/2023-07-01/index.d.ts b/types/generated-snapshot/2023-07-01/index.d.ts index 9c8abe97f32..45de60d6bd6 100755 --- a/types/generated-snapshot/2023-07-01/index.d.ts +++ b/types/generated-snapshot/2023-07-01/index.d.ts @@ -3745,6 +3745,33 @@ interface AiModels { "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText; } type ModelListType = Record; +type AiModelsSearchParams = { + author?: string; + hide_experimental?: boolean; + page?: number; + per_page?: number; + search?: string; + source?: number; + task?: string; +}; +type AiModelsSearchObject = { + id: string; + source: number; + name: string; + description: string; + task: { + id: string; + name: string; + description: string; + }; + tags: string[]; + properties: { + property_id: string; + value: string; + }[]; +}; +interface InferenceUpstreamError extends Error {} +interface AiInternalError extends Error {} declare abstract class Ai { aiGatewayLogId: string | null; gateway(gatewayId: string): AiGateway; @@ -3753,6 +3780,7 @@ declare abstract class Ai { inputs: ModelList[Name]["inputs"], options?: AiOptions, ): Promise; + public models(params?: AiModelsSearchParams): Promise; } type GatewayOptions = { id: string; diff --git a/types/generated-snapshot/2023-07-01/index.ts b/types/generated-snapshot/2023-07-01/index.ts index 141aaa0cd55..6cf1b3319f6 100755 --- a/types/generated-snapshot/2023-07-01/index.ts +++ b/types/generated-snapshot/2023-07-01/index.ts @@ -3757,6 +3757,33 @@ export interface AiModels { "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText; } export type ModelListType = Record; +export type AiModelsSearchParams = { + author?: string; + hide_experimental?: boolean; + page?: number; + per_page?: number; + search?: string; + source?: number; + task?: string; +}; +export type AiModelsSearchObject = { + id: string; + source: number; + name: string; + description: string; + task: { + id: string; + name: string; + description: string; + }; + tags: string[]; + properties: { + property_id: string; + value: string; + }[]; +}; +export interface InferenceUpstreamError extends Error {} +export interface AiInternalError extends Error {} export declare abstract class Ai { aiGatewayLogId: string | null; gateway(gatewayId: string): AiGateway; @@ -3765,6 +3792,7 @@ export declare abstract class Ai { inputs: ModelList[Name]["inputs"], options?: AiOptions, ): Promise; + public models(params?: AiModelsSearchParams): Promise; } export type GatewayOptions = { id: string; diff --git a/types/generated-snapshot/experimental/index.d.ts b/types/generated-snapshot/experimental/index.d.ts index 3bb56e2899c..17ab6707377 100755 --- a/types/generated-snapshot/experimental/index.d.ts +++ b/types/generated-snapshot/experimental/index.d.ts @@ -3824,6 +3824,33 @@ interface AiModels { "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText; } type ModelListType = Record; +type AiModelsSearchParams = { + author?: string; + hide_experimental?: boolean; + page?: number; + per_page?: number; + search?: string; + source?: number; + task?: string; +}; +type AiModelsSearchObject = { + id: string; + source: number; + name: string; + description: string; + task: { + id: string; + name: string; + description: string; + }; + tags: string[]; + properties: { + property_id: string; + value: string; + }[]; +}; +interface InferenceUpstreamError extends Error {} +interface AiInternalError extends Error {} declare abstract class Ai { aiGatewayLogId: string | null; gateway(gatewayId: string): AiGateway; @@ -3832,6 +3859,7 @@ declare abstract class Ai { inputs: ModelList[Name]["inputs"], options?: AiOptions, ): Promise; + public models(params?: AiModelsSearchParams): Promise; } type GatewayOptions = { id: string; diff --git a/types/generated-snapshot/experimental/index.ts b/types/generated-snapshot/experimental/index.ts index 8968dc55578..f517d4590a5 100755 --- a/types/generated-snapshot/experimental/index.ts +++ b/types/generated-snapshot/experimental/index.ts @@ -3836,6 +3836,33 @@ export interface AiModels { "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText; } export type ModelListType = Record; +export type AiModelsSearchParams = { + author?: string; + hide_experimental?: boolean; + page?: number; + per_page?: number; + search?: string; + source?: number; + task?: string; +}; +export type AiModelsSearchObject = { + id: string; + source: number; + name: string; + description: string; + task: { + id: string; + name: string; + description: string; + }; + tags: string[]; + properties: { + property_id: string; + value: string; + }[]; +}; +export interface InferenceUpstreamError extends Error {} +export interface AiInternalError extends Error {} export declare abstract class Ai { aiGatewayLogId: string | null; gateway(gatewayId: string): AiGateway; @@ -3844,6 +3871,7 @@ export declare abstract class Ai { inputs: ModelList[Name]["inputs"], options?: AiOptions, ): Promise; + public models(params?: AiModelsSearchParams): Promise; } export type GatewayOptions = { id: string; diff --git a/types/generated-snapshot/oldest/index.d.ts b/types/generated-snapshot/oldest/index.d.ts index d91fb1a8a53..0873101fd61 100755 --- a/types/generated-snapshot/oldest/index.d.ts +++ b/types/generated-snapshot/oldest/index.d.ts @@ -3683,6 +3683,33 @@ interface AiModels { "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText; } type ModelListType = Record; +type AiModelsSearchParams = { + author?: string; + hide_experimental?: boolean; + page?: number; + per_page?: number; + search?: string; + source?: number; + task?: string; +}; +type AiModelsSearchObject = { + id: string; + source: number; + name: string; + description: string; + task: { + id: string; + name: string; + description: string; + }; + tags: string[]; + properties: { + property_id: string; + value: string; + }[]; +}; +interface InferenceUpstreamError extends Error {} +interface AiInternalError extends Error {} declare abstract class Ai { aiGatewayLogId: string | null; gateway(gatewayId: string): AiGateway; @@ -3691,6 +3718,7 @@ declare abstract class Ai { inputs: ModelList[Name]["inputs"], options?: AiOptions, ): Promise; + public models(params?: AiModelsSearchParams): Promise; } type GatewayOptions = { id: string; diff --git a/types/generated-snapshot/oldest/index.ts b/types/generated-snapshot/oldest/index.ts index ad6de110a82..95245ad7177 100755 --- a/types/generated-snapshot/oldest/index.ts +++ b/types/generated-snapshot/oldest/index.ts @@ -3695,6 +3695,33 @@ export interface AiModels { "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText; } export type ModelListType = Record; +export type AiModelsSearchParams = { + author?: string; + hide_experimental?: boolean; + page?: number; + per_page?: number; + search?: string; + source?: number; + task?: string; +}; +export type AiModelsSearchObject = { + id: string; + source: number; + name: string; + description: string; + task: { + id: string; + name: string; + description: string; + }; + tags: string[]; + properties: { + property_id: string; + value: string; + }[]; +}; +export interface InferenceUpstreamError extends Error {} +export interface AiInternalError extends Error {} export declare abstract class Ai { aiGatewayLogId: string | null; gateway(gatewayId: string): AiGateway; @@ -3703,6 +3730,7 @@ export declare abstract class Ai { inputs: ModelList[Name]["inputs"], options?: AiOptions, ): Promise; + public models(params?: AiModelsSearchParams): Promise; } export type GatewayOptions = { id: string;