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/dist/index.d.ts
CHANGED
|
@@ -42,14 +42,49 @@ interface GetPromptTemplateParams {
|
|
|
42
42
|
}
|
|
43
43
|
declare const templateFormat: readonly ["f-string", "jinja2"];
|
|
44
44
|
type TemplateFormat = (typeof templateFormat)[number];
|
|
45
|
+
type FileAnnotation = {
|
|
46
|
+
type: "file_citation";
|
|
47
|
+
index: number;
|
|
48
|
+
file_id: string;
|
|
49
|
+
filename: string;
|
|
50
|
+
};
|
|
51
|
+
type WebAnnotation = {
|
|
52
|
+
type: "url_citation";
|
|
53
|
+
title: string;
|
|
54
|
+
url: string;
|
|
55
|
+
start_index: number;
|
|
56
|
+
end_index: number;
|
|
57
|
+
cited_text?: string;
|
|
58
|
+
encrypted_index?: string;
|
|
59
|
+
};
|
|
60
|
+
type MapAnnotation = {
|
|
61
|
+
type: "map_citation";
|
|
62
|
+
title: string;
|
|
63
|
+
url: string;
|
|
64
|
+
place_id?: string;
|
|
65
|
+
start_index: number;
|
|
66
|
+
end_index: number;
|
|
67
|
+
cited_text?: string;
|
|
68
|
+
};
|
|
69
|
+
type ContainerFileAnnotation = {
|
|
70
|
+
type: "container_file_citation";
|
|
71
|
+
container_id: string;
|
|
72
|
+
start_index?: number;
|
|
73
|
+
end_index?: number;
|
|
74
|
+
filename?: string;
|
|
75
|
+
file_id?: string;
|
|
76
|
+
};
|
|
77
|
+
type Annotation = WebAnnotation | FileAnnotation | MapAnnotation | ContainerFileAnnotation;
|
|
45
78
|
type ImageUrl = {
|
|
46
79
|
url: string;
|
|
80
|
+
detail?: string;
|
|
47
81
|
};
|
|
48
82
|
type TextContent = {
|
|
49
83
|
id?: string;
|
|
50
84
|
type: "text";
|
|
51
85
|
text: string;
|
|
52
|
-
annotations?:
|
|
86
|
+
annotations?: Annotation[];
|
|
87
|
+
thought_signature?: string;
|
|
53
88
|
};
|
|
54
89
|
type ThinkingContent = {
|
|
55
90
|
id?: string;
|
|
@@ -62,15 +97,18 @@ type CodeContent = {
|
|
|
62
97
|
container_id?: string;
|
|
63
98
|
type: "code";
|
|
64
99
|
code: string;
|
|
100
|
+
language?: string;
|
|
65
101
|
};
|
|
66
102
|
type ImageContent = {
|
|
67
103
|
type: "image_url";
|
|
68
104
|
image_url: ImageUrl;
|
|
105
|
+
image_variable?: string;
|
|
69
106
|
};
|
|
70
107
|
type Media = {
|
|
71
108
|
title: string;
|
|
72
109
|
type: string;
|
|
73
|
-
url
|
|
110
|
+
url?: string;
|
|
111
|
+
format?: "base64" | "url" | "neither";
|
|
74
112
|
};
|
|
75
113
|
type MediaContent = {
|
|
76
114
|
type: "media";
|
|
@@ -80,22 +118,196 @@ type MediaVariable = {
|
|
|
80
118
|
type: "media_variable";
|
|
81
119
|
name: string;
|
|
82
120
|
};
|
|
83
|
-
type
|
|
121
|
+
type OutputMediaContent = {
|
|
122
|
+
type: "output_media";
|
|
123
|
+
id?: string;
|
|
124
|
+
url: string;
|
|
125
|
+
mime_type?: string;
|
|
126
|
+
media_type?: "image" | "video" | "audio";
|
|
127
|
+
provider_metadata?: Record<string, unknown>;
|
|
128
|
+
};
|
|
129
|
+
type ServerToolUseContent = {
|
|
130
|
+
type: "server_tool_use";
|
|
131
|
+
id: string;
|
|
132
|
+
name: string;
|
|
133
|
+
input?: Record<string, unknown>;
|
|
134
|
+
};
|
|
135
|
+
type WebSearchResult = {
|
|
136
|
+
type: "web_search_result";
|
|
137
|
+
url?: string;
|
|
138
|
+
title?: string;
|
|
139
|
+
encrypted_content?: string;
|
|
140
|
+
page_age?: string;
|
|
141
|
+
};
|
|
142
|
+
type WebSearchToolResultContent = {
|
|
143
|
+
type: "web_search_tool_result";
|
|
144
|
+
tool_use_id: string;
|
|
145
|
+
content?: WebSearchResult[];
|
|
146
|
+
};
|
|
147
|
+
type CodeExecutionResultContent = {
|
|
148
|
+
type: "code_execution_result";
|
|
149
|
+
output: string;
|
|
150
|
+
outcome?: string;
|
|
151
|
+
};
|
|
152
|
+
type McpListToolsContent = {
|
|
153
|
+
type: "mcp_list_tools";
|
|
154
|
+
id?: string;
|
|
155
|
+
server_label?: string;
|
|
156
|
+
tools?: Record<string, unknown>[];
|
|
157
|
+
error?: string | Record<string, unknown>;
|
|
158
|
+
};
|
|
159
|
+
type McpCallContent = {
|
|
160
|
+
type: "mcp_call";
|
|
161
|
+
id?: string;
|
|
162
|
+
name?: string;
|
|
163
|
+
server_label?: string;
|
|
164
|
+
arguments?: string;
|
|
165
|
+
output?: string;
|
|
166
|
+
error?: string | Record<string, unknown>;
|
|
167
|
+
approval_request_id?: string;
|
|
168
|
+
};
|
|
169
|
+
type McpApprovalRequestContent = {
|
|
170
|
+
type: "mcp_approval_request";
|
|
171
|
+
id?: string;
|
|
172
|
+
name?: string;
|
|
173
|
+
arguments?: string;
|
|
174
|
+
server_label?: string;
|
|
175
|
+
};
|
|
176
|
+
type McpApprovalResponseContent = {
|
|
177
|
+
type: "mcp_approval_response";
|
|
178
|
+
approval_request_id: string;
|
|
179
|
+
approve: boolean;
|
|
180
|
+
};
|
|
181
|
+
type BashCodeExecutionToolResultContent = {
|
|
182
|
+
type: "bash_code_execution_tool_result";
|
|
183
|
+
tool_use_id: string;
|
|
184
|
+
content?: Record<string, unknown>;
|
|
185
|
+
};
|
|
186
|
+
type TextEditorCodeExecutionToolResultContent = {
|
|
187
|
+
type: "text_editor_code_execution_tool_result";
|
|
188
|
+
tool_use_id: string;
|
|
189
|
+
content?: Record<string, unknown>;
|
|
190
|
+
};
|
|
191
|
+
type ShellCallContent = {
|
|
192
|
+
type: "shell_call";
|
|
193
|
+
id?: string;
|
|
194
|
+
call_id?: string;
|
|
195
|
+
action?: Record<string, unknown>;
|
|
196
|
+
status?: string;
|
|
197
|
+
};
|
|
198
|
+
type ShellCallOutputContent = {
|
|
199
|
+
type: "shell_call_output";
|
|
200
|
+
id?: string;
|
|
201
|
+
call_id?: string;
|
|
202
|
+
output?: Record<string, unknown>[];
|
|
203
|
+
status?: string;
|
|
204
|
+
};
|
|
205
|
+
type ApplyPatchCallContent = {
|
|
206
|
+
type: "apply_patch_call";
|
|
207
|
+
id?: string;
|
|
208
|
+
call_id?: string;
|
|
209
|
+
operation?: Record<string, unknown>;
|
|
210
|
+
status?: string;
|
|
211
|
+
};
|
|
212
|
+
type ApplyPatchCallOutputContent = {
|
|
213
|
+
type: "apply_patch_call_output";
|
|
214
|
+
id?: string;
|
|
215
|
+
call_id?: string;
|
|
216
|
+
output?: string;
|
|
217
|
+
status?: string;
|
|
218
|
+
};
|
|
219
|
+
type Content = TextContent | ThinkingContent | CodeContent | ImageContent | MediaContent | MediaVariable | OutputMediaContent | ServerToolUseContent | WebSearchToolResultContent | CodeExecutionResultContent | McpListToolsContent | McpCallContent | McpApprovalRequestContent | McpApprovalResponseContent | BashCodeExecutionToolResultContent | TextEditorCodeExecutionToolResultContent | ShellCallContent | ShellCallOutputContent | ApplyPatchCallContent | ApplyPatchCallOutputContent;
|
|
84
220
|
type Function_ = {
|
|
85
221
|
name: string;
|
|
86
222
|
description: string;
|
|
223
|
+
strict?: boolean;
|
|
87
224
|
parameters: Record<string, unknown>;
|
|
88
225
|
};
|
|
89
|
-
type
|
|
90
|
-
|
|
91
|
-
|
|
226
|
+
type FunctionCall = {
|
|
227
|
+
name: string;
|
|
228
|
+
arguments: string;
|
|
229
|
+
};
|
|
230
|
+
type WebSearchToolFilters = {
|
|
231
|
+
allowed_domains?: string[];
|
|
232
|
+
};
|
|
233
|
+
type WebSearchToolUserLocation = {
|
|
234
|
+
city?: string;
|
|
235
|
+
country?: string;
|
|
236
|
+
region?: string;
|
|
237
|
+
timezone?: string;
|
|
238
|
+
type: "approximate";
|
|
239
|
+
};
|
|
240
|
+
type OpenAIWebSearchToolConfig = {
|
|
241
|
+
type: "web_search" | "web_search_2025_08_26";
|
|
242
|
+
filters?: WebSearchToolFilters;
|
|
243
|
+
search_context_size?: "low" | "medium" | "high";
|
|
244
|
+
user_location?: WebSearchToolUserLocation;
|
|
245
|
+
};
|
|
246
|
+
type ComparisonFilter = {
|
|
247
|
+
key: string;
|
|
248
|
+
value: string | number | boolean;
|
|
249
|
+
operation: "eq" | "ne" | "gt" | "gte" | "lt" | "lte";
|
|
250
|
+
};
|
|
251
|
+
type CompoundFilter = {
|
|
252
|
+
operator: "and" | "or";
|
|
253
|
+
operands: (ComparisonFilter | CompoundFilter)[];
|
|
254
|
+
};
|
|
255
|
+
type RankingOptions = {
|
|
256
|
+
ranker?: "auto" | "default-2024-11-15";
|
|
257
|
+
score_threshold?: number;
|
|
258
|
+
};
|
|
259
|
+
type FileSearchToolConfig = {
|
|
260
|
+
type: "file_search";
|
|
261
|
+
vector_store_ids: string[];
|
|
262
|
+
filters?: ComparisonFilter | CompoundFilter;
|
|
263
|
+
max_num_results?: number;
|
|
264
|
+
ranking_options?: RankingOptions;
|
|
265
|
+
};
|
|
266
|
+
type CodeInterpreterToolConfig = {
|
|
267
|
+
type: "code_interpreter";
|
|
268
|
+
container?: Record<string, unknown>;
|
|
269
|
+
};
|
|
270
|
+
type ImageGenerationToolConfig = {
|
|
271
|
+
type: "image_generation";
|
|
272
|
+
};
|
|
273
|
+
type ShellToolConfig = {
|
|
274
|
+
type: "shell";
|
|
275
|
+
environment?: Record<string, unknown>;
|
|
276
|
+
};
|
|
277
|
+
type ApplyPatchToolConfig = {
|
|
278
|
+
type: "apply_patch";
|
|
279
|
+
};
|
|
280
|
+
type McpToolApprovalFilter = {
|
|
281
|
+
tool_names?: string[];
|
|
282
|
+
};
|
|
283
|
+
type McpToolApproval = {
|
|
284
|
+
never?: McpToolApprovalFilter;
|
|
285
|
+
always?: McpToolApprovalFilter;
|
|
286
|
+
};
|
|
287
|
+
type McpToolConfig = {
|
|
288
|
+
type: "mcp";
|
|
289
|
+
server_label: string;
|
|
290
|
+
server_url?: string;
|
|
291
|
+
server_description?: string;
|
|
292
|
+
connector_id?: string;
|
|
293
|
+
authorization?: string;
|
|
294
|
+
allowed_tools?: string[];
|
|
295
|
+
require_approval?: string | McpToolApproval;
|
|
296
|
+
};
|
|
297
|
+
type BuiltInToolConfig = OpenAIWebSearchToolConfig | FileSearchToolConfig | CodeInterpreterToolConfig | ImageGenerationToolConfig | McpToolConfig | ShellToolConfig | ApplyPatchToolConfig;
|
|
298
|
+
type FunctionTool = {
|
|
92
299
|
type: "function";
|
|
93
300
|
function: Function_;
|
|
94
301
|
};
|
|
95
|
-
type
|
|
302
|
+
type BuiltInTool = {
|
|
303
|
+
id: string;
|
|
96
304
|
name: string;
|
|
97
|
-
|
|
305
|
+
description: string;
|
|
306
|
+
provider: string;
|
|
307
|
+
type: "web_search" | "file_search" | "code_interpreter" | "image_generation" | "google_maps" | "url_context" | "mcp" | "bash" | "shell" | "apply_patch" | "text_editor";
|
|
308
|
+
config: BuiltInToolConfig;
|
|
98
309
|
};
|
|
310
|
+
type Tool = FunctionTool | BuiltInTool;
|
|
99
311
|
type SystemMessage = {
|
|
100
312
|
role: "system";
|
|
101
313
|
input_variables?: string[];
|
|
@@ -112,6 +324,7 @@ type UserMessage = {
|
|
|
112
324
|
};
|
|
113
325
|
type ToolCall = {
|
|
114
326
|
id: string;
|
|
327
|
+
tool_id?: string;
|
|
115
328
|
type: "function";
|
|
116
329
|
function: FunctionCall;
|
|
117
330
|
};
|
|
@@ -135,7 +348,7 @@ type ToolMessage = {
|
|
|
135
348
|
role: "tool";
|
|
136
349
|
input_variables?: string[];
|
|
137
350
|
template_format?: TemplateFormat;
|
|
138
|
-
content
|
|
351
|
+
content?: Content[];
|
|
139
352
|
tool_call_id: string;
|
|
140
353
|
name?: string;
|
|
141
354
|
};
|
|
@@ -177,8 +390,11 @@ type PromptTemplate = CompletionPromptTemplate | ChatPromptTemplate;
|
|
|
177
390
|
type Model = {
|
|
178
391
|
api_type?: string;
|
|
179
392
|
provider: string;
|
|
393
|
+
model_config_display_name?: string;
|
|
394
|
+
base_model?: string;
|
|
180
395
|
name: string;
|
|
181
396
|
parameters: Record<string, unknown>;
|
|
397
|
+
display_params?: Record<string, string | boolean | null>;
|
|
182
398
|
};
|
|
183
399
|
type Metadata = {
|
|
184
400
|
model?: Model;
|
|
@@ -191,6 +407,10 @@ type PromptBlueprint = {
|
|
|
191
407
|
prompt_template: PromptTemplate;
|
|
192
408
|
commit_message?: string;
|
|
193
409
|
metadata?: Metadata;
|
|
410
|
+
provider_base_url_name?: string;
|
|
411
|
+
report_id?: number;
|
|
412
|
+
inference_client_name?: string;
|
|
413
|
+
provider_id?: number;
|
|
194
414
|
};
|
|
195
415
|
type PublishPromptTemplate = BasePromptTemplate & PromptBlueprint & {
|
|
196
416
|
release_labels?: string[];
|