promptlayer 1.0.60 → 1.1.0
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/README.md +9 -0
- package/dist/esm/chunk-SWBNW72U.js +2 -0
- package/dist/esm/chunk-SWBNW72U.js.map +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/openai-agents.js +3 -0
- package/dist/esm/openai-agents.js.map +1 -0
- package/dist/index.d.mts +229 -9
- package/dist/index.d.ts +229 -9
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/openai-agents.d.mts +42 -0
- package/dist/openai-agents.d.ts +42 -0
- package/dist/openai-agents.js +3 -0
- package/dist/openai-agents.js.map +1 -0
- package/package.json +24 -3
- package/src/integrations/openai-agents/helpers.test.ts +254 -0
- package/src/integrations/openai-agents/ids.ts +27 -0
- package/src/integrations/openai-agents/index.ts +8 -0
- package/src/integrations/openai-agents/instrumentation.test.ts +46 -0
- package/src/integrations/openai-agents/instrumentation.ts +47 -0
- package/src/integrations/openai-agents/mapping.ts +714 -0
- package/src/integrations/openai-agents/otlp-json.ts +120 -0
- package/src/integrations/openai-agents/processor.test.ts +509 -0
- package/src/integrations/openai-agents/processor.ts +388 -0
- package/src/integrations/openai-agents/time.ts +56 -0
- package/src/integrations/openai-agents/types.ts +49 -0
- package/src/integrations/openai-agents/url.ts +9 -0
- package/src/openai-agents.ts +1 -0
- package/src/types.ts +302 -9
- package/src/utils/blueprint-builder.test.ts +727 -0
- package/src/utils/blueprint-builder.ts +957 -126
- package/src/utils/streaming.test.ts +498 -0
- package/src/utils/streaming.ts +471 -43
- package/src/utils/utils.ts +4 -0
- package/tsup.config.ts +4 -1
- package/vitest.config.ts +3 -0
package/src/types.ts
CHANGED
|
@@ -93,15 +93,59 @@ const templateFormat = ["f-string", "jinja2"] as const;
|
|
|
93
93
|
|
|
94
94
|
export type TemplateFormat = (typeof templateFormat)[number];
|
|
95
95
|
|
|
96
|
+
export type FileAnnotation = {
|
|
97
|
+
type: "file_citation";
|
|
98
|
+
index: number;
|
|
99
|
+
file_id: string;
|
|
100
|
+
filename: string;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export type WebAnnotation = {
|
|
104
|
+
type: "url_citation";
|
|
105
|
+
title: string;
|
|
106
|
+
url: string;
|
|
107
|
+
start_index: number;
|
|
108
|
+
end_index: number;
|
|
109
|
+
cited_text?: string;
|
|
110
|
+
encrypted_index?: string;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export type MapAnnotation = {
|
|
114
|
+
type: "map_citation";
|
|
115
|
+
title: string;
|
|
116
|
+
url: string;
|
|
117
|
+
place_id?: string;
|
|
118
|
+
start_index: number;
|
|
119
|
+
end_index: number;
|
|
120
|
+
cited_text?: string;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export type ContainerFileAnnotation = {
|
|
124
|
+
type: "container_file_citation";
|
|
125
|
+
container_id: string;
|
|
126
|
+
start_index?: number;
|
|
127
|
+
end_index?: number;
|
|
128
|
+
filename?: string;
|
|
129
|
+
file_id?: string;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export type Annotation =
|
|
133
|
+
| WebAnnotation
|
|
134
|
+
| FileAnnotation
|
|
135
|
+
| MapAnnotation
|
|
136
|
+
| ContainerFileAnnotation;
|
|
137
|
+
|
|
96
138
|
export type ImageUrl = {
|
|
97
139
|
url: string;
|
|
140
|
+
detail?: string;
|
|
98
141
|
};
|
|
99
142
|
|
|
100
143
|
export type TextContent = {
|
|
101
144
|
id?: string;
|
|
102
145
|
type: "text";
|
|
103
146
|
text: string;
|
|
104
|
-
annotations?:
|
|
147
|
+
annotations?: Annotation[];
|
|
148
|
+
thought_signature?: string;
|
|
105
149
|
};
|
|
106
150
|
|
|
107
151
|
export type ThinkingContent = {
|
|
@@ -116,17 +160,20 @@ export type CodeContent = {
|
|
|
116
160
|
container_id?: string;
|
|
117
161
|
type: "code";
|
|
118
162
|
code: string;
|
|
163
|
+
language?: string;
|
|
119
164
|
};
|
|
120
165
|
|
|
121
166
|
export type ImageContent = {
|
|
122
167
|
type: "image_url";
|
|
123
168
|
image_url: ImageUrl;
|
|
169
|
+
image_variable?: string;
|
|
124
170
|
};
|
|
125
171
|
|
|
126
172
|
export type Media = {
|
|
127
173
|
title: string;
|
|
128
174
|
type: string;
|
|
129
|
-
url
|
|
175
|
+
url?: string;
|
|
176
|
+
format?: "base64" | "url" | "neither";
|
|
130
177
|
};
|
|
131
178
|
|
|
132
179
|
export type MediaContent = {
|
|
@@ -139,32 +186,270 @@ export type MediaVariable = {
|
|
|
139
186
|
name: string;
|
|
140
187
|
};
|
|
141
188
|
|
|
189
|
+
export type OutputMediaContent = {
|
|
190
|
+
type: "output_media";
|
|
191
|
+
id?: string;
|
|
192
|
+
url: string;
|
|
193
|
+
mime_type?: string;
|
|
194
|
+
media_type?: "image" | "video" | "audio";
|
|
195
|
+
provider_metadata?: Record<string, unknown>;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
export type ServerToolUseContent = {
|
|
199
|
+
type: "server_tool_use";
|
|
200
|
+
id: string;
|
|
201
|
+
name: string;
|
|
202
|
+
input?: Record<string, unknown>;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
export type WebSearchResult = {
|
|
206
|
+
type: "web_search_result";
|
|
207
|
+
url?: string;
|
|
208
|
+
title?: string;
|
|
209
|
+
encrypted_content?: string;
|
|
210
|
+
page_age?: string;
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
export type WebSearchToolResultContent = {
|
|
214
|
+
type: "web_search_tool_result";
|
|
215
|
+
tool_use_id: string;
|
|
216
|
+
content?: WebSearchResult[];
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export type CodeExecutionResultContent = {
|
|
220
|
+
type: "code_execution_result";
|
|
221
|
+
output: string;
|
|
222
|
+
outcome?: string;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
export type McpListToolsContent = {
|
|
226
|
+
type: "mcp_list_tools";
|
|
227
|
+
id?: string;
|
|
228
|
+
server_label?: string;
|
|
229
|
+
tools?: Record<string, unknown>[];
|
|
230
|
+
error?: string | Record<string, unknown>;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
export type McpCallContent = {
|
|
234
|
+
type: "mcp_call";
|
|
235
|
+
id?: string;
|
|
236
|
+
name?: string;
|
|
237
|
+
server_label?: string;
|
|
238
|
+
arguments?: string;
|
|
239
|
+
output?: string;
|
|
240
|
+
error?: string | Record<string, unknown>;
|
|
241
|
+
approval_request_id?: string;
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
export type McpApprovalRequestContent = {
|
|
245
|
+
type: "mcp_approval_request";
|
|
246
|
+
id?: string;
|
|
247
|
+
name?: string;
|
|
248
|
+
arguments?: string;
|
|
249
|
+
server_label?: string;
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
export type McpApprovalResponseContent = {
|
|
253
|
+
type: "mcp_approval_response";
|
|
254
|
+
approval_request_id: string;
|
|
255
|
+
approve: boolean;
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
export type BashCodeExecutionToolResultContent = {
|
|
259
|
+
type: "bash_code_execution_tool_result";
|
|
260
|
+
tool_use_id: string;
|
|
261
|
+
content?: Record<string, unknown>;
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
export type TextEditorCodeExecutionToolResultContent = {
|
|
265
|
+
type: "text_editor_code_execution_tool_result";
|
|
266
|
+
tool_use_id: string;
|
|
267
|
+
content?: Record<string, unknown>;
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
export type ShellCallContent = {
|
|
271
|
+
type: "shell_call";
|
|
272
|
+
id?: string;
|
|
273
|
+
call_id?: string;
|
|
274
|
+
action?: Record<string, unknown>;
|
|
275
|
+
status?: string;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
export type ShellCallOutputContent = {
|
|
279
|
+
type: "shell_call_output";
|
|
280
|
+
id?: string;
|
|
281
|
+
call_id?: string;
|
|
282
|
+
output?: Record<string, unknown>[];
|
|
283
|
+
status?: string;
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
export type ApplyPatchCallContent = {
|
|
287
|
+
type: "apply_patch_call";
|
|
288
|
+
id?: string;
|
|
289
|
+
call_id?: string;
|
|
290
|
+
operation?: Record<string, unknown>;
|
|
291
|
+
status?: string;
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
export type ApplyPatchCallOutputContent = {
|
|
295
|
+
type: "apply_patch_call_output";
|
|
296
|
+
id?: string;
|
|
297
|
+
call_id?: string;
|
|
298
|
+
output?: string;
|
|
299
|
+
status?: string;
|
|
300
|
+
};
|
|
301
|
+
|
|
142
302
|
export type Content =
|
|
143
303
|
| TextContent
|
|
144
304
|
| ThinkingContent
|
|
145
305
|
| CodeContent
|
|
146
306
|
| ImageContent
|
|
147
307
|
| MediaContent
|
|
148
|
-
| MediaVariable
|
|
308
|
+
| MediaVariable
|
|
309
|
+
| OutputMediaContent
|
|
310
|
+
| ServerToolUseContent
|
|
311
|
+
| WebSearchToolResultContent
|
|
312
|
+
| CodeExecutionResultContent
|
|
313
|
+
| McpListToolsContent
|
|
314
|
+
| McpCallContent
|
|
315
|
+
| McpApprovalRequestContent
|
|
316
|
+
| McpApprovalResponseContent
|
|
317
|
+
| BashCodeExecutionToolResultContent
|
|
318
|
+
| TextEditorCodeExecutionToolResultContent
|
|
319
|
+
| ShellCallContent
|
|
320
|
+
| ShellCallOutputContent
|
|
321
|
+
| ApplyPatchCallContent
|
|
322
|
+
| ApplyPatchCallOutputContent;
|
|
149
323
|
|
|
150
324
|
export type Function_ = {
|
|
151
325
|
name: string;
|
|
152
326
|
description: string;
|
|
327
|
+
strict?: boolean;
|
|
153
328
|
parameters: Record<string, unknown>;
|
|
154
329
|
};
|
|
155
330
|
|
|
156
|
-
export type
|
|
157
|
-
|
|
158
|
-
|
|
331
|
+
export type FunctionCall = {
|
|
332
|
+
name: string;
|
|
333
|
+
arguments: string;
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
export type WebSearchToolFilters = {
|
|
337
|
+
allowed_domains?: string[];
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
export type WebSearchToolUserLocation = {
|
|
341
|
+
city?: string;
|
|
342
|
+
country?: string;
|
|
343
|
+
region?: string;
|
|
344
|
+
timezone?: string;
|
|
345
|
+
type: "approximate";
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
export type OpenAIWebSearchToolConfig = {
|
|
349
|
+
type: "web_search" | "web_search_2025_08_26";
|
|
350
|
+
filters?: WebSearchToolFilters;
|
|
351
|
+
search_context_size?: "low" | "medium" | "high";
|
|
352
|
+
user_location?: WebSearchToolUserLocation;
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
export type ComparisonFilter = {
|
|
356
|
+
key: string;
|
|
357
|
+
value: string | number | boolean;
|
|
358
|
+
operation: "eq" | "ne" | "gt" | "gte" | "lt" | "lte";
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
export type CompoundFilter = {
|
|
362
|
+
operator: "and" | "or";
|
|
363
|
+
operands: (ComparisonFilter | CompoundFilter)[];
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
export type RankingOptions = {
|
|
367
|
+
ranker?: "auto" | "default-2024-11-15";
|
|
368
|
+
score_threshold?: number;
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
export type FileSearchToolConfig = {
|
|
372
|
+
type: "file_search";
|
|
373
|
+
vector_store_ids: string[];
|
|
374
|
+
filters?: ComparisonFilter | CompoundFilter;
|
|
375
|
+
max_num_results?: number;
|
|
376
|
+
ranking_options?: RankingOptions;
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
export type CodeInterpreterToolConfig = {
|
|
380
|
+
type: "code_interpreter";
|
|
381
|
+
container?: Record<string, unknown>;
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
export type ImageGenerationToolConfig = {
|
|
385
|
+
type: "image_generation";
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
export type ShellToolConfig = {
|
|
389
|
+
type: "shell";
|
|
390
|
+
environment?: Record<string, unknown>;
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
export type ApplyPatchToolConfig = {
|
|
394
|
+
type: "apply_patch";
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
export type McpToolApprovalFilter = {
|
|
398
|
+
tool_names?: string[];
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
export type McpToolApproval = {
|
|
402
|
+
never?: McpToolApprovalFilter;
|
|
403
|
+
always?: McpToolApprovalFilter;
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
export type McpToolConfig = {
|
|
407
|
+
type: "mcp";
|
|
408
|
+
server_label: string;
|
|
409
|
+
server_url?: string;
|
|
410
|
+
server_description?: string;
|
|
411
|
+
connector_id?: string;
|
|
412
|
+
authorization?: string;
|
|
413
|
+
allowed_tools?: string[];
|
|
414
|
+
require_approval?: string | McpToolApproval;
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
export type BuiltInToolConfig =
|
|
418
|
+
| OpenAIWebSearchToolConfig
|
|
419
|
+
| FileSearchToolConfig
|
|
420
|
+
| CodeInterpreterToolConfig
|
|
421
|
+
| ImageGenerationToolConfig
|
|
422
|
+
| McpToolConfig
|
|
423
|
+
| ShellToolConfig
|
|
424
|
+
| ApplyPatchToolConfig;
|
|
425
|
+
|
|
426
|
+
export type FunctionTool = {
|
|
159
427
|
type: "function";
|
|
160
428
|
function: Function_;
|
|
161
429
|
};
|
|
162
430
|
|
|
163
|
-
export type
|
|
431
|
+
export type BuiltInTool = {
|
|
432
|
+
id: string;
|
|
164
433
|
name: string;
|
|
165
|
-
|
|
434
|
+
description: string;
|
|
435
|
+
provider: string;
|
|
436
|
+
type:
|
|
437
|
+
| "web_search"
|
|
438
|
+
| "file_search"
|
|
439
|
+
| "code_interpreter"
|
|
440
|
+
| "image_generation"
|
|
441
|
+
| "google_maps"
|
|
442
|
+
| "url_context"
|
|
443
|
+
| "mcp"
|
|
444
|
+
| "bash"
|
|
445
|
+
| "shell"
|
|
446
|
+
| "apply_patch"
|
|
447
|
+
| "text_editor";
|
|
448
|
+
config: BuiltInToolConfig;
|
|
166
449
|
};
|
|
167
450
|
|
|
451
|
+
export type Tool = FunctionTool | BuiltInTool;
|
|
452
|
+
|
|
168
453
|
export type SystemMessage = {
|
|
169
454
|
role: "system";
|
|
170
455
|
input_variables?: string[];
|
|
@@ -183,6 +468,7 @@ export type UserMessage = {
|
|
|
183
468
|
|
|
184
469
|
export type ToolCall = {
|
|
185
470
|
id: string;
|
|
471
|
+
tool_id?: string;
|
|
186
472
|
type: "function";
|
|
187
473
|
function: FunctionCall;
|
|
188
474
|
};
|
|
@@ -209,7 +495,7 @@ export type ToolMessage = {
|
|
|
209
495
|
role: "tool";
|
|
210
496
|
input_variables?: string[];
|
|
211
497
|
template_format?: TemplateFormat;
|
|
212
|
-
content
|
|
498
|
+
content?: Content[];
|
|
213
499
|
tool_call_id: string;
|
|
214
500
|
name?: string;
|
|
215
501
|
};
|
|
@@ -268,8 +554,11 @@ export type PromptTemplate = CompletionPromptTemplate | ChatPromptTemplate;
|
|
|
268
554
|
export type Model = {
|
|
269
555
|
api_type?: string;
|
|
270
556
|
provider: string;
|
|
557
|
+
model_config_display_name?: string;
|
|
558
|
+
base_model?: string;
|
|
271
559
|
name: string;
|
|
272
560
|
parameters: Record<string, unknown>;
|
|
561
|
+
display_params?: Record<string, string | boolean | null>;
|
|
273
562
|
};
|
|
274
563
|
|
|
275
564
|
export type Metadata = {
|
|
@@ -285,6 +574,10 @@ export type PromptBlueprint = {
|
|
|
285
574
|
prompt_template: PromptTemplate;
|
|
286
575
|
commit_message?: string;
|
|
287
576
|
metadata?: Metadata;
|
|
577
|
+
provider_base_url_name?: string;
|
|
578
|
+
report_id?: number;
|
|
579
|
+
inference_client_name?: string;
|
|
580
|
+
provider_id?: number;
|
|
288
581
|
};
|
|
289
582
|
|
|
290
583
|
export type PublishPromptTemplate = BasePromptTemplate &
|