@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-03-21/index.ts
CHANGED
|
@@ -3097,6 +3097,11 @@ export interface QueuingStrategyInit {
|
|
|
3097
3097
|
*/
|
|
3098
3098
|
highWaterMark: number;
|
|
3099
3099
|
}
|
|
3100
|
+
export interface TracePreviewInfo {
|
|
3101
|
+
id: string;
|
|
3102
|
+
slug: string;
|
|
3103
|
+
name: string;
|
|
3104
|
+
}
|
|
3100
3105
|
export interface ScriptVersion {
|
|
3101
3106
|
id?: string;
|
|
3102
3107
|
tag?: string;
|
|
@@ -3131,6 +3136,7 @@ export interface TraceItem {
|
|
|
3131
3136
|
readonly dispatchNamespace?: string;
|
|
3132
3137
|
readonly scriptTags?: string[];
|
|
3133
3138
|
readonly tailAttributes?: Record<string, boolean | number | string>;
|
|
3139
|
+
readonly preview?: TracePreviewInfo;
|
|
3134
3140
|
readonly durableObjectId?: string;
|
|
3135
3141
|
readonly outcome: string;
|
|
3136
3142
|
readonly executionModel: string;
|
|
@@ -3869,11 +3875,10 @@ export declare abstract class Performance {
|
|
|
3869
3875
|
*/
|
|
3870
3876
|
toJSON(): object;
|
|
3871
3877
|
}
|
|
3872
|
-
// AI Search
|
|
3878
|
+
// ============ AI Search Error Interfaces ============
|
|
3873
3879
|
export interface AiSearchInternalError extends Error {}
|
|
3874
3880
|
export interface AiSearchNotFoundError extends Error {}
|
|
3875
|
-
|
|
3876
|
-
// AI Search V2 Request Types
|
|
3881
|
+
// ============ AI Search Request Types ============
|
|
3877
3882
|
export type AiSearchSearchRequest = {
|
|
3878
3883
|
messages: Array<{
|
|
3879
3884
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
@@ -3898,9 +3903,8 @@ export type AiSearchSearchRequest = {
|
|
|
3898
3903
|
[key: string]: unknown;
|
|
3899
3904
|
};
|
|
3900
3905
|
reranking?: {
|
|
3901
|
-
/** Enable reranking (default false) */
|
|
3902
3906
|
enabled?: boolean;
|
|
3903
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
3907
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
3904
3908
|
/** Match threshold (0-1, default 0.4) */
|
|
3905
3909
|
match_threshold?: number;
|
|
3906
3910
|
[key: string]: unknown;
|
|
@@ -3912,6 +3916,7 @@ export type AiSearchChatCompletionsRequest = {
|
|
|
3912
3916
|
messages: Array<{
|
|
3913
3917
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
3914
3918
|
content: string | null;
|
|
3919
|
+
[key: string]: unknown;
|
|
3915
3920
|
}>;
|
|
3916
3921
|
model?: string;
|
|
3917
3922
|
stream?: boolean;
|
|
@@ -3932,7 +3937,7 @@ export type AiSearchChatCompletionsRequest = {
|
|
|
3932
3937
|
};
|
|
3933
3938
|
reranking?: {
|
|
3934
3939
|
enabled?: boolean;
|
|
3935
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
3940
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
3936
3941
|
match_threshold?: number;
|
|
3937
3942
|
[key: string]: unknown;
|
|
3938
3943
|
};
|
|
@@ -3940,7 +3945,7 @@ export type AiSearchChatCompletionsRequest = {
|
|
|
3940
3945
|
};
|
|
3941
3946
|
[key: string]: unknown;
|
|
3942
3947
|
};
|
|
3943
|
-
// AI Search
|
|
3948
|
+
// ============ AI Search Response Types ============
|
|
3944
3949
|
export type AiSearchSearchResponse = {
|
|
3945
3950
|
search_query: string;
|
|
3946
3951
|
chunks: Array<{
|
|
@@ -3959,26 +3964,65 @@ export type AiSearchSearchResponse = {
|
|
|
3959
3964
|
keyword_score?: number;
|
|
3960
3965
|
/** Vector similarity score (0-1) */
|
|
3961
3966
|
vector_score?: number;
|
|
3967
|
+
[key: string]: unknown;
|
|
3968
|
+
};
|
|
3969
|
+
}>;
|
|
3970
|
+
};
|
|
3971
|
+
export type AiSearchChatCompletionsResponse = {
|
|
3972
|
+
id?: string;
|
|
3973
|
+
object?: string;
|
|
3974
|
+
model?: string;
|
|
3975
|
+
choices: Array<{
|
|
3976
|
+
index?: number;
|
|
3977
|
+
message: {
|
|
3978
|
+
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
3979
|
+
content: string | null;
|
|
3980
|
+
[key: string]: unknown;
|
|
3962
3981
|
};
|
|
3982
|
+
[key: string]: unknown;
|
|
3963
3983
|
}>;
|
|
3984
|
+
chunks: AiSearchSearchResponse["chunks"];
|
|
3985
|
+
[key: string]: unknown;
|
|
3964
3986
|
};
|
|
3965
|
-
export type
|
|
3987
|
+
export type AiSearchStatsResponse = {
|
|
3988
|
+
queued?: number;
|
|
3989
|
+
running?: number;
|
|
3990
|
+
completed?: number;
|
|
3991
|
+
error?: number;
|
|
3992
|
+
skipped?: number;
|
|
3993
|
+
outdated?: number;
|
|
3994
|
+
last_activity?: string;
|
|
3995
|
+
};
|
|
3996
|
+
// ============ AI Search Instance Info Types ============
|
|
3997
|
+
export type AiSearchInstanceInfo = {
|
|
3966
3998
|
id: string;
|
|
3967
|
-
|
|
3968
|
-
account_id?: string;
|
|
3969
|
-
account_tag?: string;
|
|
3970
|
-
/** Whether the instance is enabled (default true) */
|
|
3971
|
-
enable?: boolean;
|
|
3972
|
-
type?: "r2" | "web-crawler";
|
|
3999
|
+
type?: "r2" | "web-crawler" | string;
|
|
3973
4000
|
source?: string;
|
|
4001
|
+
paused?: boolean;
|
|
4002
|
+
status?: string;
|
|
4003
|
+
namespace?: string;
|
|
4004
|
+
created_at?: string;
|
|
4005
|
+
modified_at?: string;
|
|
3974
4006
|
[key: string]: unknown;
|
|
3975
|
-
}
|
|
4007
|
+
};
|
|
4008
|
+
export type AiSearchListResponse = {
|
|
4009
|
+
result: AiSearchInstanceInfo[];
|
|
4010
|
+
result_info?: {
|
|
4011
|
+
count: number;
|
|
4012
|
+
page: number;
|
|
4013
|
+
per_page: number;
|
|
4014
|
+
total_count: number;
|
|
4015
|
+
};
|
|
4016
|
+
};
|
|
4017
|
+
// ============ AI Search Config Types ============
|
|
3976
4018
|
export type AiSearchConfig = {
|
|
3977
4019
|
/** Instance ID (1-32 chars, pattern: ^[a-z0-9_]+(?:-[a-z0-9_]+)*$) */
|
|
3978
4020
|
id: string;
|
|
3979
|
-
type
|
|
3980
|
-
|
|
3981
|
-
|
|
4021
|
+
/** Instance type. Omit to create with built-in storage. */
|
|
4022
|
+
type?: "r2" | "web-crawler" | string;
|
|
4023
|
+
/** Source URL (required for web-crawler type). */
|
|
4024
|
+
source?: string;
|
|
4025
|
+
source_params?: unknown;
|
|
3982
4026
|
/** Token ID (UUID format) */
|
|
3983
4027
|
token_id?: string;
|
|
3984
4028
|
ai_gateway_id?: string;
|
|
@@ -3988,54 +4032,307 @@ export type AiSearchConfig = {
|
|
|
3988
4032
|
reranking?: boolean;
|
|
3989
4033
|
embedding_model?: string;
|
|
3990
4034
|
ai_search_model?: string;
|
|
4035
|
+
[key: string]: unknown;
|
|
3991
4036
|
};
|
|
3992
|
-
|
|
4037
|
+
// ============ AI Search Item Types ============
|
|
4038
|
+
export type AiSearchItemInfo = {
|
|
3993
4039
|
id: string;
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
4040
|
+
key: string;
|
|
4041
|
+
status:
|
|
4042
|
+
| "completed"
|
|
4043
|
+
| "error"
|
|
4044
|
+
| "skipped"
|
|
4045
|
+
| "queued"
|
|
4046
|
+
| "processing"
|
|
4047
|
+
| "outdated";
|
|
4048
|
+
metadata?: Record<string, unknown>;
|
|
3997
4049
|
[key: string]: unknown;
|
|
3998
4050
|
};
|
|
3999
|
-
|
|
4000
|
-
|
|
4051
|
+
export type AiSearchItemContentResult = {
|
|
4052
|
+
body: ReadableStream;
|
|
4053
|
+
contentType: string;
|
|
4054
|
+
filename: string;
|
|
4055
|
+
size: number;
|
|
4056
|
+
};
|
|
4057
|
+
export type AiSearchUploadItemOptions = {
|
|
4058
|
+
metadata?: Record<string, unknown>;
|
|
4059
|
+
};
|
|
4060
|
+
export type AiSearchListItemsParams = {
|
|
4061
|
+
page?: number;
|
|
4062
|
+
per_page?: number;
|
|
4063
|
+
};
|
|
4064
|
+
export type AiSearchListItemsResponse = {
|
|
4065
|
+
result: AiSearchItemInfo[];
|
|
4066
|
+
result_info?: {
|
|
4067
|
+
count: number;
|
|
4068
|
+
page: number;
|
|
4069
|
+
per_page: number;
|
|
4070
|
+
total_count: number;
|
|
4071
|
+
};
|
|
4072
|
+
};
|
|
4073
|
+
// ============ AI Search Job Types ============
|
|
4074
|
+
export type AiSearchJobInfo = {
|
|
4075
|
+
id: string;
|
|
4076
|
+
source: "user" | "schedule";
|
|
4077
|
+
description?: string;
|
|
4078
|
+
last_seen_at?: string;
|
|
4079
|
+
started_at?: string;
|
|
4080
|
+
ended_at?: string;
|
|
4081
|
+
end_reason?: string;
|
|
4082
|
+
};
|
|
4083
|
+
export type AiSearchJobLog = {
|
|
4084
|
+
id: number;
|
|
4085
|
+
message: string;
|
|
4086
|
+
message_type: number;
|
|
4087
|
+
created_at: number;
|
|
4088
|
+
};
|
|
4089
|
+
export type AiSearchCreateJobParams = {
|
|
4090
|
+
description?: string;
|
|
4091
|
+
};
|
|
4092
|
+
export type AiSearchListJobsParams = {
|
|
4093
|
+
page?: number;
|
|
4094
|
+
per_page?: number;
|
|
4095
|
+
};
|
|
4096
|
+
export type AiSearchListJobsResponse = {
|
|
4097
|
+
result: AiSearchJobInfo[];
|
|
4098
|
+
result_info?: {
|
|
4099
|
+
count: number;
|
|
4100
|
+
page: number;
|
|
4101
|
+
per_page: number;
|
|
4102
|
+
total_count: number;
|
|
4103
|
+
};
|
|
4104
|
+
};
|
|
4105
|
+
export type AiSearchJobLogsParams = {
|
|
4106
|
+
page?: number;
|
|
4107
|
+
per_page?: number;
|
|
4108
|
+
};
|
|
4109
|
+
export type AiSearchJobLogsResponse = {
|
|
4110
|
+
result: AiSearchJobLog[];
|
|
4111
|
+
result_info?: {
|
|
4112
|
+
count: number;
|
|
4113
|
+
page: number;
|
|
4114
|
+
per_page: number;
|
|
4115
|
+
total_count: number;
|
|
4116
|
+
};
|
|
4117
|
+
};
|
|
4118
|
+
// ============ AI Search Sub-Service Classes ============
|
|
4119
|
+
/**
|
|
4120
|
+
* Single item service for an AI Search instance.
|
|
4121
|
+
* Provides info, delete, and download operations on a specific item.
|
|
4122
|
+
*/
|
|
4123
|
+
export declare abstract class AiSearchItem {
|
|
4124
|
+
/** Get metadata about this item. */
|
|
4125
|
+
info(): Promise<AiSearchItemInfo>;
|
|
4126
|
+
/**
|
|
4127
|
+
* Download the item's content.
|
|
4128
|
+
* @returns Object with body stream, content type, filename, and size.
|
|
4129
|
+
*/
|
|
4130
|
+
download(): Promise<AiSearchItemContentResult>;
|
|
4131
|
+
}
|
|
4132
|
+
/**
|
|
4133
|
+
* Items collection service for an AI Search instance.
|
|
4134
|
+
* Provides list, upload, and access to individual items.
|
|
4135
|
+
*/
|
|
4136
|
+
export declare abstract class AiSearchItems {
|
|
4137
|
+
/** List items in this instance. */
|
|
4138
|
+
list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
|
|
4139
|
+
/**
|
|
4140
|
+
* Upload a file as an item.
|
|
4141
|
+
* @param name Filename for the uploaded item.
|
|
4142
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4143
|
+
* @param options Optional metadata to attach to the item.
|
|
4144
|
+
* @returns The created item info.
|
|
4145
|
+
*/
|
|
4146
|
+
upload(
|
|
4147
|
+
name: string,
|
|
4148
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4149
|
+
options?: AiSearchUploadItemOptions,
|
|
4150
|
+
): Promise<AiSearchItemInfo>;
|
|
4151
|
+
/**
|
|
4152
|
+
* Upload a file and poll until processing completes.
|
|
4153
|
+
* @param name Filename for the uploaded item.
|
|
4154
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4155
|
+
* @param options Optional metadata to attach to the item.
|
|
4156
|
+
* @returns The item info after processing completes (or timeout).
|
|
4157
|
+
*/
|
|
4158
|
+
uploadAndPoll(
|
|
4159
|
+
name: string,
|
|
4160
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4161
|
+
options?: AiSearchUploadItemOptions,
|
|
4162
|
+
): Promise<AiSearchItemInfo>;
|
|
4163
|
+
/**
|
|
4164
|
+
* Get an item by ID.
|
|
4165
|
+
* @param itemId The item identifier.
|
|
4166
|
+
* @returns Item service for info, delete, and download operations.
|
|
4167
|
+
*/
|
|
4168
|
+
get(itemId: string): AiSearchItem;
|
|
4169
|
+
/** Delete this item from the instance.
|
|
4170
|
+
* @param itemId The item identifier.
|
|
4171
|
+
*/
|
|
4172
|
+
delete(itemId: string): Promise<void>;
|
|
4173
|
+
}
|
|
4174
|
+
/**
|
|
4175
|
+
* Single job service for an AI Search instance.
|
|
4176
|
+
* Provides info and logs for a specific job.
|
|
4177
|
+
*/
|
|
4178
|
+
export declare abstract class AiSearchJob {
|
|
4179
|
+
/** Get metadata about this job. */
|
|
4180
|
+
info(): Promise<AiSearchJobInfo>;
|
|
4181
|
+
/** Get logs for this job. */
|
|
4182
|
+
logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
|
|
4183
|
+
}
|
|
4184
|
+
/**
|
|
4185
|
+
* Jobs collection service for an AI Search instance.
|
|
4186
|
+
* Provides list, create, and access to individual jobs.
|
|
4187
|
+
*/
|
|
4188
|
+
export declare abstract class AiSearchJobs {
|
|
4189
|
+
/** List jobs for this instance. */
|
|
4190
|
+
list(params?: AiSearchListJobsParams): Promise<AiSearchListJobsResponse>;
|
|
4191
|
+
/**
|
|
4192
|
+
* Create a new indexing job.
|
|
4193
|
+
* @param params Optional job parameters.
|
|
4194
|
+
* @returns The created job info.
|
|
4195
|
+
*/
|
|
4196
|
+
create(params?: AiSearchCreateJobParams): Promise<AiSearchJobInfo>;
|
|
4197
|
+
/**
|
|
4198
|
+
* Get a job by ID.
|
|
4199
|
+
* @param jobId The job identifier.
|
|
4200
|
+
* @returns Job service for info and logs operations.
|
|
4201
|
+
*/
|
|
4202
|
+
get(jobId: string): AiSearchJob;
|
|
4203
|
+
}
|
|
4204
|
+
// ============ AI Search Binding Classes ============
|
|
4205
|
+
/**
|
|
4206
|
+
* Instance-level AI Search service.
|
|
4207
|
+
*
|
|
4208
|
+
* Used as:
|
|
4209
|
+
* - The return type of `AiSearchNamespace.get(name)` (namespace binding)
|
|
4210
|
+
* - The type of `env.BLOG_SEARCH` (single instance binding via `ai_search`)
|
|
4211
|
+
*
|
|
4212
|
+
* Provides search, chat, update, stats, items, and jobs operations.
|
|
4213
|
+
*
|
|
4214
|
+
* @example
|
|
4215
|
+
* ```ts
|
|
4216
|
+
* // Via namespace binding
|
|
4217
|
+
* const instance = env.AI_SEARCH.get("blog");
|
|
4218
|
+
* const results = await instance.search({
|
|
4219
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4220
|
+
* });
|
|
4221
|
+
*
|
|
4222
|
+
* // Via single instance binding
|
|
4223
|
+
* const results = await env.BLOG_SEARCH.search({
|
|
4224
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4225
|
+
* });
|
|
4226
|
+
* ```
|
|
4227
|
+
*/
|
|
4228
|
+
export declare abstract class AiSearchInstance {
|
|
4001
4229
|
/**
|
|
4002
4230
|
* Search the AI Search instance for relevant chunks.
|
|
4003
|
-
* @param params Search request with messages and AI search options
|
|
4004
|
-
* @returns Search response with matching chunks
|
|
4231
|
+
* @param params Search request with messages and optional AI search options.
|
|
4232
|
+
* @returns Search response with matching chunks and search query.
|
|
4005
4233
|
*/
|
|
4006
4234
|
search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
|
|
4235
|
+
/**
|
|
4236
|
+
* Generate chat completions with AI Search context (streaming).
|
|
4237
|
+
* @param params Chat completions request with stream: true.
|
|
4238
|
+
* @returns ReadableStream of server-sent events.
|
|
4239
|
+
*/
|
|
4240
|
+
chatCompletions(
|
|
4241
|
+
params: AiSearchChatCompletionsRequest & {
|
|
4242
|
+
stream: true;
|
|
4243
|
+
},
|
|
4244
|
+
): Promise<ReadableStream>;
|
|
4007
4245
|
/**
|
|
4008
4246
|
* Generate chat completions with AI Search context.
|
|
4009
|
-
* @param params Chat completions request
|
|
4010
|
-
* @returns
|
|
4247
|
+
* @param params Chat completions request.
|
|
4248
|
+
* @returns Chat completion response with choices and RAG chunks.
|
|
4011
4249
|
*/
|
|
4012
4250
|
chatCompletions(
|
|
4013
4251
|
params: AiSearchChatCompletionsRequest,
|
|
4014
|
-
): Promise<
|
|
4252
|
+
): Promise<AiSearchChatCompletionsResponse>;
|
|
4015
4253
|
/**
|
|
4016
|
-
*
|
|
4254
|
+
* Update the instance configuration.
|
|
4255
|
+
* @param config Partial configuration to update.
|
|
4256
|
+
* @returns Updated instance info.
|
|
4017
4257
|
*/
|
|
4018
|
-
|
|
4258
|
+
update(config: Partial<AiSearchConfig>): Promise<AiSearchInstanceInfo>;
|
|
4259
|
+
/** Get metadata about this instance. */
|
|
4260
|
+
info(): Promise<AiSearchInstanceInfo>;
|
|
4261
|
+
/**
|
|
4262
|
+
* Get instance statistics (item count, indexing status, etc.).
|
|
4263
|
+
* @returns Statistics with counts per status and last activity time.
|
|
4264
|
+
*/
|
|
4265
|
+
stats(): Promise<AiSearchStatsResponse>;
|
|
4266
|
+
/** Items collection — list, upload, and manage items in this instance. */
|
|
4267
|
+
get items(): AiSearchItems;
|
|
4268
|
+
/** Jobs collection — list, create, and inspect indexing jobs. */
|
|
4269
|
+
get jobs(): AiSearchJobs;
|
|
4019
4270
|
}
|
|
4020
|
-
|
|
4021
|
-
|
|
4271
|
+
/**
|
|
4272
|
+
* Namespace-level AI Search service.
|
|
4273
|
+
*
|
|
4274
|
+
* Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
|
|
4275
|
+
* Scoped to a single namespace. Provides dynamic instance access, creation, and deletion.
|
|
4276
|
+
*
|
|
4277
|
+
* @example
|
|
4278
|
+
* ```ts
|
|
4279
|
+
* // Access an instance within the namespace
|
|
4280
|
+
* const blog = env.AI_SEARCH.get("blog");
|
|
4281
|
+
* const results = await blog.search({
|
|
4282
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4283
|
+
* });
|
|
4284
|
+
*
|
|
4285
|
+
* // List all instances in the namespace
|
|
4286
|
+
* const instances = await env.AI_SEARCH.list();
|
|
4287
|
+
*
|
|
4288
|
+
* // Create a new instance with built-in storage
|
|
4289
|
+
* const tenant = await env.AI_SEARCH.create({
|
|
4290
|
+
* id: "tenant-123",
|
|
4291
|
+
* });
|
|
4292
|
+
*
|
|
4293
|
+
* // Upload items into the instance
|
|
4294
|
+
* await tenant.items.upload("doc.pdf", fileContent);
|
|
4295
|
+
*
|
|
4296
|
+
* // Delete an instance
|
|
4297
|
+
* await env.AI_SEARCH.delete("tenant-123");
|
|
4298
|
+
* ```
|
|
4299
|
+
*/
|
|
4300
|
+
export declare abstract class AiSearchNamespace {
|
|
4022
4301
|
/**
|
|
4023
|
-
*
|
|
4024
|
-
* @
|
|
4302
|
+
* Get an instance by name within the bound namespace.
|
|
4303
|
+
* @param name Instance name.
|
|
4304
|
+
* @returns Instance service for search, chat, update, stats, items, and jobs.
|
|
4305
|
+
*/
|
|
4306
|
+
get(name: string): AiSearchInstance;
|
|
4307
|
+
/**
|
|
4308
|
+
* List all instances in the bound namespace.
|
|
4309
|
+
* @returns Array of instance metadata.
|
|
4025
4310
|
*/
|
|
4026
4311
|
list(): Promise<AiSearchListResponse>;
|
|
4027
4312
|
/**
|
|
4028
|
-
*
|
|
4029
|
-
* @param
|
|
4030
|
-
* @returns Instance service for
|
|
4313
|
+
* Create a new instance within the bound namespace.
|
|
4314
|
+
* @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
|
|
4315
|
+
* @returns Instance service for the newly created instance.
|
|
4316
|
+
*
|
|
4317
|
+
* @example
|
|
4318
|
+
* ```ts
|
|
4319
|
+
* // Create with built-in storage (upload items manually)
|
|
4320
|
+
* const instance = await env.AI_SEARCH.create({ id: "my-search" });
|
|
4321
|
+
*
|
|
4322
|
+
* // Create with web crawler source
|
|
4323
|
+
* const instance = await env.AI_SEARCH.create({
|
|
4324
|
+
* id: "docs-search",
|
|
4325
|
+
* type: "web-crawler",
|
|
4326
|
+
* source: "https://developers.cloudflare.com",
|
|
4327
|
+
* });
|
|
4328
|
+
* ```
|
|
4031
4329
|
*/
|
|
4032
|
-
|
|
4330
|
+
create(config: AiSearchConfig): Promise<AiSearchInstance>;
|
|
4033
4331
|
/**
|
|
4034
|
-
*
|
|
4035
|
-
* @param
|
|
4036
|
-
* @returns Instance service for performing operations
|
|
4332
|
+
* Delete an instance from the bound namespace.
|
|
4333
|
+
* @param name Instance name to delete.
|
|
4037
4334
|
*/
|
|
4038
|
-
|
|
4335
|
+
delete(name: string): Promise<void>;
|
|
4039
4336
|
}
|
|
4040
4337
|
export type AiImageClassificationInput = {
|
|
4041
4338
|
image: number[];
|
|
@@ -10036,6 +10333,7 @@ export type AiOptions = {
|
|
|
10036
10333
|
returnRawResponse?: boolean;
|
|
10037
10334
|
prefix?: string;
|
|
10038
10335
|
extraHeaders?: object;
|
|
10336
|
+
signal?: AbortSignal;
|
|
10039
10337
|
};
|
|
10040
10338
|
export type AiModelsSearchParams = {
|
|
10041
10339
|
author?: string;
|
|
@@ -10081,46 +10379,16 @@ export declare abstract class Ai<
|
|
|
10081
10379
|
aiGatewayLogId: string | null;
|
|
10082
10380
|
gateway(gatewayId: string): AiGateway;
|
|
10083
10381
|
/**
|
|
10084
|
-
*
|
|
10085
|
-
*
|
|
10086
|
-
* This is the new API that replaces AutoRAG with better namespace separation:
|
|
10087
|
-
* - Account-level operations: `list()`, `create()`
|
|
10088
|
-
* - Instance-level operations: `get(id).search()`, `get(id).chatCompletions()`, `get(id).delete()`
|
|
10089
|
-
*
|
|
10090
|
-
* @example
|
|
10091
|
-
* ```typescript
|
|
10092
|
-
* // List all AI Search instances
|
|
10093
|
-
* const instances = await env.AI.aiSearch.list();
|
|
10094
|
-
*
|
|
10095
|
-
* // Search an instance
|
|
10096
|
-
* const results = await env.AI.aiSearch.get('my-search').search({
|
|
10097
|
-
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
10098
|
-
* ai_search_options: {
|
|
10099
|
-
* retrieval: { max_num_results: 10 }
|
|
10100
|
-
* }
|
|
10101
|
-
* });
|
|
10102
|
-
*
|
|
10103
|
-
* // Generate chat completions with AI Search context
|
|
10104
|
-
* const response = await env.AI.aiSearch.get('my-search').chatCompletions({
|
|
10105
|
-
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
10106
|
-
* model: '@cf/meta/llama-3.3-70b-instruct-fp8-fast'
|
|
10107
|
-
* });
|
|
10108
|
-
* ```
|
|
10382
|
+
* @deprecated Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
10383
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10109
10384
|
*/
|
|
10110
|
-
aiSearch():
|
|
10385
|
+
aiSearch(): AiSearchNamespace;
|
|
10111
10386
|
/**
|
|
10112
10387
|
* @deprecated AutoRAG has been replaced by AI Search.
|
|
10113
|
-
* Use `
|
|
10114
|
-
*
|
|
10115
|
-
* Migration guide:
|
|
10116
|
-
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
10117
|
-
* - `env.AI.autorag('id').search({ query: '...' })` → `env.AI.aiSearch.get('id').search({ messages: [{ role: 'user', content: '...' }] })`
|
|
10118
|
-
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
10388
|
+
* Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
10389
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10119
10390
|
*
|
|
10120
|
-
*
|
|
10121
|
-
*
|
|
10122
|
-
* @see AiSearchAccountService
|
|
10123
|
-
* @param autoragId Optional instance ID (omit for account-level operations)
|
|
10391
|
+
* @param autoragId Instance ID
|
|
10124
10392
|
*/
|
|
10125
10393
|
autorag(autoragId: string): AutoRAG;
|
|
10126
10394
|
run<
|
|
@@ -10279,22 +10547,23 @@ export declare abstract class AiGateway {
|
|
|
10279
10547
|
getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
|
|
10280
10548
|
}
|
|
10281
10549
|
/**
|
|
10282
|
-
* @deprecated
|
|
10283
|
-
*
|
|
10550
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10551
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10284
10552
|
*/
|
|
10285
10553
|
export interface AutoRAGInternalError extends Error {}
|
|
10286
10554
|
/**
|
|
10287
|
-
* @deprecated
|
|
10288
|
-
*
|
|
10555
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10556
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10289
10557
|
*/
|
|
10290
10558
|
export interface AutoRAGNotFoundError extends Error {}
|
|
10291
10559
|
/**
|
|
10292
|
-
* @deprecated
|
|
10560
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10561
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10293
10562
|
*/
|
|
10294
10563
|
export interface AutoRAGUnauthorizedError extends Error {}
|
|
10295
10564
|
/**
|
|
10296
|
-
* @deprecated
|
|
10297
|
-
*
|
|
10565
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10566
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10298
10567
|
*/
|
|
10299
10568
|
export interface AutoRAGNameNotSetError extends Error {}
|
|
10300
10569
|
export type ComparisonFilter = {
|
|
@@ -10307,9 +10576,8 @@ export type CompoundFilter = {
|
|
|
10307
10576
|
filters: ComparisonFilter[];
|
|
10308
10577
|
};
|
|
10309
10578
|
/**
|
|
10310
|
-
* @deprecated
|
|
10311
|
-
*
|
|
10312
|
-
* @see AiSearchSearchRequest
|
|
10579
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10580
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10313
10581
|
*/
|
|
10314
10582
|
export type AutoRagSearchRequest = {
|
|
10315
10583
|
query: string;
|
|
@@ -10326,18 +10594,16 @@ export type AutoRagSearchRequest = {
|
|
|
10326
10594
|
rewrite_query?: boolean;
|
|
10327
10595
|
};
|
|
10328
10596
|
/**
|
|
10329
|
-
* @deprecated
|
|
10330
|
-
*
|
|
10331
|
-
* @see AiSearchChatCompletionsRequest
|
|
10597
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10598
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10332
10599
|
*/
|
|
10333
10600
|
export type AutoRagAiSearchRequest = AutoRagSearchRequest & {
|
|
10334
10601
|
stream?: boolean;
|
|
10335
10602
|
system_prompt?: string;
|
|
10336
10603
|
};
|
|
10337
10604
|
/**
|
|
10338
|
-
* @deprecated
|
|
10339
|
-
*
|
|
10340
|
-
* @see AiSearchChatCompletionsRequest
|
|
10605
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10606
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10341
10607
|
*/
|
|
10342
10608
|
export type AutoRagAiSearchRequestStreaming = Omit<
|
|
10343
10609
|
AutoRagAiSearchRequest,
|
|
@@ -10346,9 +10612,8 @@ export type AutoRagAiSearchRequestStreaming = Omit<
|
|
|
10346
10612
|
stream: true;
|
|
10347
10613
|
};
|
|
10348
10614
|
/**
|
|
10349
|
-
* @deprecated
|
|
10350
|
-
*
|
|
10351
|
-
* @see AiSearchSearchResponse
|
|
10615
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10616
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10352
10617
|
*/
|
|
10353
10618
|
export type AutoRagSearchResponse = {
|
|
10354
10619
|
object: "vector_store.search_results.page";
|
|
@@ -10367,9 +10632,8 @@ export type AutoRagSearchResponse = {
|
|
|
10367
10632
|
next_page: string | null;
|
|
10368
10633
|
};
|
|
10369
10634
|
/**
|
|
10370
|
-
* @deprecated
|
|
10371
|
-
*
|
|
10372
|
-
* @see AiSearchListResponse
|
|
10635
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10636
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10373
10637
|
*/
|
|
10374
10638
|
export type AutoRagListResponse = {
|
|
10375
10639
|
id: string;
|
|
@@ -10381,49 +10645,40 @@ export type AutoRagListResponse = {
|
|
|
10381
10645
|
status: string;
|
|
10382
10646
|
}[];
|
|
10383
10647
|
/**
|
|
10384
|
-
* @deprecated
|
|
10385
|
-
*
|
|
10648
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10649
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10386
10650
|
*/
|
|
10387
10651
|
export type AutoRagAiSearchResponse = AutoRagSearchResponse & {
|
|
10388
10652
|
response: string;
|
|
10389
10653
|
};
|
|
10390
10654
|
/**
|
|
10391
|
-
* @deprecated
|
|
10392
|
-
*
|
|
10393
|
-
*
|
|
10394
|
-
* Migration guide:
|
|
10395
|
-
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
10396
|
-
* - `env.AI.autorag('id').search(...)` → `env.AI.aiSearch.get('id').search(...)`
|
|
10397
|
-
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
10398
|
-
*
|
|
10399
|
-
* @see AiSearchAccountService
|
|
10400
|
-
* @see AiSearchInstanceService
|
|
10655
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10656
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10401
10657
|
*/
|
|
10402
10658
|
export declare abstract class AutoRAG {
|
|
10403
10659
|
/**
|
|
10404
|
-
* @deprecated Use
|
|
10405
|
-
*
|
|
10660
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10661
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10406
10662
|
*/
|
|
10407
10663
|
list(): Promise<AutoRagListResponse>;
|
|
10408
10664
|
/**
|
|
10409
|
-
* @deprecated Use
|
|
10410
|
-
*
|
|
10411
|
-
* @see AiSearchInstanceService.search
|
|
10665
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10666
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10412
10667
|
*/
|
|
10413
10668
|
search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;
|
|
10414
10669
|
/**
|
|
10415
|
-
* @deprecated Use
|
|
10416
|
-
*
|
|
10670
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10671
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10417
10672
|
*/
|
|
10418
10673
|
aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;
|
|
10419
10674
|
/**
|
|
10420
|
-
* @deprecated Use
|
|
10421
|
-
*
|
|
10675
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10676
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10422
10677
|
*/
|
|
10423
10678
|
aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;
|
|
10424
10679
|
/**
|
|
10425
|
-
* @deprecated Use
|
|
10426
|
-
*
|
|
10680
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10681
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10427
10682
|
*/
|
|
10428
10683
|
aiSearch(
|
|
10429
10684
|
params: AutoRagAiSearchRequest,
|