@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-10-31/index.ts
CHANGED
|
@@ -3098,6 +3098,11 @@ export interface QueuingStrategyInit {
|
|
|
3098
3098
|
*/
|
|
3099
3099
|
highWaterMark: number;
|
|
3100
3100
|
}
|
|
3101
|
+
export interface TracePreviewInfo {
|
|
3102
|
+
id: string;
|
|
3103
|
+
slug: string;
|
|
3104
|
+
name: string;
|
|
3105
|
+
}
|
|
3101
3106
|
export interface ScriptVersion {
|
|
3102
3107
|
id?: string;
|
|
3103
3108
|
tag?: string;
|
|
@@ -3132,6 +3137,7 @@ export interface TraceItem {
|
|
|
3132
3137
|
readonly dispatchNamespace?: string;
|
|
3133
3138
|
readonly scriptTags?: string[];
|
|
3134
3139
|
readonly tailAttributes?: Record<string, boolean | number | string>;
|
|
3140
|
+
readonly preview?: TracePreviewInfo;
|
|
3135
3141
|
readonly durableObjectId?: string;
|
|
3136
3142
|
readonly outcome: string;
|
|
3137
3143
|
readonly executionModel: string;
|
|
@@ -3890,11 +3896,10 @@ export declare abstract class Performance {
|
|
|
3890
3896
|
*/
|
|
3891
3897
|
toJSON(): object;
|
|
3892
3898
|
}
|
|
3893
|
-
// AI Search
|
|
3899
|
+
// ============ AI Search Error Interfaces ============
|
|
3894
3900
|
export interface AiSearchInternalError extends Error {}
|
|
3895
3901
|
export interface AiSearchNotFoundError extends Error {}
|
|
3896
|
-
|
|
3897
|
-
// AI Search V2 Request Types
|
|
3902
|
+
// ============ AI Search Request Types ============
|
|
3898
3903
|
export type AiSearchSearchRequest = {
|
|
3899
3904
|
messages: Array<{
|
|
3900
3905
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
@@ -3919,9 +3924,8 @@ export type AiSearchSearchRequest = {
|
|
|
3919
3924
|
[key: string]: unknown;
|
|
3920
3925
|
};
|
|
3921
3926
|
reranking?: {
|
|
3922
|
-
/** Enable reranking (default false) */
|
|
3923
3927
|
enabled?: boolean;
|
|
3924
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
3928
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
3925
3929
|
/** Match threshold (0-1, default 0.4) */
|
|
3926
3930
|
match_threshold?: number;
|
|
3927
3931
|
[key: string]: unknown;
|
|
@@ -3933,6 +3937,7 @@ export type AiSearchChatCompletionsRequest = {
|
|
|
3933
3937
|
messages: Array<{
|
|
3934
3938
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
3935
3939
|
content: string | null;
|
|
3940
|
+
[key: string]: unknown;
|
|
3936
3941
|
}>;
|
|
3937
3942
|
model?: string;
|
|
3938
3943
|
stream?: boolean;
|
|
@@ -3953,7 +3958,7 @@ export type AiSearchChatCompletionsRequest = {
|
|
|
3953
3958
|
};
|
|
3954
3959
|
reranking?: {
|
|
3955
3960
|
enabled?: boolean;
|
|
3956
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
3961
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
3957
3962
|
match_threshold?: number;
|
|
3958
3963
|
[key: string]: unknown;
|
|
3959
3964
|
};
|
|
@@ -3961,7 +3966,7 @@ export type AiSearchChatCompletionsRequest = {
|
|
|
3961
3966
|
};
|
|
3962
3967
|
[key: string]: unknown;
|
|
3963
3968
|
};
|
|
3964
|
-
// AI Search
|
|
3969
|
+
// ============ AI Search Response Types ============
|
|
3965
3970
|
export type AiSearchSearchResponse = {
|
|
3966
3971
|
search_query: string;
|
|
3967
3972
|
chunks: Array<{
|
|
@@ -3980,26 +3985,65 @@ export type AiSearchSearchResponse = {
|
|
|
3980
3985
|
keyword_score?: number;
|
|
3981
3986
|
/** Vector similarity score (0-1) */
|
|
3982
3987
|
vector_score?: number;
|
|
3988
|
+
[key: string]: unknown;
|
|
3989
|
+
};
|
|
3990
|
+
}>;
|
|
3991
|
+
};
|
|
3992
|
+
export type AiSearchChatCompletionsResponse = {
|
|
3993
|
+
id?: string;
|
|
3994
|
+
object?: string;
|
|
3995
|
+
model?: string;
|
|
3996
|
+
choices: Array<{
|
|
3997
|
+
index?: number;
|
|
3998
|
+
message: {
|
|
3999
|
+
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
4000
|
+
content: string | null;
|
|
4001
|
+
[key: string]: unknown;
|
|
3983
4002
|
};
|
|
4003
|
+
[key: string]: unknown;
|
|
3984
4004
|
}>;
|
|
4005
|
+
chunks: AiSearchSearchResponse["chunks"];
|
|
4006
|
+
[key: string]: unknown;
|
|
3985
4007
|
};
|
|
3986
|
-
export type
|
|
4008
|
+
export type AiSearchStatsResponse = {
|
|
4009
|
+
queued?: number;
|
|
4010
|
+
running?: number;
|
|
4011
|
+
completed?: number;
|
|
4012
|
+
error?: number;
|
|
4013
|
+
skipped?: number;
|
|
4014
|
+
outdated?: number;
|
|
4015
|
+
last_activity?: string;
|
|
4016
|
+
};
|
|
4017
|
+
// ============ AI Search Instance Info Types ============
|
|
4018
|
+
export type AiSearchInstanceInfo = {
|
|
3987
4019
|
id: string;
|
|
3988
|
-
|
|
3989
|
-
account_id?: string;
|
|
3990
|
-
account_tag?: string;
|
|
3991
|
-
/** Whether the instance is enabled (default true) */
|
|
3992
|
-
enable?: boolean;
|
|
3993
|
-
type?: "r2" | "web-crawler";
|
|
4020
|
+
type?: "r2" | "web-crawler" | string;
|
|
3994
4021
|
source?: string;
|
|
4022
|
+
paused?: boolean;
|
|
4023
|
+
status?: string;
|
|
4024
|
+
namespace?: string;
|
|
4025
|
+
created_at?: string;
|
|
4026
|
+
modified_at?: string;
|
|
3995
4027
|
[key: string]: unknown;
|
|
3996
|
-
}
|
|
4028
|
+
};
|
|
4029
|
+
export type AiSearchListResponse = {
|
|
4030
|
+
result: AiSearchInstanceInfo[];
|
|
4031
|
+
result_info?: {
|
|
4032
|
+
count: number;
|
|
4033
|
+
page: number;
|
|
4034
|
+
per_page: number;
|
|
4035
|
+
total_count: number;
|
|
4036
|
+
};
|
|
4037
|
+
};
|
|
4038
|
+
// ============ AI Search Config Types ============
|
|
3997
4039
|
export type AiSearchConfig = {
|
|
3998
4040
|
/** Instance ID (1-32 chars, pattern: ^[a-z0-9_]+(?:-[a-z0-9_]+)*$) */
|
|
3999
4041
|
id: string;
|
|
4000
|
-
type
|
|
4001
|
-
|
|
4002
|
-
|
|
4042
|
+
/** Instance type. Omit to create with built-in storage. */
|
|
4043
|
+
type?: "r2" | "web-crawler" | string;
|
|
4044
|
+
/** Source URL (required for web-crawler type). */
|
|
4045
|
+
source?: string;
|
|
4046
|
+
source_params?: unknown;
|
|
4003
4047
|
/** Token ID (UUID format) */
|
|
4004
4048
|
token_id?: string;
|
|
4005
4049
|
ai_gateway_id?: string;
|
|
@@ -4009,54 +4053,307 @@ export type AiSearchConfig = {
|
|
|
4009
4053
|
reranking?: boolean;
|
|
4010
4054
|
embedding_model?: string;
|
|
4011
4055
|
ai_search_model?: string;
|
|
4056
|
+
[key: string]: unknown;
|
|
4012
4057
|
};
|
|
4013
|
-
|
|
4058
|
+
// ============ AI Search Item Types ============
|
|
4059
|
+
export type AiSearchItemInfo = {
|
|
4014
4060
|
id: string;
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4061
|
+
key: string;
|
|
4062
|
+
status:
|
|
4063
|
+
| "completed"
|
|
4064
|
+
| "error"
|
|
4065
|
+
| "skipped"
|
|
4066
|
+
| "queued"
|
|
4067
|
+
| "processing"
|
|
4068
|
+
| "outdated";
|
|
4069
|
+
metadata?: Record<string, unknown>;
|
|
4018
4070
|
[key: string]: unknown;
|
|
4019
4071
|
};
|
|
4020
|
-
|
|
4021
|
-
|
|
4072
|
+
export type AiSearchItemContentResult = {
|
|
4073
|
+
body: ReadableStream;
|
|
4074
|
+
contentType: string;
|
|
4075
|
+
filename: string;
|
|
4076
|
+
size: number;
|
|
4077
|
+
};
|
|
4078
|
+
export type AiSearchUploadItemOptions = {
|
|
4079
|
+
metadata?: Record<string, unknown>;
|
|
4080
|
+
};
|
|
4081
|
+
export type AiSearchListItemsParams = {
|
|
4082
|
+
page?: number;
|
|
4083
|
+
per_page?: number;
|
|
4084
|
+
};
|
|
4085
|
+
export type AiSearchListItemsResponse = {
|
|
4086
|
+
result: AiSearchItemInfo[];
|
|
4087
|
+
result_info?: {
|
|
4088
|
+
count: number;
|
|
4089
|
+
page: number;
|
|
4090
|
+
per_page: number;
|
|
4091
|
+
total_count: number;
|
|
4092
|
+
};
|
|
4093
|
+
};
|
|
4094
|
+
// ============ AI Search Job Types ============
|
|
4095
|
+
export type AiSearchJobInfo = {
|
|
4096
|
+
id: string;
|
|
4097
|
+
source: "user" | "schedule";
|
|
4098
|
+
description?: string;
|
|
4099
|
+
last_seen_at?: string;
|
|
4100
|
+
started_at?: string;
|
|
4101
|
+
ended_at?: string;
|
|
4102
|
+
end_reason?: string;
|
|
4103
|
+
};
|
|
4104
|
+
export type AiSearchJobLog = {
|
|
4105
|
+
id: number;
|
|
4106
|
+
message: string;
|
|
4107
|
+
message_type: number;
|
|
4108
|
+
created_at: number;
|
|
4109
|
+
};
|
|
4110
|
+
export type AiSearchCreateJobParams = {
|
|
4111
|
+
description?: string;
|
|
4112
|
+
};
|
|
4113
|
+
export type AiSearchListJobsParams = {
|
|
4114
|
+
page?: number;
|
|
4115
|
+
per_page?: number;
|
|
4116
|
+
};
|
|
4117
|
+
export type AiSearchListJobsResponse = {
|
|
4118
|
+
result: AiSearchJobInfo[];
|
|
4119
|
+
result_info?: {
|
|
4120
|
+
count: number;
|
|
4121
|
+
page: number;
|
|
4122
|
+
per_page: number;
|
|
4123
|
+
total_count: number;
|
|
4124
|
+
};
|
|
4125
|
+
};
|
|
4126
|
+
export type AiSearchJobLogsParams = {
|
|
4127
|
+
page?: number;
|
|
4128
|
+
per_page?: number;
|
|
4129
|
+
};
|
|
4130
|
+
export type AiSearchJobLogsResponse = {
|
|
4131
|
+
result: AiSearchJobLog[];
|
|
4132
|
+
result_info?: {
|
|
4133
|
+
count: number;
|
|
4134
|
+
page: number;
|
|
4135
|
+
per_page: number;
|
|
4136
|
+
total_count: number;
|
|
4137
|
+
};
|
|
4138
|
+
};
|
|
4139
|
+
// ============ AI Search Sub-Service Classes ============
|
|
4140
|
+
/**
|
|
4141
|
+
* Single item service for an AI Search instance.
|
|
4142
|
+
* Provides info, delete, and download operations on a specific item.
|
|
4143
|
+
*/
|
|
4144
|
+
export declare abstract class AiSearchItem {
|
|
4145
|
+
/** Get metadata about this item. */
|
|
4146
|
+
info(): Promise<AiSearchItemInfo>;
|
|
4147
|
+
/**
|
|
4148
|
+
* Download the item's content.
|
|
4149
|
+
* @returns Object with body stream, content type, filename, and size.
|
|
4150
|
+
*/
|
|
4151
|
+
download(): Promise<AiSearchItemContentResult>;
|
|
4152
|
+
}
|
|
4153
|
+
/**
|
|
4154
|
+
* Items collection service for an AI Search instance.
|
|
4155
|
+
* Provides list, upload, and access to individual items.
|
|
4156
|
+
*/
|
|
4157
|
+
export declare abstract class AiSearchItems {
|
|
4158
|
+
/** List items in this instance. */
|
|
4159
|
+
list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
|
|
4160
|
+
/**
|
|
4161
|
+
* Upload a file as an item.
|
|
4162
|
+
* @param name Filename for the uploaded item.
|
|
4163
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4164
|
+
* @param options Optional metadata to attach to the item.
|
|
4165
|
+
* @returns The created item info.
|
|
4166
|
+
*/
|
|
4167
|
+
upload(
|
|
4168
|
+
name: string,
|
|
4169
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4170
|
+
options?: AiSearchUploadItemOptions,
|
|
4171
|
+
): Promise<AiSearchItemInfo>;
|
|
4172
|
+
/**
|
|
4173
|
+
* Upload a file and poll until processing completes.
|
|
4174
|
+
* @param name Filename for the uploaded item.
|
|
4175
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4176
|
+
* @param options Optional metadata to attach to the item.
|
|
4177
|
+
* @returns The item info after processing completes (or timeout).
|
|
4178
|
+
*/
|
|
4179
|
+
uploadAndPoll(
|
|
4180
|
+
name: string,
|
|
4181
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4182
|
+
options?: AiSearchUploadItemOptions,
|
|
4183
|
+
): Promise<AiSearchItemInfo>;
|
|
4184
|
+
/**
|
|
4185
|
+
* Get an item by ID.
|
|
4186
|
+
* @param itemId The item identifier.
|
|
4187
|
+
* @returns Item service for info, delete, and download operations.
|
|
4188
|
+
*/
|
|
4189
|
+
get(itemId: string): AiSearchItem;
|
|
4190
|
+
/** Delete this item from the instance.
|
|
4191
|
+
* @param itemId The item identifier.
|
|
4192
|
+
*/
|
|
4193
|
+
delete(itemId: string): Promise<void>;
|
|
4194
|
+
}
|
|
4195
|
+
/**
|
|
4196
|
+
* Single job service for an AI Search instance.
|
|
4197
|
+
* Provides info and logs for a specific job.
|
|
4198
|
+
*/
|
|
4199
|
+
export declare abstract class AiSearchJob {
|
|
4200
|
+
/** Get metadata about this job. */
|
|
4201
|
+
info(): Promise<AiSearchJobInfo>;
|
|
4202
|
+
/** Get logs for this job. */
|
|
4203
|
+
logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
|
|
4204
|
+
}
|
|
4205
|
+
/**
|
|
4206
|
+
* Jobs collection service for an AI Search instance.
|
|
4207
|
+
* Provides list, create, and access to individual jobs.
|
|
4208
|
+
*/
|
|
4209
|
+
export declare abstract class AiSearchJobs {
|
|
4210
|
+
/** List jobs for this instance. */
|
|
4211
|
+
list(params?: AiSearchListJobsParams): Promise<AiSearchListJobsResponse>;
|
|
4212
|
+
/**
|
|
4213
|
+
* Create a new indexing job.
|
|
4214
|
+
* @param params Optional job parameters.
|
|
4215
|
+
* @returns The created job info.
|
|
4216
|
+
*/
|
|
4217
|
+
create(params?: AiSearchCreateJobParams): Promise<AiSearchJobInfo>;
|
|
4218
|
+
/**
|
|
4219
|
+
* Get a job by ID.
|
|
4220
|
+
* @param jobId The job identifier.
|
|
4221
|
+
* @returns Job service for info and logs operations.
|
|
4222
|
+
*/
|
|
4223
|
+
get(jobId: string): AiSearchJob;
|
|
4224
|
+
}
|
|
4225
|
+
// ============ AI Search Binding Classes ============
|
|
4226
|
+
/**
|
|
4227
|
+
* Instance-level AI Search service.
|
|
4228
|
+
*
|
|
4229
|
+
* Used as:
|
|
4230
|
+
* - The return type of `AiSearchNamespace.get(name)` (namespace binding)
|
|
4231
|
+
* - The type of `env.BLOG_SEARCH` (single instance binding via `ai_search`)
|
|
4232
|
+
*
|
|
4233
|
+
* Provides search, chat, update, stats, items, and jobs operations.
|
|
4234
|
+
*
|
|
4235
|
+
* @example
|
|
4236
|
+
* ```ts
|
|
4237
|
+
* // Via namespace binding
|
|
4238
|
+
* const instance = env.AI_SEARCH.get("blog");
|
|
4239
|
+
* const results = await instance.search({
|
|
4240
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4241
|
+
* });
|
|
4242
|
+
*
|
|
4243
|
+
* // Via single instance binding
|
|
4244
|
+
* const results = await env.BLOG_SEARCH.search({
|
|
4245
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4246
|
+
* });
|
|
4247
|
+
* ```
|
|
4248
|
+
*/
|
|
4249
|
+
export declare abstract class AiSearchInstance {
|
|
4022
4250
|
/**
|
|
4023
4251
|
* Search the AI Search instance for relevant chunks.
|
|
4024
|
-
* @param params Search request with messages and AI search options
|
|
4025
|
-
* @returns Search response with matching chunks
|
|
4252
|
+
* @param params Search request with messages and optional AI search options.
|
|
4253
|
+
* @returns Search response with matching chunks and search query.
|
|
4026
4254
|
*/
|
|
4027
4255
|
search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
|
|
4256
|
+
/**
|
|
4257
|
+
* Generate chat completions with AI Search context (streaming).
|
|
4258
|
+
* @param params Chat completions request with stream: true.
|
|
4259
|
+
* @returns ReadableStream of server-sent events.
|
|
4260
|
+
*/
|
|
4261
|
+
chatCompletions(
|
|
4262
|
+
params: AiSearchChatCompletionsRequest & {
|
|
4263
|
+
stream: true;
|
|
4264
|
+
},
|
|
4265
|
+
): Promise<ReadableStream>;
|
|
4028
4266
|
/**
|
|
4029
4267
|
* Generate chat completions with AI Search context.
|
|
4030
|
-
* @param params Chat completions request
|
|
4031
|
-
* @returns
|
|
4268
|
+
* @param params Chat completions request.
|
|
4269
|
+
* @returns Chat completion response with choices and RAG chunks.
|
|
4032
4270
|
*/
|
|
4033
4271
|
chatCompletions(
|
|
4034
4272
|
params: AiSearchChatCompletionsRequest,
|
|
4035
|
-
): Promise<
|
|
4273
|
+
): Promise<AiSearchChatCompletionsResponse>;
|
|
4036
4274
|
/**
|
|
4037
|
-
*
|
|
4275
|
+
* Update the instance configuration.
|
|
4276
|
+
* @param config Partial configuration to update.
|
|
4277
|
+
* @returns Updated instance info.
|
|
4038
4278
|
*/
|
|
4039
|
-
|
|
4279
|
+
update(config: Partial<AiSearchConfig>): Promise<AiSearchInstanceInfo>;
|
|
4280
|
+
/** Get metadata about this instance. */
|
|
4281
|
+
info(): Promise<AiSearchInstanceInfo>;
|
|
4282
|
+
/**
|
|
4283
|
+
* Get instance statistics (item count, indexing status, etc.).
|
|
4284
|
+
* @returns Statistics with counts per status and last activity time.
|
|
4285
|
+
*/
|
|
4286
|
+
stats(): Promise<AiSearchStatsResponse>;
|
|
4287
|
+
/** Items collection — list, upload, and manage items in this instance. */
|
|
4288
|
+
get items(): AiSearchItems;
|
|
4289
|
+
/** Jobs collection — list, create, and inspect indexing jobs. */
|
|
4290
|
+
get jobs(): AiSearchJobs;
|
|
4040
4291
|
}
|
|
4041
|
-
|
|
4042
|
-
|
|
4292
|
+
/**
|
|
4293
|
+
* Namespace-level AI Search service.
|
|
4294
|
+
*
|
|
4295
|
+
* Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
|
|
4296
|
+
* Scoped to a single namespace. Provides dynamic instance access, creation, and deletion.
|
|
4297
|
+
*
|
|
4298
|
+
* @example
|
|
4299
|
+
* ```ts
|
|
4300
|
+
* // Access an instance within the namespace
|
|
4301
|
+
* const blog = env.AI_SEARCH.get("blog");
|
|
4302
|
+
* const results = await blog.search({
|
|
4303
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4304
|
+
* });
|
|
4305
|
+
*
|
|
4306
|
+
* // List all instances in the namespace
|
|
4307
|
+
* const instances = await env.AI_SEARCH.list();
|
|
4308
|
+
*
|
|
4309
|
+
* // Create a new instance with built-in storage
|
|
4310
|
+
* const tenant = await env.AI_SEARCH.create({
|
|
4311
|
+
* id: "tenant-123",
|
|
4312
|
+
* });
|
|
4313
|
+
*
|
|
4314
|
+
* // Upload items into the instance
|
|
4315
|
+
* await tenant.items.upload("doc.pdf", fileContent);
|
|
4316
|
+
*
|
|
4317
|
+
* // Delete an instance
|
|
4318
|
+
* await env.AI_SEARCH.delete("tenant-123");
|
|
4319
|
+
* ```
|
|
4320
|
+
*/
|
|
4321
|
+
export declare abstract class AiSearchNamespace {
|
|
4043
4322
|
/**
|
|
4044
|
-
*
|
|
4045
|
-
* @
|
|
4323
|
+
* Get an instance by name within the bound namespace.
|
|
4324
|
+
* @param name Instance name.
|
|
4325
|
+
* @returns Instance service for search, chat, update, stats, items, and jobs.
|
|
4326
|
+
*/
|
|
4327
|
+
get(name: string): AiSearchInstance;
|
|
4328
|
+
/**
|
|
4329
|
+
* List all instances in the bound namespace.
|
|
4330
|
+
* @returns Array of instance metadata.
|
|
4046
4331
|
*/
|
|
4047
4332
|
list(): Promise<AiSearchListResponse>;
|
|
4048
4333
|
/**
|
|
4049
|
-
*
|
|
4050
|
-
* @param
|
|
4051
|
-
* @returns Instance service for
|
|
4334
|
+
* Create a new instance within the bound namespace.
|
|
4335
|
+
* @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
|
|
4336
|
+
* @returns Instance service for the newly created instance.
|
|
4337
|
+
*
|
|
4338
|
+
* @example
|
|
4339
|
+
* ```ts
|
|
4340
|
+
* // Create with built-in storage (upload items manually)
|
|
4341
|
+
* const instance = await env.AI_SEARCH.create({ id: "my-search" });
|
|
4342
|
+
*
|
|
4343
|
+
* // Create with web crawler source
|
|
4344
|
+
* const instance = await env.AI_SEARCH.create({
|
|
4345
|
+
* id: "docs-search",
|
|
4346
|
+
* type: "web-crawler",
|
|
4347
|
+
* source: "https://developers.cloudflare.com",
|
|
4348
|
+
* });
|
|
4349
|
+
* ```
|
|
4052
4350
|
*/
|
|
4053
|
-
|
|
4351
|
+
create(config: AiSearchConfig): Promise<AiSearchInstance>;
|
|
4054
4352
|
/**
|
|
4055
|
-
*
|
|
4056
|
-
* @param
|
|
4057
|
-
* @returns Instance service for performing operations
|
|
4353
|
+
* Delete an instance from the bound namespace.
|
|
4354
|
+
* @param name Instance name to delete.
|
|
4058
4355
|
*/
|
|
4059
|
-
|
|
4356
|
+
delete(name: string): Promise<void>;
|
|
4060
4357
|
}
|
|
4061
4358
|
export type AiImageClassificationInput = {
|
|
4062
4359
|
image: number[];
|
|
@@ -10057,6 +10354,7 @@ export type AiOptions = {
|
|
|
10057
10354
|
returnRawResponse?: boolean;
|
|
10058
10355
|
prefix?: string;
|
|
10059
10356
|
extraHeaders?: object;
|
|
10357
|
+
signal?: AbortSignal;
|
|
10060
10358
|
};
|
|
10061
10359
|
export type AiModelsSearchParams = {
|
|
10062
10360
|
author?: string;
|
|
@@ -10102,46 +10400,16 @@ export declare abstract class Ai<
|
|
|
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 @@ export 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
|
export 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
|
export 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
|
export 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
|
export interface AutoRAGNameNotSetError extends Error {}
|
|
10321
10590
|
export type ComparisonFilter = {
|
|
@@ -10328,9 +10597,8 @@ export 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
|
export type AutoRagSearchRequest = {
|
|
10336
10604
|
query: string;
|
|
@@ -10347,18 +10615,16 @@ export 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
|
export 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
|
export type AutoRagAiSearchRequestStreaming = Omit<
|
|
10364
10630
|
AutoRagAiSearchRequest,
|
|
@@ -10367,9 +10633,8 @@ export 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
|
export type AutoRagSearchResponse = {
|
|
10375
10640
|
object: "vector_store.search_results.page";
|
|
@@ -10388,9 +10653,8 @@ export 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
|
export type AutoRagListResponse = {
|
|
10396
10660
|
id: string;
|
|
@@ -10402,49 +10666,40 @@ export 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
|
export 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
|
export 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,
|