@cloudflare/workers-types 4.20260329.1 → 4.20260331.1
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/2021-11-03/index.d.ts +379 -124
- package/2021-11-03/index.ts +379 -124
- package/2022-01-31/index.d.ts +379 -124
- package/2022-01-31/index.ts +379 -124
- package/2022-03-21/index.d.ts +379 -124
- package/2022-03-21/index.ts +379 -124
- package/2022-08-04/index.d.ts +379 -124
- package/2022-08-04/index.ts +379 -124
- package/2022-10-31/index.d.ts +379 -124
- package/2022-10-31/index.ts +379 -124
- package/2022-11-30/index.d.ts +379 -124
- package/2022-11-30/index.ts +379 -124
- package/2023-03-01/index.d.ts +379 -124
- package/2023-03-01/index.ts +379 -124
- package/2023-07-01/index.d.ts +379 -124
- package/2023-07-01/index.ts +379 -124
- package/experimental/index.d.ts +393 -126
- package/experimental/index.ts +393 -126
- package/index.d.ts +379 -124
- package/index.ts +379 -124
- package/latest/index.d.ts +379 -124
- package/latest/index.ts +379 -124
- package/oldest/index.d.ts +379 -124
- package/oldest/index.ts +379 -124
- package/package.json +1 -1
package/latest/index.ts
CHANGED
|
@@ -3121,6 +3121,11 @@ export interface QueuingStrategyInit {
|
|
|
3121
3121
|
*/
|
|
3122
3122
|
highWaterMark: number;
|
|
3123
3123
|
}
|
|
3124
|
+
export interface TracePreviewInfo {
|
|
3125
|
+
id: string;
|
|
3126
|
+
slug: string;
|
|
3127
|
+
name: string;
|
|
3128
|
+
}
|
|
3124
3129
|
export interface ScriptVersion {
|
|
3125
3130
|
id?: string;
|
|
3126
3131
|
tag?: string;
|
|
@@ -3155,6 +3160,7 @@ export interface TraceItem {
|
|
|
3155
3160
|
readonly dispatchNamespace?: string;
|
|
3156
3161
|
readonly scriptTags?: string[];
|
|
3157
3162
|
readonly tailAttributes?: Record<string, boolean | number | string>;
|
|
3163
|
+
readonly preview?: TracePreviewInfo;
|
|
3158
3164
|
readonly durableObjectId?: string;
|
|
3159
3165
|
readonly outcome: string;
|
|
3160
3166
|
readonly executionModel: string;
|
|
@@ -3934,11 +3940,10 @@ export declare abstract class Performance {
|
|
|
3934
3940
|
*/
|
|
3935
3941
|
toJSON(): object;
|
|
3936
3942
|
}
|
|
3937
|
-
// AI Search
|
|
3943
|
+
// ============ AI Search Error Interfaces ============
|
|
3938
3944
|
export interface AiSearchInternalError extends Error {}
|
|
3939
3945
|
export interface AiSearchNotFoundError extends Error {}
|
|
3940
|
-
|
|
3941
|
-
// AI Search V2 Request Types
|
|
3946
|
+
// ============ AI Search Request Types ============
|
|
3942
3947
|
export type AiSearchSearchRequest = {
|
|
3943
3948
|
messages: Array<{
|
|
3944
3949
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
@@ -3963,9 +3968,8 @@ export type AiSearchSearchRequest = {
|
|
|
3963
3968
|
[key: string]: unknown;
|
|
3964
3969
|
};
|
|
3965
3970
|
reranking?: {
|
|
3966
|
-
/** Enable reranking (default false) */
|
|
3967
3971
|
enabled?: boolean;
|
|
3968
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
3972
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
3969
3973
|
/** Match threshold (0-1, default 0.4) */
|
|
3970
3974
|
match_threshold?: number;
|
|
3971
3975
|
[key: string]: unknown;
|
|
@@ -3977,6 +3981,7 @@ export type AiSearchChatCompletionsRequest = {
|
|
|
3977
3981
|
messages: Array<{
|
|
3978
3982
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
3979
3983
|
content: string | null;
|
|
3984
|
+
[key: string]: unknown;
|
|
3980
3985
|
}>;
|
|
3981
3986
|
model?: string;
|
|
3982
3987
|
stream?: boolean;
|
|
@@ -3997,7 +4002,7 @@ export type AiSearchChatCompletionsRequest = {
|
|
|
3997
4002
|
};
|
|
3998
4003
|
reranking?: {
|
|
3999
4004
|
enabled?: boolean;
|
|
4000
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
4005
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
4001
4006
|
match_threshold?: number;
|
|
4002
4007
|
[key: string]: unknown;
|
|
4003
4008
|
};
|
|
@@ -4005,7 +4010,7 @@ export type AiSearchChatCompletionsRequest = {
|
|
|
4005
4010
|
};
|
|
4006
4011
|
[key: string]: unknown;
|
|
4007
4012
|
};
|
|
4008
|
-
// AI Search
|
|
4013
|
+
// ============ AI Search Response Types ============
|
|
4009
4014
|
export type AiSearchSearchResponse = {
|
|
4010
4015
|
search_query: string;
|
|
4011
4016
|
chunks: Array<{
|
|
@@ -4024,26 +4029,65 @@ export type AiSearchSearchResponse = {
|
|
|
4024
4029
|
keyword_score?: number;
|
|
4025
4030
|
/** Vector similarity score (0-1) */
|
|
4026
4031
|
vector_score?: number;
|
|
4032
|
+
[key: string]: unknown;
|
|
4033
|
+
};
|
|
4034
|
+
}>;
|
|
4035
|
+
};
|
|
4036
|
+
export type AiSearchChatCompletionsResponse = {
|
|
4037
|
+
id?: string;
|
|
4038
|
+
object?: string;
|
|
4039
|
+
model?: string;
|
|
4040
|
+
choices: Array<{
|
|
4041
|
+
index?: number;
|
|
4042
|
+
message: {
|
|
4043
|
+
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
4044
|
+
content: string | null;
|
|
4045
|
+
[key: string]: unknown;
|
|
4027
4046
|
};
|
|
4047
|
+
[key: string]: unknown;
|
|
4028
4048
|
}>;
|
|
4049
|
+
chunks: AiSearchSearchResponse["chunks"];
|
|
4050
|
+
[key: string]: unknown;
|
|
4029
4051
|
};
|
|
4030
|
-
export type
|
|
4052
|
+
export type AiSearchStatsResponse = {
|
|
4053
|
+
queued?: number;
|
|
4054
|
+
running?: number;
|
|
4055
|
+
completed?: number;
|
|
4056
|
+
error?: number;
|
|
4057
|
+
skipped?: number;
|
|
4058
|
+
outdated?: number;
|
|
4059
|
+
last_activity?: string;
|
|
4060
|
+
};
|
|
4061
|
+
// ============ AI Search Instance Info Types ============
|
|
4062
|
+
export type AiSearchInstanceInfo = {
|
|
4031
4063
|
id: string;
|
|
4032
|
-
|
|
4033
|
-
account_id?: string;
|
|
4034
|
-
account_tag?: string;
|
|
4035
|
-
/** Whether the instance is enabled (default true) */
|
|
4036
|
-
enable?: boolean;
|
|
4037
|
-
type?: "r2" | "web-crawler";
|
|
4064
|
+
type?: "r2" | "web-crawler" | string;
|
|
4038
4065
|
source?: string;
|
|
4066
|
+
paused?: boolean;
|
|
4067
|
+
status?: string;
|
|
4068
|
+
namespace?: string;
|
|
4069
|
+
created_at?: string;
|
|
4070
|
+
modified_at?: string;
|
|
4039
4071
|
[key: string]: unknown;
|
|
4040
|
-
}
|
|
4072
|
+
};
|
|
4073
|
+
export type AiSearchListResponse = {
|
|
4074
|
+
result: AiSearchInstanceInfo[];
|
|
4075
|
+
result_info?: {
|
|
4076
|
+
count: number;
|
|
4077
|
+
page: number;
|
|
4078
|
+
per_page: number;
|
|
4079
|
+
total_count: number;
|
|
4080
|
+
};
|
|
4081
|
+
};
|
|
4082
|
+
// ============ AI Search Config Types ============
|
|
4041
4083
|
export type AiSearchConfig = {
|
|
4042
4084
|
/** Instance ID (1-32 chars, pattern: ^[a-z0-9_]+(?:-[a-z0-9_]+)*$) */
|
|
4043
4085
|
id: string;
|
|
4044
|
-
type
|
|
4045
|
-
|
|
4046
|
-
|
|
4086
|
+
/** Instance type. Omit to create with built-in storage. */
|
|
4087
|
+
type?: "r2" | "web-crawler" | string;
|
|
4088
|
+
/** Source URL (required for web-crawler type). */
|
|
4089
|
+
source?: string;
|
|
4090
|
+
source_params?: unknown;
|
|
4047
4091
|
/** Token ID (UUID format) */
|
|
4048
4092
|
token_id?: string;
|
|
4049
4093
|
ai_gateway_id?: string;
|
|
@@ -4053,54 +4097,307 @@ export type AiSearchConfig = {
|
|
|
4053
4097
|
reranking?: boolean;
|
|
4054
4098
|
embedding_model?: string;
|
|
4055
4099
|
ai_search_model?: string;
|
|
4100
|
+
[key: string]: unknown;
|
|
4056
4101
|
};
|
|
4057
|
-
|
|
4102
|
+
// ============ AI Search Item Types ============
|
|
4103
|
+
export type AiSearchItemInfo = {
|
|
4058
4104
|
id: string;
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4105
|
+
key: string;
|
|
4106
|
+
status:
|
|
4107
|
+
| "completed"
|
|
4108
|
+
| "error"
|
|
4109
|
+
| "skipped"
|
|
4110
|
+
| "queued"
|
|
4111
|
+
| "processing"
|
|
4112
|
+
| "outdated";
|
|
4113
|
+
metadata?: Record<string, unknown>;
|
|
4062
4114
|
[key: string]: unknown;
|
|
4063
4115
|
};
|
|
4064
|
-
|
|
4065
|
-
|
|
4116
|
+
export type AiSearchItemContentResult = {
|
|
4117
|
+
body: ReadableStream;
|
|
4118
|
+
contentType: string;
|
|
4119
|
+
filename: string;
|
|
4120
|
+
size: number;
|
|
4121
|
+
};
|
|
4122
|
+
export type AiSearchUploadItemOptions = {
|
|
4123
|
+
metadata?: Record<string, unknown>;
|
|
4124
|
+
};
|
|
4125
|
+
export type AiSearchListItemsParams = {
|
|
4126
|
+
page?: number;
|
|
4127
|
+
per_page?: number;
|
|
4128
|
+
};
|
|
4129
|
+
export type AiSearchListItemsResponse = {
|
|
4130
|
+
result: AiSearchItemInfo[];
|
|
4131
|
+
result_info?: {
|
|
4132
|
+
count: number;
|
|
4133
|
+
page: number;
|
|
4134
|
+
per_page: number;
|
|
4135
|
+
total_count: number;
|
|
4136
|
+
};
|
|
4137
|
+
};
|
|
4138
|
+
// ============ AI Search Job Types ============
|
|
4139
|
+
export type AiSearchJobInfo = {
|
|
4140
|
+
id: string;
|
|
4141
|
+
source: "user" | "schedule";
|
|
4142
|
+
description?: string;
|
|
4143
|
+
last_seen_at?: string;
|
|
4144
|
+
started_at?: string;
|
|
4145
|
+
ended_at?: string;
|
|
4146
|
+
end_reason?: string;
|
|
4147
|
+
};
|
|
4148
|
+
export type AiSearchJobLog = {
|
|
4149
|
+
id: number;
|
|
4150
|
+
message: string;
|
|
4151
|
+
message_type: number;
|
|
4152
|
+
created_at: number;
|
|
4153
|
+
};
|
|
4154
|
+
export type AiSearchCreateJobParams = {
|
|
4155
|
+
description?: string;
|
|
4156
|
+
};
|
|
4157
|
+
export type AiSearchListJobsParams = {
|
|
4158
|
+
page?: number;
|
|
4159
|
+
per_page?: number;
|
|
4160
|
+
};
|
|
4161
|
+
export type AiSearchListJobsResponse = {
|
|
4162
|
+
result: AiSearchJobInfo[];
|
|
4163
|
+
result_info?: {
|
|
4164
|
+
count: number;
|
|
4165
|
+
page: number;
|
|
4166
|
+
per_page: number;
|
|
4167
|
+
total_count: number;
|
|
4168
|
+
};
|
|
4169
|
+
};
|
|
4170
|
+
export type AiSearchJobLogsParams = {
|
|
4171
|
+
page?: number;
|
|
4172
|
+
per_page?: number;
|
|
4173
|
+
};
|
|
4174
|
+
export type AiSearchJobLogsResponse = {
|
|
4175
|
+
result: AiSearchJobLog[];
|
|
4176
|
+
result_info?: {
|
|
4177
|
+
count: number;
|
|
4178
|
+
page: number;
|
|
4179
|
+
per_page: number;
|
|
4180
|
+
total_count: number;
|
|
4181
|
+
};
|
|
4182
|
+
};
|
|
4183
|
+
// ============ AI Search Sub-Service Classes ============
|
|
4184
|
+
/**
|
|
4185
|
+
* Single item service for an AI Search instance.
|
|
4186
|
+
* Provides info, delete, and download operations on a specific item.
|
|
4187
|
+
*/
|
|
4188
|
+
export declare abstract class AiSearchItem {
|
|
4189
|
+
/** Get metadata about this item. */
|
|
4190
|
+
info(): Promise<AiSearchItemInfo>;
|
|
4191
|
+
/**
|
|
4192
|
+
* Download the item's content.
|
|
4193
|
+
* @returns Object with body stream, content type, filename, and size.
|
|
4194
|
+
*/
|
|
4195
|
+
download(): Promise<AiSearchItemContentResult>;
|
|
4196
|
+
}
|
|
4197
|
+
/**
|
|
4198
|
+
* Items collection service for an AI Search instance.
|
|
4199
|
+
* Provides list, upload, and access to individual items.
|
|
4200
|
+
*/
|
|
4201
|
+
export declare abstract class AiSearchItems {
|
|
4202
|
+
/** List items in this instance. */
|
|
4203
|
+
list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
|
|
4204
|
+
/**
|
|
4205
|
+
* Upload a file as an item.
|
|
4206
|
+
* @param name Filename for the uploaded item.
|
|
4207
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4208
|
+
* @param options Optional metadata to attach to the item.
|
|
4209
|
+
* @returns The created item info.
|
|
4210
|
+
*/
|
|
4211
|
+
upload(
|
|
4212
|
+
name: string,
|
|
4213
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4214
|
+
options?: AiSearchUploadItemOptions,
|
|
4215
|
+
): Promise<AiSearchItemInfo>;
|
|
4216
|
+
/**
|
|
4217
|
+
* Upload a file and poll until processing completes.
|
|
4218
|
+
* @param name Filename for the uploaded item.
|
|
4219
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4220
|
+
* @param options Optional metadata to attach to the item.
|
|
4221
|
+
* @returns The item info after processing completes (or timeout).
|
|
4222
|
+
*/
|
|
4223
|
+
uploadAndPoll(
|
|
4224
|
+
name: string,
|
|
4225
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4226
|
+
options?: AiSearchUploadItemOptions,
|
|
4227
|
+
): Promise<AiSearchItemInfo>;
|
|
4228
|
+
/**
|
|
4229
|
+
* Get an item by ID.
|
|
4230
|
+
* @param itemId The item identifier.
|
|
4231
|
+
* @returns Item service for info, delete, and download operations.
|
|
4232
|
+
*/
|
|
4233
|
+
get(itemId: string): AiSearchItem;
|
|
4234
|
+
/** Delete this item from the instance.
|
|
4235
|
+
* @param itemId The item identifier.
|
|
4236
|
+
*/
|
|
4237
|
+
delete(itemId: string): Promise<void>;
|
|
4238
|
+
}
|
|
4239
|
+
/**
|
|
4240
|
+
* Single job service for an AI Search instance.
|
|
4241
|
+
* Provides info and logs for a specific job.
|
|
4242
|
+
*/
|
|
4243
|
+
export declare abstract class AiSearchJob {
|
|
4244
|
+
/** Get metadata about this job. */
|
|
4245
|
+
info(): Promise<AiSearchJobInfo>;
|
|
4246
|
+
/** Get logs for this job. */
|
|
4247
|
+
logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
|
|
4248
|
+
}
|
|
4249
|
+
/**
|
|
4250
|
+
* Jobs collection service for an AI Search instance.
|
|
4251
|
+
* Provides list, create, and access to individual jobs.
|
|
4252
|
+
*/
|
|
4253
|
+
export declare abstract class AiSearchJobs {
|
|
4254
|
+
/** List jobs for this instance. */
|
|
4255
|
+
list(params?: AiSearchListJobsParams): Promise<AiSearchListJobsResponse>;
|
|
4256
|
+
/**
|
|
4257
|
+
* Create a new indexing job.
|
|
4258
|
+
* @param params Optional job parameters.
|
|
4259
|
+
* @returns The created job info.
|
|
4260
|
+
*/
|
|
4261
|
+
create(params?: AiSearchCreateJobParams): Promise<AiSearchJobInfo>;
|
|
4262
|
+
/**
|
|
4263
|
+
* Get a job by ID.
|
|
4264
|
+
* @param jobId The job identifier.
|
|
4265
|
+
* @returns Job service for info and logs operations.
|
|
4266
|
+
*/
|
|
4267
|
+
get(jobId: string): AiSearchJob;
|
|
4268
|
+
}
|
|
4269
|
+
// ============ AI Search Binding Classes ============
|
|
4270
|
+
/**
|
|
4271
|
+
* Instance-level AI Search service.
|
|
4272
|
+
*
|
|
4273
|
+
* Used as:
|
|
4274
|
+
* - The return type of `AiSearchNamespace.get(name)` (namespace binding)
|
|
4275
|
+
* - The type of `env.BLOG_SEARCH` (single instance binding via `ai_search`)
|
|
4276
|
+
*
|
|
4277
|
+
* Provides search, chat, update, stats, items, and jobs operations.
|
|
4278
|
+
*
|
|
4279
|
+
* @example
|
|
4280
|
+
* ```ts
|
|
4281
|
+
* // Via namespace binding
|
|
4282
|
+
* const instance = env.AI_SEARCH.get("blog");
|
|
4283
|
+
* const results = await instance.search({
|
|
4284
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4285
|
+
* });
|
|
4286
|
+
*
|
|
4287
|
+
* // Via single instance binding
|
|
4288
|
+
* const results = await env.BLOG_SEARCH.search({
|
|
4289
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4290
|
+
* });
|
|
4291
|
+
* ```
|
|
4292
|
+
*/
|
|
4293
|
+
export declare abstract class AiSearchInstance {
|
|
4066
4294
|
/**
|
|
4067
4295
|
* Search the AI Search instance for relevant chunks.
|
|
4068
|
-
* @param params Search request with messages and AI search options
|
|
4069
|
-
* @returns Search response with matching chunks
|
|
4296
|
+
* @param params Search request with messages and optional AI search options.
|
|
4297
|
+
* @returns Search response with matching chunks and search query.
|
|
4070
4298
|
*/
|
|
4071
4299
|
search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
|
|
4300
|
+
/**
|
|
4301
|
+
* Generate chat completions with AI Search context (streaming).
|
|
4302
|
+
* @param params Chat completions request with stream: true.
|
|
4303
|
+
* @returns ReadableStream of server-sent events.
|
|
4304
|
+
*/
|
|
4305
|
+
chatCompletions(
|
|
4306
|
+
params: AiSearchChatCompletionsRequest & {
|
|
4307
|
+
stream: true;
|
|
4308
|
+
},
|
|
4309
|
+
): Promise<ReadableStream>;
|
|
4072
4310
|
/**
|
|
4073
4311
|
* Generate chat completions with AI Search context.
|
|
4074
|
-
* @param params Chat completions request
|
|
4075
|
-
* @returns
|
|
4312
|
+
* @param params Chat completions request.
|
|
4313
|
+
* @returns Chat completion response with choices and RAG chunks.
|
|
4076
4314
|
*/
|
|
4077
4315
|
chatCompletions(
|
|
4078
4316
|
params: AiSearchChatCompletionsRequest,
|
|
4079
|
-
): Promise<
|
|
4317
|
+
): Promise<AiSearchChatCompletionsResponse>;
|
|
4080
4318
|
/**
|
|
4081
|
-
*
|
|
4319
|
+
* Update the instance configuration.
|
|
4320
|
+
* @param config Partial configuration to update.
|
|
4321
|
+
* @returns Updated instance info.
|
|
4082
4322
|
*/
|
|
4083
|
-
|
|
4323
|
+
update(config: Partial<AiSearchConfig>): Promise<AiSearchInstanceInfo>;
|
|
4324
|
+
/** Get metadata about this instance. */
|
|
4325
|
+
info(): Promise<AiSearchInstanceInfo>;
|
|
4326
|
+
/**
|
|
4327
|
+
* Get instance statistics (item count, indexing status, etc.).
|
|
4328
|
+
* @returns Statistics with counts per status and last activity time.
|
|
4329
|
+
*/
|
|
4330
|
+
stats(): Promise<AiSearchStatsResponse>;
|
|
4331
|
+
/** Items collection — list, upload, and manage items in this instance. */
|
|
4332
|
+
get items(): AiSearchItems;
|
|
4333
|
+
/** Jobs collection — list, create, and inspect indexing jobs. */
|
|
4334
|
+
get jobs(): AiSearchJobs;
|
|
4084
4335
|
}
|
|
4085
|
-
|
|
4086
|
-
|
|
4336
|
+
/**
|
|
4337
|
+
* Namespace-level AI Search service.
|
|
4338
|
+
*
|
|
4339
|
+
* Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
|
|
4340
|
+
* Scoped to a single namespace. Provides dynamic instance access, creation, and deletion.
|
|
4341
|
+
*
|
|
4342
|
+
* @example
|
|
4343
|
+
* ```ts
|
|
4344
|
+
* // Access an instance within the namespace
|
|
4345
|
+
* const blog = env.AI_SEARCH.get("blog");
|
|
4346
|
+
* const results = await blog.search({
|
|
4347
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4348
|
+
* });
|
|
4349
|
+
*
|
|
4350
|
+
* // List all instances in the namespace
|
|
4351
|
+
* const instances = await env.AI_SEARCH.list();
|
|
4352
|
+
*
|
|
4353
|
+
* // Create a new instance with built-in storage
|
|
4354
|
+
* const tenant = await env.AI_SEARCH.create({
|
|
4355
|
+
* id: "tenant-123",
|
|
4356
|
+
* });
|
|
4357
|
+
*
|
|
4358
|
+
* // Upload items into the instance
|
|
4359
|
+
* await tenant.items.upload("doc.pdf", fileContent);
|
|
4360
|
+
*
|
|
4361
|
+
* // Delete an instance
|
|
4362
|
+
* await env.AI_SEARCH.delete("tenant-123");
|
|
4363
|
+
* ```
|
|
4364
|
+
*/
|
|
4365
|
+
export declare abstract class AiSearchNamespace {
|
|
4087
4366
|
/**
|
|
4088
|
-
*
|
|
4089
|
-
* @
|
|
4367
|
+
* Get an instance by name within the bound namespace.
|
|
4368
|
+
* @param name Instance name.
|
|
4369
|
+
* @returns Instance service for search, chat, update, stats, items, and jobs.
|
|
4370
|
+
*/
|
|
4371
|
+
get(name: string): AiSearchInstance;
|
|
4372
|
+
/**
|
|
4373
|
+
* List all instances in the bound namespace.
|
|
4374
|
+
* @returns Array of instance metadata.
|
|
4090
4375
|
*/
|
|
4091
4376
|
list(): Promise<AiSearchListResponse>;
|
|
4092
4377
|
/**
|
|
4093
|
-
*
|
|
4094
|
-
* @param
|
|
4095
|
-
* @returns Instance service for
|
|
4378
|
+
* Create a new instance within the bound namespace.
|
|
4379
|
+
* @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
|
|
4380
|
+
* @returns Instance service for the newly created instance.
|
|
4381
|
+
*
|
|
4382
|
+
* @example
|
|
4383
|
+
* ```ts
|
|
4384
|
+
* // Create with built-in storage (upload items manually)
|
|
4385
|
+
* const instance = await env.AI_SEARCH.create({ id: "my-search" });
|
|
4386
|
+
*
|
|
4387
|
+
* // Create with web crawler source
|
|
4388
|
+
* const instance = await env.AI_SEARCH.create({
|
|
4389
|
+
* id: "docs-search",
|
|
4390
|
+
* type: "web-crawler",
|
|
4391
|
+
* source: "https://developers.cloudflare.com",
|
|
4392
|
+
* });
|
|
4393
|
+
* ```
|
|
4096
4394
|
*/
|
|
4097
|
-
|
|
4395
|
+
create(config: AiSearchConfig): Promise<AiSearchInstance>;
|
|
4098
4396
|
/**
|
|
4099
|
-
*
|
|
4100
|
-
* @param
|
|
4101
|
-
* @returns Instance service for performing operations
|
|
4397
|
+
* Delete an instance from the bound namespace.
|
|
4398
|
+
* @param name Instance name to delete.
|
|
4102
4399
|
*/
|
|
4103
|
-
|
|
4400
|
+
delete(name: string): Promise<void>;
|
|
4104
4401
|
}
|
|
4105
4402
|
export type AiImageClassificationInput = {
|
|
4106
4403
|
image: number[];
|
|
@@ -10101,6 +10398,7 @@ export type AiOptions = {
|
|
|
10101
10398
|
returnRawResponse?: boolean;
|
|
10102
10399
|
prefix?: string;
|
|
10103
10400
|
extraHeaders?: object;
|
|
10401
|
+
signal?: AbortSignal;
|
|
10104
10402
|
};
|
|
10105
10403
|
export type AiModelsSearchParams = {
|
|
10106
10404
|
author?: string;
|
|
@@ -10146,46 +10444,16 @@ export declare abstract class Ai<
|
|
|
10146
10444
|
aiGatewayLogId: string | null;
|
|
10147
10445
|
gateway(gatewayId: string): AiGateway;
|
|
10148
10446
|
/**
|
|
10149
|
-
*
|
|
10150
|
-
*
|
|
10151
|
-
* This is the new API that replaces AutoRAG with better namespace separation:
|
|
10152
|
-
* - Account-level operations: `list()`, `create()`
|
|
10153
|
-
* - Instance-level operations: `get(id).search()`, `get(id).chatCompletions()`, `get(id).delete()`
|
|
10154
|
-
*
|
|
10155
|
-
* @example
|
|
10156
|
-
* ```typescript
|
|
10157
|
-
* // List all AI Search instances
|
|
10158
|
-
* const instances = await env.AI.aiSearch.list();
|
|
10159
|
-
*
|
|
10160
|
-
* // Search an instance
|
|
10161
|
-
* const results = await env.AI.aiSearch.get('my-search').search({
|
|
10162
|
-
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
10163
|
-
* ai_search_options: {
|
|
10164
|
-
* retrieval: { max_num_results: 10 }
|
|
10165
|
-
* }
|
|
10166
|
-
* });
|
|
10167
|
-
*
|
|
10168
|
-
* // Generate chat completions with AI Search context
|
|
10169
|
-
* const response = await env.AI.aiSearch.get('my-search').chatCompletions({
|
|
10170
|
-
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
10171
|
-
* model: '@cf/meta/llama-3.3-70b-instruct-fp8-fast'
|
|
10172
|
-
* });
|
|
10173
|
-
* ```
|
|
10447
|
+
* @deprecated Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
10448
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10174
10449
|
*/
|
|
10175
|
-
aiSearch():
|
|
10450
|
+
aiSearch(): AiSearchNamespace;
|
|
10176
10451
|
/**
|
|
10177
10452
|
* @deprecated AutoRAG has been replaced by AI Search.
|
|
10178
|
-
* Use `
|
|
10179
|
-
*
|
|
10180
|
-
* Migration guide:
|
|
10181
|
-
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
10182
|
-
* - `env.AI.autorag('id').search({ query: '...' })` → `env.AI.aiSearch.get('id').search({ messages: [{ role: 'user', content: '...' }] })`
|
|
10183
|
-
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
10453
|
+
* Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
10454
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10184
10455
|
*
|
|
10185
|
-
*
|
|
10186
|
-
*
|
|
10187
|
-
* @see AiSearchAccountService
|
|
10188
|
-
* @param autoragId Optional instance ID (omit for account-level operations)
|
|
10456
|
+
* @param autoragId Instance ID
|
|
10189
10457
|
*/
|
|
10190
10458
|
autorag(autoragId: string): AutoRAG;
|
|
10191
10459
|
run<
|
|
@@ -10344,22 +10612,23 @@ export declare abstract class AiGateway {
|
|
|
10344
10612
|
getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
|
|
10345
10613
|
}
|
|
10346
10614
|
/**
|
|
10347
|
-
* @deprecated
|
|
10348
|
-
*
|
|
10615
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10616
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10349
10617
|
*/
|
|
10350
10618
|
export interface AutoRAGInternalError extends Error {}
|
|
10351
10619
|
/**
|
|
10352
|
-
* @deprecated
|
|
10353
|
-
*
|
|
10620
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10621
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10354
10622
|
*/
|
|
10355
10623
|
export interface AutoRAGNotFoundError extends Error {}
|
|
10356
10624
|
/**
|
|
10357
|
-
* @deprecated
|
|
10625
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10626
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10358
10627
|
*/
|
|
10359
10628
|
export interface AutoRAGUnauthorizedError extends Error {}
|
|
10360
10629
|
/**
|
|
10361
|
-
* @deprecated
|
|
10362
|
-
*
|
|
10630
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10631
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10363
10632
|
*/
|
|
10364
10633
|
export interface AutoRAGNameNotSetError extends Error {}
|
|
10365
10634
|
export type ComparisonFilter = {
|
|
@@ -10372,9 +10641,8 @@ export type CompoundFilter = {
|
|
|
10372
10641
|
filters: ComparisonFilter[];
|
|
10373
10642
|
};
|
|
10374
10643
|
/**
|
|
10375
|
-
* @deprecated
|
|
10376
|
-
*
|
|
10377
|
-
* @see AiSearchSearchRequest
|
|
10644
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10645
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10378
10646
|
*/
|
|
10379
10647
|
export type AutoRagSearchRequest = {
|
|
10380
10648
|
query: string;
|
|
@@ -10391,18 +10659,16 @@ export type AutoRagSearchRequest = {
|
|
|
10391
10659
|
rewrite_query?: boolean;
|
|
10392
10660
|
};
|
|
10393
10661
|
/**
|
|
10394
|
-
* @deprecated
|
|
10395
|
-
*
|
|
10396
|
-
* @see AiSearchChatCompletionsRequest
|
|
10662
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10663
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10397
10664
|
*/
|
|
10398
10665
|
export type AutoRagAiSearchRequest = AutoRagSearchRequest & {
|
|
10399
10666
|
stream?: boolean;
|
|
10400
10667
|
system_prompt?: string;
|
|
10401
10668
|
};
|
|
10402
10669
|
/**
|
|
10403
|
-
* @deprecated
|
|
10404
|
-
*
|
|
10405
|
-
* @see AiSearchChatCompletionsRequest
|
|
10670
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10671
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10406
10672
|
*/
|
|
10407
10673
|
export type AutoRagAiSearchRequestStreaming = Omit<
|
|
10408
10674
|
AutoRagAiSearchRequest,
|
|
@@ -10411,9 +10677,8 @@ export type AutoRagAiSearchRequestStreaming = Omit<
|
|
|
10411
10677
|
stream: true;
|
|
10412
10678
|
};
|
|
10413
10679
|
/**
|
|
10414
|
-
* @deprecated
|
|
10415
|
-
*
|
|
10416
|
-
* @see AiSearchSearchResponse
|
|
10680
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10681
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10417
10682
|
*/
|
|
10418
10683
|
export type AutoRagSearchResponse = {
|
|
10419
10684
|
object: "vector_store.search_results.page";
|
|
@@ -10432,9 +10697,8 @@ export type AutoRagSearchResponse = {
|
|
|
10432
10697
|
next_page: string | null;
|
|
10433
10698
|
};
|
|
10434
10699
|
/**
|
|
10435
|
-
* @deprecated
|
|
10436
|
-
*
|
|
10437
|
-
* @see AiSearchListResponse
|
|
10700
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10701
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10438
10702
|
*/
|
|
10439
10703
|
export type AutoRagListResponse = {
|
|
10440
10704
|
id: string;
|
|
@@ -10446,49 +10710,40 @@ export type AutoRagListResponse = {
|
|
|
10446
10710
|
status: string;
|
|
10447
10711
|
}[];
|
|
10448
10712
|
/**
|
|
10449
|
-
* @deprecated
|
|
10450
|
-
*
|
|
10713
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10714
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10451
10715
|
*/
|
|
10452
10716
|
export type AutoRagAiSearchResponse = AutoRagSearchResponse & {
|
|
10453
10717
|
response: string;
|
|
10454
10718
|
};
|
|
10455
10719
|
/**
|
|
10456
|
-
* @deprecated
|
|
10457
|
-
*
|
|
10458
|
-
*
|
|
10459
|
-
* Migration guide:
|
|
10460
|
-
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
10461
|
-
* - `env.AI.autorag('id').search(...)` → `env.AI.aiSearch.get('id').search(...)`
|
|
10462
|
-
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
10463
|
-
*
|
|
10464
|
-
* @see AiSearchAccountService
|
|
10465
|
-
* @see AiSearchInstanceService
|
|
10720
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10721
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10466
10722
|
*/
|
|
10467
10723
|
export declare abstract class AutoRAG {
|
|
10468
10724
|
/**
|
|
10469
|
-
* @deprecated Use
|
|
10470
|
-
*
|
|
10725
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10726
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10471
10727
|
*/
|
|
10472
10728
|
list(): Promise<AutoRagListResponse>;
|
|
10473
10729
|
/**
|
|
10474
|
-
* @deprecated Use
|
|
10475
|
-
*
|
|
10476
|
-
* @see AiSearchInstanceService.search
|
|
10730
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10731
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10477
10732
|
*/
|
|
10478
10733
|
search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;
|
|
10479
10734
|
/**
|
|
10480
|
-
* @deprecated Use
|
|
10481
|
-
*
|
|
10735
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10736
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10482
10737
|
*/
|
|
10483
10738
|
aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;
|
|
10484
10739
|
/**
|
|
10485
|
-
* @deprecated Use
|
|
10486
|
-
*
|
|
10740
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10741
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10487
10742
|
*/
|
|
10488
10743
|
aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;
|
|
10489
10744
|
/**
|
|
10490
|
-
* @deprecated Use
|
|
10491
|
-
*
|
|
10745
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10746
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10492
10747
|
*/
|
|
10493
10748
|
aiSearch(
|
|
10494
10749
|
params: AutoRagAiSearchRequest,
|