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