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