@workers-community/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/index.d.ts +379 -124
- package/index.ts +379 -124
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -3103,6 +3103,11 @@ interface QueuingStrategyInit {
|
|
|
3103
3103
|
*/
|
|
3104
3104
|
highWaterMark: number;
|
|
3105
3105
|
}
|
|
3106
|
+
interface TracePreviewInfo {
|
|
3107
|
+
id: string;
|
|
3108
|
+
slug: string;
|
|
3109
|
+
name: string;
|
|
3110
|
+
}
|
|
3106
3111
|
interface ScriptVersion {
|
|
3107
3112
|
id?: string;
|
|
3108
3113
|
tag?: string;
|
|
@@ -3137,6 +3142,7 @@ 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 @@ declare abstract class Performance {
|
|
|
3895
3901
|
*/
|
|
3896
3902
|
toJSON(): object;
|
|
3897
3903
|
}
|
|
3898
|
-
// AI Search
|
|
3904
|
+
// ============ AI Search Error Interfaces ============
|
|
3899
3905
|
interface AiSearchInternalError extends Error {}
|
|
3900
3906
|
interface AiSearchNotFoundError extends Error {}
|
|
3901
|
-
|
|
3902
|
-
// AI Search V2 Request Types
|
|
3907
|
+
// ============ AI Search Request Types ============
|
|
3903
3908
|
type AiSearchSearchRequest = {
|
|
3904
3909
|
messages: Array<{
|
|
3905
3910
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
@@ -3924,9 +3929,8 @@ 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 @@ 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 @@ 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 @@ type AiSearchChatCompletionsRequest = {
|
|
|
3966
3971
|
};
|
|
3967
3972
|
[key: string]: unknown;
|
|
3968
3973
|
};
|
|
3969
|
-
// AI Search
|
|
3974
|
+
// ============ AI Search Response Types ============
|
|
3970
3975
|
type AiSearchSearchResponse = {
|
|
3971
3976
|
search_query: string;
|
|
3972
3977
|
chunks: Array<{
|
|
@@ -3985,26 +3990,65 @@ 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
|
+
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
|
-
type
|
|
4013
|
+
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
|
+
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
|
+
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
|
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 @@ 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
|
+
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
|
+
type AiSearchItemContentResult = {
|
|
4078
|
+
body: ReadableStream;
|
|
4079
|
+
contentType: string;
|
|
4080
|
+
filename: string;
|
|
4081
|
+
size: number;
|
|
4082
|
+
};
|
|
4083
|
+
type AiSearchUploadItemOptions = {
|
|
4084
|
+
metadata?: Record<string, unknown>;
|
|
4085
|
+
};
|
|
4086
|
+
type AiSearchListItemsParams = {
|
|
4087
|
+
page?: number;
|
|
4088
|
+
per_page?: number;
|
|
4089
|
+
};
|
|
4090
|
+
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
|
+
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
|
+
type AiSearchJobLog = {
|
|
4110
|
+
id: number;
|
|
4111
|
+
message: string;
|
|
4112
|
+
message_type: number;
|
|
4113
|
+
created_at: number;
|
|
4114
|
+
};
|
|
4115
|
+
type AiSearchCreateJobParams = {
|
|
4116
|
+
description?: string;
|
|
4117
|
+
};
|
|
4118
|
+
type AiSearchListJobsParams = {
|
|
4119
|
+
page?: number;
|
|
4120
|
+
per_page?: number;
|
|
4121
|
+
};
|
|
4122
|
+
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
|
+
type AiSearchJobLogsParams = {
|
|
4132
|
+
page?: number;
|
|
4133
|
+
per_page?: number;
|
|
4134
|
+
};
|
|
4135
|
+
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
|
+
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
|
+
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
|
+
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
|
+
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
|
+
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
|
+
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
|
type AiImageClassificationInput = {
|
|
4067
4364
|
image: number[];
|
|
@@ -10059,6 +10356,7 @@ type AiOptions = {
|
|
|
10059
10356
|
returnRawResponse?: boolean;
|
|
10060
10357
|
prefix?: string;
|
|
10061
10358
|
extraHeaders?: object;
|
|
10359
|
+
signal?: AbortSignal;
|
|
10062
10360
|
};
|
|
10063
10361
|
type AiModelsSearchParams = {
|
|
10064
10362
|
author?: string;
|
|
@@ -10102,46 +10400,16 @@ declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
|
|
|
10102
10400
|
aiGatewayLogId: string | null;
|
|
10103
10401
|
gateway(gatewayId: string): AiGateway;
|
|
10104
10402
|
/**
|
|
10105
|
-
*
|
|
10106
|
-
*
|
|
10107
|
-
* This is the new API that replaces AutoRAG with better namespace separation:
|
|
10108
|
-
* - Account-level operations: `list()`, `create()`
|
|
10109
|
-
* - Instance-level operations: `get(id).search()`, `get(id).chatCompletions()`, `get(id).delete()`
|
|
10110
|
-
*
|
|
10111
|
-
* @example
|
|
10112
|
-
* ```typescript
|
|
10113
|
-
* // List all AI Search instances
|
|
10114
|
-
* const instances = await env.AI.aiSearch.list();
|
|
10115
|
-
*
|
|
10116
|
-
* // Search an instance
|
|
10117
|
-
* const results = await env.AI.aiSearch.get('my-search').search({
|
|
10118
|
-
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
10119
|
-
* ai_search_options: {
|
|
10120
|
-
* retrieval: { max_num_results: 10 }
|
|
10121
|
-
* }
|
|
10122
|
-
* });
|
|
10123
|
-
*
|
|
10124
|
-
* // Generate chat completions with AI Search context
|
|
10125
|
-
* const response = await env.AI.aiSearch.get('my-search').chatCompletions({
|
|
10126
|
-
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
10127
|
-
* model: '@cf/meta/llama-3.3-70b-instruct-fp8-fast'
|
|
10128
|
-
* });
|
|
10129
|
-
* ```
|
|
10403
|
+
* @deprecated Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
10404
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10130
10405
|
*/
|
|
10131
|
-
aiSearch():
|
|
10406
|
+
aiSearch(): AiSearchNamespace;
|
|
10132
10407
|
/**
|
|
10133
10408
|
* @deprecated AutoRAG has been replaced by AI Search.
|
|
10134
|
-
* Use `
|
|
10135
|
-
*
|
|
10136
|
-
* Migration guide:
|
|
10137
|
-
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
10138
|
-
* - `env.AI.autorag('id').search({ query: '...' })` → `env.AI.aiSearch.get('id').search({ messages: [{ role: 'user', content: '...' }] })`
|
|
10139
|
-
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
10409
|
+
* Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
10410
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10140
10411
|
*
|
|
10141
|
-
*
|
|
10142
|
-
*
|
|
10143
|
-
* @see AiSearchAccountService
|
|
10144
|
-
* @param autoragId Optional instance ID (omit for account-level operations)
|
|
10412
|
+
* @param autoragId Instance ID
|
|
10145
10413
|
*/
|
|
10146
10414
|
autorag(autoragId: string): AutoRAG;
|
|
10147
10415
|
run<
|
|
@@ -10300,22 +10568,23 @@ declare abstract class AiGateway {
|
|
|
10300
10568
|
getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
|
|
10301
10569
|
}
|
|
10302
10570
|
/**
|
|
10303
|
-
* @deprecated
|
|
10304
|
-
*
|
|
10571
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10572
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10305
10573
|
*/
|
|
10306
10574
|
interface AutoRAGInternalError extends Error {}
|
|
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
|
interface AutoRAGNotFoundError extends Error {}
|
|
10312
10580
|
/**
|
|
10313
|
-
* @deprecated
|
|
10581
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10582
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10314
10583
|
*/
|
|
10315
10584
|
interface AutoRAGUnauthorizedError extends Error {}
|
|
10316
10585
|
/**
|
|
10317
|
-
* @deprecated
|
|
10318
|
-
*
|
|
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
|
interface AutoRAGNameNotSetError extends Error {}
|
|
10321
10590
|
type ComparisonFilter = {
|
|
@@ -10328,9 +10597,8 @@ type CompoundFilter = {
|
|
|
10328
10597
|
filters: ComparisonFilter[];
|
|
10329
10598
|
};
|
|
10330
10599
|
/**
|
|
10331
|
-
* @deprecated
|
|
10332
|
-
*
|
|
10333
|
-
* @see AiSearchSearchRequest
|
|
10600
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10601
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10334
10602
|
*/
|
|
10335
10603
|
type AutoRagSearchRequest = {
|
|
10336
10604
|
query: string;
|
|
@@ -10347,18 +10615,16 @@ type AutoRagSearchRequest = {
|
|
|
10347
10615
|
rewrite_query?: boolean;
|
|
10348
10616
|
};
|
|
10349
10617
|
/**
|
|
10350
|
-
* @deprecated
|
|
10351
|
-
*
|
|
10352
|
-
* @see AiSearchChatCompletionsRequest
|
|
10618
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10619
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10353
10620
|
*/
|
|
10354
10621
|
type AutoRagAiSearchRequest = AutoRagSearchRequest & {
|
|
10355
10622
|
stream?: boolean;
|
|
10356
10623
|
system_prompt?: string;
|
|
10357
10624
|
};
|
|
10358
10625
|
/**
|
|
10359
|
-
* @deprecated
|
|
10360
|
-
*
|
|
10361
|
-
* @see AiSearchChatCompletionsRequest
|
|
10626
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10627
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10362
10628
|
*/
|
|
10363
10629
|
type AutoRagAiSearchRequestStreaming = Omit<
|
|
10364
10630
|
AutoRagAiSearchRequest,
|
|
@@ -10367,9 +10633,8 @@ type AutoRagAiSearchRequestStreaming = Omit<
|
|
|
10367
10633
|
stream: true;
|
|
10368
10634
|
};
|
|
10369
10635
|
/**
|
|
10370
|
-
* @deprecated
|
|
10371
|
-
*
|
|
10372
|
-
* @see AiSearchSearchResponse
|
|
10636
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10637
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10373
10638
|
*/
|
|
10374
10639
|
type AutoRagSearchResponse = {
|
|
10375
10640
|
object: "vector_store.search_results.page";
|
|
@@ -10388,9 +10653,8 @@ type AutoRagSearchResponse = {
|
|
|
10388
10653
|
next_page: string | null;
|
|
10389
10654
|
};
|
|
10390
10655
|
/**
|
|
10391
|
-
* @deprecated
|
|
10392
|
-
*
|
|
10393
|
-
* @see AiSearchListResponse
|
|
10656
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10657
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10394
10658
|
*/
|
|
10395
10659
|
type AutoRagListResponse = {
|
|
10396
10660
|
id: string;
|
|
@@ -10402,49 +10666,40 @@ type AutoRagListResponse = {
|
|
|
10402
10666
|
status: string;
|
|
10403
10667
|
}[];
|
|
10404
10668
|
/**
|
|
10405
|
-
* @deprecated
|
|
10406
|
-
*
|
|
10669
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10670
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10407
10671
|
*/
|
|
10408
10672
|
type AutoRagAiSearchResponse = AutoRagSearchResponse & {
|
|
10409
10673
|
response: string;
|
|
10410
10674
|
};
|
|
10411
10675
|
/**
|
|
10412
|
-
* @deprecated
|
|
10413
|
-
*
|
|
10414
|
-
*
|
|
10415
|
-
* Migration guide:
|
|
10416
|
-
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
10417
|
-
* - `env.AI.autorag('id').search(...)` → `env.AI.aiSearch.get('id').search(...)`
|
|
10418
|
-
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
10419
|
-
*
|
|
10420
|
-
* @see AiSearchAccountService
|
|
10421
|
-
* @see AiSearchInstanceService
|
|
10676
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10677
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10422
10678
|
*/
|
|
10423
10679
|
declare abstract class AutoRAG {
|
|
10424
10680
|
/**
|
|
10425
|
-
* @deprecated Use
|
|
10426
|
-
*
|
|
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
|
list(): Promise<AutoRagListResponse>;
|
|
10429
10685
|
/**
|
|
10430
|
-
* @deprecated Use
|
|
10431
|
-
*
|
|
10432
|
-
* @see AiSearchInstanceService.search
|
|
10686
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10687
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10433
10688
|
*/
|
|
10434
10689
|
search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;
|
|
10435
10690
|
/**
|
|
10436
|
-
* @deprecated Use
|
|
10437
|
-
*
|
|
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
|
aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;
|
|
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: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;
|
|
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(
|
|
10450
10705
|
params: AutoRagAiSearchRequest,
|