@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/2022-11-30/index.ts
CHANGED
|
@@ -3103,6 +3103,11 @@ export interface QueuingStrategyInit {
|
|
|
3103
3103
|
*/
|
|
3104
3104
|
highWaterMark: number;
|
|
3105
3105
|
}
|
|
3106
|
+
export interface TracePreviewInfo {
|
|
3107
|
+
id: string;
|
|
3108
|
+
slug: string;
|
|
3109
|
+
name: string;
|
|
3110
|
+
}
|
|
3106
3111
|
export interface ScriptVersion {
|
|
3107
3112
|
id?: string;
|
|
3108
3113
|
tag?: string;
|
|
@@ -3137,6 +3142,7 @@ export interface TraceItem {
|
|
|
3137
3142
|
readonly dispatchNamespace?: string;
|
|
3138
3143
|
readonly scriptTags?: string[];
|
|
3139
3144
|
readonly tailAttributes?: Record<string, boolean | number | string>;
|
|
3145
|
+
readonly preview?: TracePreviewInfo;
|
|
3140
3146
|
readonly durableObjectId?: string;
|
|
3141
3147
|
readonly outcome: string;
|
|
3142
3148
|
readonly executionModel: string;
|
|
@@ -3895,11 +3901,10 @@ export declare abstract class Performance {
|
|
|
3895
3901
|
*/
|
|
3896
3902
|
toJSON(): object;
|
|
3897
3903
|
}
|
|
3898
|
-
// AI Search
|
|
3904
|
+
// ============ AI Search Error Interfaces ============
|
|
3899
3905
|
export interface AiSearchInternalError extends Error {}
|
|
3900
3906
|
export interface AiSearchNotFoundError extends Error {}
|
|
3901
|
-
|
|
3902
|
-
// AI Search V2 Request Types
|
|
3907
|
+
// ============ AI Search Request Types ============
|
|
3903
3908
|
export type AiSearchSearchRequest = {
|
|
3904
3909
|
messages: Array<{
|
|
3905
3910
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
@@ -3924,9 +3929,8 @@ export type AiSearchSearchRequest = {
|
|
|
3924
3929
|
[key: string]: unknown;
|
|
3925
3930
|
};
|
|
3926
3931
|
reranking?: {
|
|
3927
|
-
/** Enable reranking (default false) */
|
|
3928
3932
|
enabled?: boolean;
|
|
3929
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
3933
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
3930
3934
|
/** Match threshold (0-1, default 0.4) */
|
|
3931
3935
|
match_threshold?: number;
|
|
3932
3936
|
[key: string]: unknown;
|
|
@@ -3938,6 +3942,7 @@ export type AiSearchChatCompletionsRequest = {
|
|
|
3938
3942
|
messages: Array<{
|
|
3939
3943
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
3940
3944
|
content: string | null;
|
|
3945
|
+
[key: string]: unknown;
|
|
3941
3946
|
}>;
|
|
3942
3947
|
model?: string;
|
|
3943
3948
|
stream?: boolean;
|
|
@@ -3958,7 +3963,7 @@ export type AiSearchChatCompletionsRequest = {
|
|
|
3958
3963
|
};
|
|
3959
3964
|
reranking?: {
|
|
3960
3965
|
enabled?: boolean;
|
|
3961
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
3966
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
3962
3967
|
match_threshold?: number;
|
|
3963
3968
|
[key: string]: unknown;
|
|
3964
3969
|
};
|
|
@@ -3966,7 +3971,7 @@ export type AiSearchChatCompletionsRequest = {
|
|
|
3966
3971
|
};
|
|
3967
3972
|
[key: string]: unknown;
|
|
3968
3973
|
};
|
|
3969
|
-
// AI Search
|
|
3974
|
+
// ============ AI Search Response Types ============
|
|
3970
3975
|
export type AiSearchSearchResponse = {
|
|
3971
3976
|
search_query: string;
|
|
3972
3977
|
chunks: Array<{
|
|
@@ -3985,26 +3990,65 @@ export type AiSearchSearchResponse = {
|
|
|
3985
3990
|
keyword_score?: number;
|
|
3986
3991
|
/** Vector similarity score (0-1) */
|
|
3987
3992
|
vector_score?: number;
|
|
3993
|
+
[key: string]: unknown;
|
|
3994
|
+
};
|
|
3995
|
+
}>;
|
|
3996
|
+
};
|
|
3997
|
+
export type AiSearchChatCompletionsResponse = {
|
|
3998
|
+
id?: string;
|
|
3999
|
+
object?: string;
|
|
4000
|
+
model?: string;
|
|
4001
|
+
choices: Array<{
|
|
4002
|
+
index?: number;
|
|
4003
|
+
message: {
|
|
4004
|
+
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
4005
|
+
content: string | null;
|
|
4006
|
+
[key: string]: unknown;
|
|
3988
4007
|
};
|
|
4008
|
+
[key: string]: unknown;
|
|
3989
4009
|
}>;
|
|
4010
|
+
chunks: AiSearchSearchResponse["chunks"];
|
|
4011
|
+
[key: string]: unknown;
|
|
3990
4012
|
};
|
|
3991
|
-
export type
|
|
4013
|
+
export type AiSearchStatsResponse = {
|
|
4014
|
+
queued?: number;
|
|
4015
|
+
running?: number;
|
|
4016
|
+
completed?: number;
|
|
4017
|
+
error?: number;
|
|
4018
|
+
skipped?: number;
|
|
4019
|
+
outdated?: number;
|
|
4020
|
+
last_activity?: string;
|
|
4021
|
+
};
|
|
4022
|
+
// ============ AI Search Instance Info Types ============
|
|
4023
|
+
export type AiSearchInstanceInfo = {
|
|
3992
4024
|
id: string;
|
|
3993
|
-
|
|
3994
|
-
account_id?: string;
|
|
3995
|
-
account_tag?: string;
|
|
3996
|
-
/** Whether the instance is enabled (default true) */
|
|
3997
|
-
enable?: boolean;
|
|
3998
|
-
type?: "r2" | "web-crawler";
|
|
4025
|
+
type?: "r2" | "web-crawler" | string;
|
|
3999
4026
|
source?: string;
|
|
4027
|
+
paused?: boolean;
|
|
4028
|
+
status?: string;
|
|
4029
|
+
namespace?: string;
|
|
4030
|
+
created_at?: string;
|
|
4031
|
+
modified_at?: string;
|
|
4000
4032
|
[key: string]: unknown;
|
|
4001
|
-
}
|
|
4033
|
+
};
|
|
4034
|
+
export type AiSearchListResponse = {
|
|
4035
|
+
result: AiSearchInstanceInfo[];
|
|
4036
|
+
result_info?: {
|
|
4037
|
+
count: number;
|
|
4038
|
+
page: number;
|
|
4039
|
+
per_page: number;
|
|
4040
|
+
total_count: number;
|
|
4041
|
+
};
|
|
4042
|
+
};
|
|
4043
|
+
// ============ AI Search Config Types ============
|
|
4002
4044
|
export type AiSearchConfig = {
|
|
4003
4045
|
/** Instance ID (1-32 chars, pattern: ^[a-z0-9_]+(?:-[a-z0-9_]+)*$) */
|
|
4004
4046
|
id: string;
|
|
4005
|
-
type
|
|
4006
|
-
|
|
4007
|
-
|
|
4047
|
+
/** Instance type. Omit to create with built-in storage. */
|
|
4048
|
+
type?: "r2" | "web-crawler" | string;
|
|
4049
|
+
/** Source URL (required for web-crawler type). */
|
|
4050
|
+
source?: string;
|
|
4051
|
+
source_params?: unknown;
|
|
4008
4052
|
/** Token ID (UUID format) */
|
|
4009
4053
|
token_id?: string;
|
|
4010
4054
|
ai_gateway_id?: string;
|
|
@@ -4014,54 +4058,307 @@ export type AiSearchConfig = {
|
|
|
4014
4058
|
reranking?: boolean;
|
|
4015
4059
|
embedding_model?: string;
|
|
4016
4060
|
ai_search_model?: string;
|
|
4061
|
+
[key: string]: unknown;
|
|
4017
4062
|
};
|
|
4018
|
-
|
|
4063
|
+
// ============ AI Search Item Types ============
|
|
4064
|
+
export type AiSearchItemInfo = {
|
|
4019
4065
|
id: string;
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4066
|
+
key: string;
|
|
4067
|
+
status:
|
|
4068
|
+
| "completed"
|
|
4069
|
+
| "error"
|
|
4070
|
+
| "skipped"
|
|
4071
|
+
| "queued"
|
|
4072
|
+
| "processing"
|
|
4073
|
+
| "outdated";
|
|
4074
|
+
metadata?: Record<string, unknown>;
|
|
4023
4075
|
[key: string]: unknown;
|
|
4024
4076
|
};
|
|
4025
|
-
|
|
4026
|
-
|
|
4077
|
+
export type AiSearchItemContentResult = {
|
|
4078
|
+
body: ReadableStream;
|
|
4079
|
+
contentType: string;
|
|
4080
|
+
filename: string;
|
|
4081
|
+
size: number;
|
|
4082
|
+
};
|
|
4083
|
+
export type AiSearchUploadItemOptions = {
|
|
4084
|
+
metadata?: Record<string, unknown>;
|
|
4085
|
+
};
|
|
4086
|
+
export type AiSearchListItemsParams = {
|
|
4087
|
+
page?: number;
|
|
4088
|
+
per_page?: number;
|
|
4089
|
+
};
|
|
4090
|
+
export type AiSearchListItemsResponse = {
|
|
4091
|
+
result: AiSearchItemInfo[];
|
|
4092
|
+
result_info?: {
|
|
4093
|
+
count: number;
|
|
4094
|
+
page: number;
|
|
4095
|
+
per_page: number;
|
|
4096
|
+
total_count: number;
|
|
4097
|
+
};
|
|
4098
|
+
};
|
|
4099
|
+
// ============ AI Search Job Types ============
|
|
4100
|
+
export type AiSearchJobInfo = {
|
|
4101
|
+
id: string;
|
|
4102
|
+
source: "user" | "schedule";
|
|
4103
|
+
description?: string;
|
|
4104
|
+
last_seen_at?: string;
|
|
4105
|
+
started_at?: string;
|
|
4106
|
+
ended_at?: string;
|
|
4107
|
+
end_reason?: string;
|
|
4108
|
+
};
|
|
4109
|
+
export type AiSearchJobLog = {
|
|
4110
|
+
id: number;
|
|
4111
|
+
message: string;
|
|
4112
|
+
message_type: number;
|
|
4113
|
+
created_at: number;
|
|
4114
|
+
};
|
|
4115
|
+
export type AiSearchCreateJobParams = {
|
|
4116
|
+
description?: string;
|
|
4117
|
+
};
|
|
4118
|
+
export type AiSearchListJobsParams = {
|
|
4119
|
+
page?: number;
|
|
4120
|
+
per_page?: number;
|
|
4121
|
+
};
|
|
4122
|
+
export type AiSearchListJobsResponse = {
|
|
4123
|
+
result: AiSearchJobInfo[];
|
|
4124
|
+
result_info?: {
|
|
4125
|
+
count: number;
|
|
4126
|
+
page: number;
|
|
4127
|
+
per_page: number;
|
|
4128
|
+
total_count: number;
|
|
4129
|
+
};
|
|
4130
|
+
};
|
|
4131
|
+
export type AiSearchJobLogsParams = {
|
|
4132
|
+
page?: number;
|
|
4133
|
+
per_page?: number;
|
|
4134
|
+
};
|
|
4135
|
+
export type AiSearchJobLogsResponse = {
|
|
4136
|
+
result: AiSearchJobLog[];
|
|
4137
|
+
result_info?: {
|
|
4138
|
+
count: number;
|
|
4139
|
+
page: number;
|
|
4140
|
+
per_page: number;
|
|
4141
|
+
total_count: number;
|
|
4142
|
+
};
|
|
4143
|
+
};
|
|
4144
|
+
// ============ AI Search Sub-Service Classes ============
|
|
4145
|
+
/**
|
|
4146
|
+
* Single item service for an AI Search instance.
|
|
4147
|
+
* Provides info, delete, and download operations on a specific item.
|
|
4148
|
+
*/
|
|
4149
|
+
export declare abstract class AiSearchItem {
|
|
4150
|
+
/** Get metadata about this item. */
|
|
4151
|
+
info(): Promise<AiSearchItemInfo>;
|
|
4152
|
+
/**
|
|
4153
|
+
* Download the item's content.
|
|
4154
|
+
* @returns Object with body stream, content type, filename, and size.
|
|
4155
|
+
*/
|
|
4156
|
+
download(): Promise<AiSearchItemContentResult>;
|
|
4157
|
+
}
|
|
4158
|
+
/**
|
|
4159
|
+
* Items collection service for an AI Search instance.
|
|
4160
|
+
* Provides list, upload, and access to individual items.
|
|
4161
|
+
*/
|
|
4162
|
+
export declare abstract class AiSearchItems {
|
|
4163
|
+
/** List items in this instance. */
|
|
4164
|
+
list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
|
|
4165
|
+
/**
|
|
4166
|
+
* Upload a file as an item.
|
|
4167
|
+
* @param name Filename for the uploaded item.
|
|
4168
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4169
|
+
* @param options Optional metadata to attach to the item.
|
|
4170
|
+
* @returns The created item info.
|
|
4171
|
+
*/
|
|
4172
|
+
upload(
|
|
4173
|
+
name: string,
|
|
4174
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4175
|
+
options?: AiSearchUploadItemOptions,
|
|
4176
|
+
): Promise<AiSearchItemInfo>;
|
|
4177
|
+
/**
|
|
4178
|
+
* Upload a file and poll until processing completes.
|
|
4179
|
+
* @param name Filename for the uploaded item.
|
|
4180
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4181
|
+
* @param options Optional metadata to attach to the item.
|
|
4182
|
+
* @returns The item info after processing completes (or timeout).
|
|
4183
|
+
*/
|
|
4184
|
+
uploadAndPoll(
|
|
4185
|
+
name: string,
|
|
4186
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4187
|
+
options?: AiSearchUploadItemOptions,
|
|
4188
|
+
): Promise<AiSearchItemInfo>;
|
|
4189
|
+
/**
|
|
4190
|
+
* Get an item by ID.
|
|
4191
|
+
* @param itemId The item identifier.
|
|
4192
|
+
* @returns Item service for info, delete, and download operations.
|
|
4193
|
+
*/
|
|
4194
|
+
get(itemId: string): AiSearchItem;
|
|
4195
|
+
/** Delete this item from the instance.
|
|
4196
|
+
* @param itemId The item identifier.
|
|
4197
|
+
*/
|
|
4198
|
+
delete(itemId: string): Promise<void>;
|
|
4199
|
+
}
|
|
4200
|
+
/**
|
|
4201
|
+
* Single job service for an AI Search instance.
|
|
4202
|
+
* Provides info and logs for a specific job.
|
|
4203
|
+
*/
|
|
4204
|
+
export declare abstract class AiSearchJob {
|
|
4205
|
+
/** Get metadata about this job. */
|
|
4206
|
+
info(): Promise<AiSearchJobInfo>;
|
|
4207
|
+
/** Get logs for this job. */
|
|
4208
|
+
logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
|
|
4209
|
+
}
|
|
4210
|
+
/**
|
|
4211
|
+
* Jobs collection service for an AI Search instance.
|
|
4212
|
+
* Provides list, create, and access to individual jobs.
|
|
4213
|
+
*/
|
|
4214
|
+
export declare abstract class AiSearchJobs {
|
|
4215
|
+
/** List jobs for this instance. */
|
|
4216
|
+
list(params?: AiSearchListJobsParams): Promise<AiSearchListJobsResponse>;
|
|
4217
|
+
/**
|
|
4218
|
+
* Create a new indexing job.
|
|
4219
|
+
* @param params Optional job parameters.
|
|
4220
|
+
* @returns The created job info.
|
|
4221
|
+
*/
|
|
4222
|
+
create(params?: AiSearchCreateJobParams): Promise<AiSearchJobInfo>;
|
|
4223
|
+
/**
|
|
4224
|
+
* Get a job by ID.
|
|
4225
|
+
* @param jobId The job identifier.
|
|
4226
|
+
* @returns Job service for info and logs operations.
|
|
4227
|
+
*/
|
|
4228
|
+
get(jobId: string): AiSearchJob;
|
|
4229
|
+
}
|
|
4230
|
+
// ============ AI Search Binding Classes ============
|
|
4231
|
+
/**
|
|
4232
|
+
* Instance-level AI Search service.
|
|
4233
|
+
*
|
|
4234
|
+
* Used as:
|
|
4235
|
+
* - The return type of `AiSearchNamespace.get(name)` (namespace binding)
|
|
4236
|
+
* - The type of `env.BLOG_SEARCH` (single instance binding via `ai_search`)
|
|
4237
|
+
*
|
|
4238
|
+
* Provides search, chat, update, stats, items, and jobs operations.
|
|
4239
|
+
*
|
|
4240
|
+
* @example
|
|
4241
|
+
* ```ts
|
|
4242
|
+
* // Via namespace binding
|
|
4243
|
+
* const instance = env.AI_SEARCH.get("blog");
|
|
4244
|
+
* const results = await instance.search({
|
|
4245
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4246
|
+
* });
|
|
4247
|
+
*
|
|
4248
|
+
* // Via single instance binding
|
|
4249
|
+
* const results = await env.BLOG_SEARCH.search({
|
|
4250
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4251
|
+
* });
|
|
4252
|
+
* ```
|
|
4253
|
+
*/
|
|
4254
|
+
export declare abstract class AiSearchInstance {
|
|
4027
4255
|
/**
|
|
4028
4256
|
* Search the AI Search instance for relevant chunks.
|
|
4029
|
-
* @param params Search request with messages and AI search options
|
|
4030
|
-
* @returns Search response with matching chunks
|
|
4257
|
+
* @param params Search request with messages and optional AI search options.
|
|
4258
|
+
* @returns Search response with matching chunks and search query.
|
|
4031
4259
|
*/
|
|
4032
4260
|
search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
|
|
4261
|
+
/**
|
|
4262
|
+
* Generate chat completions with AI Search context (streaming).
|
|
4263
|
+
* @param params Chat completions request with stream: true.
|
|
4264
|
+
* @returns ReadableStream of server-sent events.
|
|
4265
|
+
*/
|
|
4266
|
+
chatCompletions(
|
|
4267
|
+
params: AiSearchChatCompletionsRequest & {
|
|
4268
|
+
stream: true;
|
|
4269
|
+
},
|
|
4270
|
+
): Promise<ReadableStream>;
|
|
4033
4271
|
/**
|
|
4034
4272
|
* Generate chat completions with AI Search context.
|
|
4035
|
-
* @param params Chat completions request
|
|
4036
|
-
* @returns
|
|
4273
|
+
* @param params Chat completions request.
|
|
4274
|
+
* @returns Chat completion response with choices and RAG chunks.
|
|
4037
4275
|
*/
|
|
4038
4276
|
chatCompletions(
|
|
4039
4277
|
params: AiSearchChatCompletionsRequest,
|
|
4040
|
-
): Promise<
|
|
4278
|
+
): Promise<AiSearchChatCompletionsResponse>;
|
|
4041
4279
|
/**
|
|
4042
|
-
*
|
|
4280
|
+
* Update the instance configuration.
|
|
4281
|
+
* @param config Partial configuration to update.
|
|
4282
|
+
* @returns Updated instance info.
|
|
4043
4283
|
*/
|
|
4044
|
-
|
|
4284
|
+
update(config: Partial<AiSearchConfig>): Promise<AiSearchInstanceInfo>;
|
|
4285
|
+
/** Get metadata about this instance. */
|
|
4286
|
+
info(): Promise<AiSearchInstanceInfo>;
|
|
4287
|
+
/**
|
|
4288
|
+
* Get instance statistics (item count, indexing status, etc.).
|
|
4289
|
+
* @returns Statistics with counts per status and last activity time.
|
|
4290
|
+
*/
|
|
4291
|
+
stats(): Promise<AiSearchStatsResponse>;
|
|
4292
|
+
/** Items collection — list, upload, and manage items in this instance. */
|
|
4293
|
+
get items(): AiSearchItems;
|
|
4294
|
+
/** Jobs collection — list, create, and inspect indexing jobs. */
|
|
4295
|
+
get jobs(): AiSearchJobs;
|
|
4045
4296
|
}
|
|
4046
|
-
|
|
4047
|
-
|
|
4297
|
+
/**
|
|
4298
|
+
* Namespace-level AI Search service.
|
|
4299
|
+
*
|
|
4300
|
+
* Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
|
|
4301
|
+
* Scoped to a single namespace. Provides dynamic instance access, creation, and deletion.
|
|
4302
|
+
*
|
|
4303
|
+
* @example
|
|
4304
|
+
* ```ts
|
|
4305
|
+
* // Access an instance within the namespace
|
|
4306
|
+
* const blog = env.AI_SEARCH.get("blog");
|
|
4307
|
+
* const results = await blog.search({
|
|
4308
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4309
|
+
* });
|
|
4310
|
+
*
|
|
4311
|
+
* // List all instances in the namespace
|
|
4312
|
+
* const instances = await env.AI_SEARCH.list();
|
|
4313
|
+
*
|
|
4314
|
+
* // Create a new instance with built-in storage
|
|
4315
|
+
* const tenant = await env.AI_SEARCH.create({
|
|
4316
|
+
* id: "tenant-123",
|
|
4317
|
+
* });
|
|
4318
|
+
*
|
|
4319
|
+
* // Upload items into the instance
|
|
4320
|
+
* await tenant.items.upload("doc.pdf", fileContent);
|
|
4321
|
+
*
|
|
4322
|
+
* // Delete an instance
|
|
4323
|
+
* await env.AI_SEARCH.delete("tenant-123");
|
|
4324
|
+
* ```
|
|
4325
|
+
*/
|
|
4326
|
+
export declare abstract class AiSearchNamespace {
|
|
4048
4327
|
/**
|
|
4049
|
-
*
|
|
4050
|
-
* @
|
|
4328
|
+
* Get an instance by name within the bound namespace.
|
|
4329
|
+
* @param name Instance name.
|
|
4330
|
+
* @returns Instance service for search, chat, update, stats, items, and jobs.
|
|
4331
|
+
*/
|
|
4332
|
+
get(name: string): AiSearchInstance;
|
|
4333
|
+
/**
|
|
4334
|
+
* List all instances in the bound namespace.
|
|
4335
|
+
* @returns Array of instance metadata.
|
|
4051
4336
|
*/
|
|
4052
4337
|
list(): Promise<AiSearchListResponse>;
|
|
4053
4338
|
/**
|
|
4054
|
-
*
|
|
4055
|
-
* @param
|
|
4056
|
-
* @returns Instance service for
|
|
4339
|
+
* Create a new instance within the bound namespace.
|
|
4340
|
+
* @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
|
|
4341
|
+
* @returns Instance service for the newly created instance.
|
|
4342
|
+
*
|
|
4343
|
+
* @example
|
|
4344
|
+
* ```ts
|
|
4345
|
+
* // Create with built-in storage (upload items manually)
|
|
4346
|
+
* const instance = await env.AI_SEARCH.create({ id: "my-search" });
|
|
4347
|
+
*
|
|
4348
|
+
* // Create with web crawler source
|
|
4349
|
+
* const instance = await env.AI_SEARCH.create({
|
|
4350
|
+
* id: "docs-search",
|
|
4351
|
+
* type: "web-crawler",
|
|
4352
|
+
* source: "https://developers.cloudflare.com",
|
|
4353
|
+
* });
|
|
4354
|
+
* ```
|
|
4057
4355
|
*/
|
|
4058
|
-
|
|
4356
|
+
create(config: AiSearchConfig): Promise<AiSearchInstance>;
|
|
4059
4357
|
/**
|
|
4060
|
-
*
|
|
4061
|
-
* @param
|
|
4062
|
-
* @returns Instance service for performing operations
|
|
4358
|
+
* Delete an instance from the bound namespace.
|
|
4359
|
+
* @param name Instance name to delete.
|
|
4063
4360
|
*/
|
|
4064
|
-
|
|
4361
|
+
delete(name: string): Promise<void>;
|
|
4065
4362
|
}
|
|
4066
4363
|
export type AiImageClassificationInput = {
|
|
4067
4364
|
image: number[];
|
|
@@ -10062,6 +10359,7 @@ export type AiOptions = {
|
|
|
10062
10359
|
returnRawResponse?: boolean;
|
|
10063
10360
|
prefix?: string;
|
|
10064
10361
|
extraHeaders?: object;
|
|
10362
|
+
signal?: AbortSignal;
|
|
10065
10363
|
};
|
|
10066
10364
|
export type AiModelsSearchParams = {
|
|
10067
10365
|
author?: string;
|
|
@@ -10107,46 +10405,16 @@ export declare abstract class Ai<
|
|
|
10107
10405
|
aiGatewayLogId: string | null;
|
|
10108
10406
|
gateway(gatewayId: string): AiGateway;
|
|
10109
10407
|
/**
|
|
10110
|
-
*
|
|
10111
|
-
*
|
|
10112
|
-
* This is the new API that replaces AutoRAG with better namespace separation:
|
|
10113
|
-
* - Account-level operations: `list()`, `create()`
|
|
10114
|
-
* - Instance-level operations: `get(id).search()`, `get(id).chatCompletions()`, `get(id).delete()`
|
|
10115
|
-
*
|
|
10116
|
-
* @example
|
|
10117
|
-
* ```typescript
|
|
10118
|
-
* // List all AI Search instances
|
|
10119
|
-
* const instances = await env.AI.aiSearch.list();
|
|
10120
|
-
*
|
|
10121
|
-
* // Search an instance
|
|
10122
|
-
* const results = await env.AI.aiSearch.get('my-search').search({
|
|
10123
|
-
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
10124
|
-
* ai_search_options: {
|
|
10125
|
-
* retrieval: { max_num_results: 10 }
|
|
10126
|
-
* }
|
|
10127
|
-
* });
|
|
10128
|
-
*
|
|
10129
|
-
* // Generate chat completions with AI Search context
|
|
10130
|
-
* const response = await env.AI.aiSearch.get('my-search').chatCompletions({
|
|
10131
|
-
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
10132
|
-
* model: '@cf/meta/llama-3.3-70b-instruct-fp8-fast'
|
|
10133
|
-
* });
|
|
10134
|
-
* ```
|
|
10408
|
+
* @deprecated Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
10409
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10135
10410
|
*/
|
|
10136
|
-
aiSearch():
|
|
10411
|
+
aiSearch(): AiSearchNamespace;
|
|
10137
10412
|
/**
|
|
10138
10413
|
* @deprecated AutoRAG has been replaced by AI Search.
|
|
10139
|
-
* Use `
|
|
10140
|
-
*
|
|
10141
|
-
* Migration guide:
|
|
10142
|
-
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
10143
|
-
* - `env.AI.autorag('id').search({ query: '...' })` → `env.AI.aiSearch.get('id').search({ messages: [{ role: 'user', content: '...' }] })`
|
|
10144
|
-
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
10414
|
+
* Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
10415
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10145
10416
|
*
|
|
10146
|
-
*
|
|
10147
|
-
*
|
|
10148
|
-
* @see AiSearchAccountService
|
|
10149
|
-
* @param autoragId Optional instance ID (omit for account-level operations)
|
|
10417
|
+
* @param autoragId Instance ID
|
|
10150
10418
|
*/
|
|
10151
10419
|
autorag(autoragId: string): AutoRAG;
|
|
10152
10420
|
run<
|
|
@@ -10305,22 +10573,23 @@ export declare abstract class AiGateway {
|
|
|
10305
10573
|
getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
|
|
10306
10574
|
}
|
|
10307
10575
|
/**
|
|
10308
|
-
* @deprecated
|
|
10309
|
-
*
|
|
10576
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10577
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10310
10578
|
*/
|
|
10311
10579
|
export interface AutoRAGInternalError extends Error {}
|
|
10312
10580
|
/**
|
|
10313
|
-
* @deprecated
|
|
10314
|
-
*
|
|
10581
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10582
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10315
10583
|
*/
|
|
10316
10584
|
export interface AutoRAGNotFoundError extends Error {}
|
|
10317
10585
|
/**
|
|
10318
|
-
* @deprecated
|
|
10586
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10587
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10319
10588
|
*/
|
|
10320
10589
|
export interface AutoRAGUnauthorizedError extends Error {}
|
|
10321
10590
|
/**
|
|
10322
|
-
* @deprecated
|
|
10323
|
-
*
|
|
10591
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10592
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10324
10593
|
*/
|
|
10325
10594
|
export interface AutoRAGNameNotSetError extends Error {}
|
|
10326
10595
|
export type ComparisonFilter = {
|
|
@@ -10333,9 +10602,8 @@ export type CompoundFilter = {
|
|
|
10333
10602
|
filters: ComparisonFilter[];
|
|
10334
10603
|
};
|
|
10335
10604
|
/**
|
|
10336
|
-
* @deprecated
|
|
10337
|
-
*
|
|
10338
|
-
* @see AiSearchSearchRequest
|
|
10605
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10606
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10339
10607
|
*/
|
|
10340
10608
|
export type AutoRagSearchRequest = {
|
|
10341
10609
|
query: string;
|
|
@@ -10352,18 +10620,16 @@ export type AutoRagSearchRequest = {
|
|
|
10352
10620
|
rewrite_query?: boolean;
|
|
10353
10621
|
};
|
|
10354
10622
|
/**
|
|
10355
|
-
* @deprecated
|
|
10356
|
-
*
|
|
10357
|
-
* @see AiSearchChatCompletionsRequest
|
|
10623
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10624
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10358
10625
|
*/
|
|
10359
10626
|
export type AutoRagAiSearchRequest = AutoRagSearchRequest & {
|
|
10360
10627
|
stream?: boolean;
|
|
10361
10628
|
system_prompt?: string;
|
|
10362
10629
|
};
|
|
10363
10630
|
/**
|
|
10364
|
-
* @deprecated
|
|
10365
|
-
*
|
|
10366
|
-
* @see AiSearchChatCompletionsRequest
|
|
10631
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10632
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10367
10633
|
*/
|
|
10368
10634
|
export type AutoRagAiSearchRequestStreaming = Omit<
|
|
10369
10635
|
AutoRagAiSearchRequest,
|
|
@@ -10372,9 +10638,8 @@ export type AutoRagAiSearchRequestStreaming = Omit<
|
|
|
10372
10638
|
stream: true;
|
|
10373
10639
|
};
|
|
10374
10640
|
/**
|
|
10375
|
-
* @deprecated
|
|
10376
|
-
*
|
|
10377
|
-
* @see AiSearchSearchResponse
|
|
10641
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10642
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10378
10643
|
*/
|
|
10379
10644
|
export type AutoRagSearchResponse = {
|
|
10380
10645
|
object: "vector_store.search_results.page";
|
|
@@ -10393,9 +10658,8 @@ export type AutoRagSearchResponse = {
|
|
|
10393
10658
|
next_page: string | null;
|
|
10394
10659
|
};
|
|
10395
10660
|
/**
|
|
10396
|
-
* @deprecated
|
|
10397
|
-
*
|
|
10398
|
-
* @see AiSearchListResponse
|
|
10661
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10662
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10399
10663
|
*/
|
|
10400
10664
|
export type AutoRagListResponse = {
|
|
10401
10665
|
id: string;
|
|
@@ -10407,49 +10671,40 @@ export type AutoRagListResponse = {
|
|
|
10407
10671
|
status: string;
|
|
10408
10672
|
}[];
|
|
10409
10673
|
/**
|
|
10410
|
-
* @deprecated
|
|
10411
|
-
*
|
|
10674
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10675
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10412
10676
|
*/
|
|
10413
10677
|
export type AutoRagAiSearchResponse = AutoRagSearchResponse & {
|
|
10414
10678
|
response: string;
|
|
10415
10679
|
};
|
|
10416
10680
|
/**
|
|
10417
|
-
* @deprecated
|
|
10418
|
-
*
|
|
10419
|
-
*
|
|
10420
|
-
* Migration guide:
|
|
10421
|
-
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
10422
|
-
* - `env.AI.autorag('id').search(...)` → `env.AI.aiSearch.get('id').search(...)`
|
|
10423
|
-
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
10424
|
-
*
|
|
10425
|
-
* @see AiSearchAccountService
|
|
10426
|
-
* @see AiSearchInstanceService
|
|
10681
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10682
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10427
10683
|
*/
|
|
10428
10684
|
export declare abstract class AutoRAG {
|
|
10429
10685
|
/**
|
|
10430
|
-
* @deprecated Use
|
|
10431
|
-
*
|
|
10686
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10687
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10432
10688
|
*/
|
|
10433
10689
|
list(): Promise<AutoRagListResponse>;
|
|
10434
10690
|
/**
|
|
10435
|
-
* @deprecated Use
|
|
10436
|
-
*
|
|
10437
|
-
* @see AiSearchInstanceService.search
|
|
10691
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10692
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10438
10693
|
*/
|
|
10439
10694
|
search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;
|
|
10440
10695
|
/**
|
|
10441
|
-
* @deprecated Use
|
|
10442
|
-
*
|
|
10696
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10697
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10443
10698
|
*/
|
|
10444
10699
|
aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;
|
|
10445
10700
|
/**
|
|
10446
|
-
* @deprecated Use
|
|
10447
|
-
*
|
|
10701
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10702
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10448
10703
|
*/
|
|
10449
10704
|
aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;
|
|
10450
10705
|
/**
|
|
10451
|
-
* @deprecated Use
|
|
10452
|
-
*
|
|
10706
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10707
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10453
10708
|
*/
|
|
10454
10709
|
aiSearch(
|
|
10455
10710
|
params: AutoRagAiSearchRequest,
|