@ai-sdk/openai 4.0.90 → 4.0.92
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/CHANGELOG.md +24 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +195 -102
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +11 -2
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +241 -153
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +35 -0
- package/package.json +3 -3
- package/src/embedding/openai-embedding-model.ts +2 -1
- package/src/openai-batch.ts +3 -1
- package/src/openai-decision-model.ts +2 -0
- package/src/responses/convert-to-openai-responses-input.ts +89 -0
- package/src/responses/map-openai-responses-annotation.ts +75 -0
- package/src/responses/openai-responses-api.ts +8 -0
- package/src/responses/openai-responses-language-model.ts +174 -136
- package/src/responses/openai-responses-provider-metadata.ts +4 -0
package/dist/internal/index.d.ts
CHANGED
|
@@ -170,7 +170,7 @@ export declare class OpenAIEmbeddingModel implements EmbeddingModelV4 {
|
|
|
170
170
|
}): OpenAIEmbeddingModel;
|
|
171
171
|
get provider(): string;
|
|
172
172
|
constructor(modelId: OpenAIEmbeddingModelId, config: OpenAIConfig);
|
|
173
|
-
doEmbed({ values, headers, abortSignal, providerOptions }: Parameters<EmbeddingModelV4['doEmbed']>[0]): Promise<Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>>;
|
|
173
|
+
doEmbed({ values, dimensions, headers, abortSignal, providerOptions }: Parameters<EmbeddingModelV4['doEmbed']>[0]): Promise<Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>>;
|
|
174
174
|
}
|
|
175
175
|
//#endregion
|
|
176
176
|
//#region src/image/openai-image-model-options.d.ts
|
|
@@ -449,7 +449,7 @@ declare const openaiResponsesLocalShellCallSchema: z.ZodObject<{
|
|
|
449
449
|
}, z.core.$strip>;
|
|
450
450
|
}, z.core.$strip>;
|
|
451
451
|
type OpenAIResponsesInput = Array<OpenAIResponsesInputItem>;
|
|
452
|
-
type OpenAIResponsesInputItem = OpenAIResponsesSystemMessage | OpenAIResponsesUserMessage | OpenAIResponsesAssistantMessage | OpenAIResponsesFunctionCall | OpenAIResponsesFunctionCallOutput | OpenAIResponsesProgram | OpenAIResponsesProgramOutput | OpenAIResponsesCustomToolCall | OpenAIResponsesCustomToolCallOutput | OpenAIResponsesMcpApprovalResponse | OpenAIResponsesComputerCall | OpenAIResponsesComputerCallOutput | OpenAIResponsesLocalShellCall | OpenAIResponsesLocalShellCallOutput | OpenAIResponsesShellCall | OpenAIResponsesShellCallOutput | OpenAIResponsesApplyPatchCall | OpenAIResponsesApplyPatchCallOutput | OpenAIResponsesToolSearchCall | OpenAIResponsesToolSearchOutput | OpenAIResponsesReasoning | OpenAIResponsesItemReference | OpenAIResponsesCompactionItem | OpenAIResponsesConfigurationUpdate | OpenAIResponsesCompactionTrigger;
|
|
452
|
+
type OpenAIResponsesInputItem = OpenAIResponsesSystemMessage | OpenAIResponsesUserMessage | OpenAIResponsesAssistantMessage | OpenAIResponsesFunctionCall | OpenAIResponsesFunctionCallOutput | OpenAIResponsesProgram | OpenAIResponsesProgramOutput | OpenAIResponsesCustomToolCall | OpenAIResponsesCustomToolCallOutput | OpenAIResponsesMcpApprovalResponse | OpenAIResponsesComputerCall | OpenAIResponsesComputerCallOutput | OpenAIResponsesLocalShellCall | OpenAIResponsesLocalShellCallOutput | OpenAIResponsesShellCall | OpenAIResponsesShellCallOutput | OpenAIResponsesApplyPatchCall | OpenAIResponsesApplyPatchCallOutput | OpenAIResponsesToolSearchCall | OpenAIResponsesToolSearchOutput | OpenAIResponsesWebSearchCall | OpenAIResponsesReasoning | OpenAIResponsesItemReference | OpenAIResponsesCompactionItem | OpenAIResponsesConfigurationUpdate | OpenAIResponsesCompactionTrigger;
|
|
453
453
|
type OpenAIResponsesIncludeValue = 'web_search_call.action.sources' | 'web_search_call.results' | 'code_interpreter_call.outputs' | 'computer_call_output.output.image_url' | 'file_search_call.results' | 'message.input_image.image_url' | 'message.output_text.logprobs' | 'reasoning.encrypted_content';
|
|
454
454
|
type OpenAIResponsesIncludeOptions = Array<OpenAIResponsesIncludeValue> | undefined | null;
|
|
455
455
|
type OpenAIResponsesSystemMessage = {
|
|
@@ -584,6 +584,12 @@ type OpenAIResponsesProgramOutput = {
|
|
|
584
584
|
result: string;
|
|
585
585
|
status: 'completed' | 'incomplete';
|
|
586
586
|
};
|
|
587
|
+
type OpenAIResponsesWebSearchCall = {
|
|
588
|
+
type: 'web_search_call';
|
|
589
|
+
id: string;
|
|
590
|
+
status: 'completed';
|
|
591
|
+
action: OpenAIResponsesWebSearchAction;
|
|
592
|
+
};
|
|
587
593
|
type OpenAIResponsesCustomToolCall = {
|
|
588
594
|
type: 'custom_tool_call';
|
|
589
595
|
id?: string;
|
|
@@ -2039,6 +2045,9 @@ export type OpenaiResponsesTextProviderMetadata = {
|
|
|
2039
2045
|
openai: ResponsesTextProviderMetadata;
|
|
2040
2046
|
};
|
|
2041
2047
|
export type ResponsesSourceDocumentProviderMetadata = {
|
|
2048
|
+
type: 'file_search';
|
|
2049
|
+
fileId: string;
|
|
2050
|
+
} | {
|
|
2042
2051
|
type: 'file_citation';
|
|
2043
2052
|
fileId: string;
|
|
2044
2053
|
index: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["TranscriptionModelV4StreamOptions","_$__openai_responses_api0.OpenAIResponsesTool","_$__openai_responses_api0.OpenAIResponsesAllowedTool","_$__openai_responses_api0.OpenAIResponsesInput"],"sources":["../../src/chat/openai-chat-language-model-options.ts","../../src/chat/openai-chat-language-model.ts","../../src/completion/openai-completion-language-model-options.ts","../../src/completion/openai-completion-language-model.ts","../../src/openai-config.ts","../../src/embedding/openai-embedding-model-options.ts","../../src/embedding/openai-embedding-model.ts","../../src/image/openai-image-model-options.ts","../../src/image/openai-image-model.ts","../../src/transcription/openai-transcription-model-options.ts","../../src/transcription/openai-transcription-model.ts","../../src/speech/openai-speech-model-options.ts","../../src/speech/openai-speech-model.ts","../../src/responses/openai-responses-api.ts","../../src/tool/web-search.ts","../../src/responses/openai-responses-language-model-options.ts","../../src/responses/openai-responses-language-model.ts","../../src/responses/openai-responses-provider-metadata.ts","../../src/tool/apply-patch.ts","../../src/tool/code-interpreter.ts","../../src/tool/file-search.ts","../../src/tool/image-generation.ts","../../src/tool/programmatic-tool-calling.ts","../../src/tool/web-search-preview.ts"],"mappings":";;;;YAQY;qBAsEC,iEAA8B;;;;;;;;;;;;;;;;;;;;;;;YAwJ/B,iCAAiC,mBACpC;;;KCnLJ;EACH;EACA,gBAAgB;EAChB,MAAM;IAAW;IAAiB;;EAClC,QAAQ;;qBAGG,mCAAmC;WACrC;WAEA,SAAS;WAET;;;mBAIQ;UAET,oBAAoB,OAAO;;;;UAO3B,sBAAsB;IAC5B,SAAS;IACT,QAAQ;MACT;EAIW,YAAA,SAAS,mBAAmB,QAAQ;MAK5C;UAIU;EA6SR,WACJ,SAAS,6BACR,QAAQ;EA+FL,SACJ,SAAS,6BACR,QAAQ;;;;YCreD;qBAKC,uEAAoC;;cAApC;;;;;YAiDD,uCAAuC,mBAC1C;;;KCpBJ;EACH;EACA,gBAAgB;EAChB,MAAM;IAAW;IAAiB;;EAClC,QAAQ;;qBAGG,yCAAyC;WAC3C;WAEA,SAAS;mBAED;cAEL;UAIJ,oBAAoB,OAAO;;;;UAO3B,sBAAsB;IAC5B,SAAS;IACT,QAAQ;MACT;EAKC,YAAA,SAAS,yBACT,QAAQ;MAMN;WAIK,eAAe,eAAe;UAIzB;EA2FR,WACJ,SAAS,6BACR,QAAQ;EAgDL,SACJ,SAAS,6BACR,QAAQ;;;;KCrOR,gBAAgB;KAEhB,yBAAyB,KAAK,QAAQ;EACzC,iBAAiB,iBAAiB;;KAGxB;EACV;EACA;EACA,MAAM;IAAW;IAAiB;;EAClC,gBAAgB;EAChB,QAAQ;EACR,YAAY;EACZ;;;;;;;EAOA;;;;;;;EAOA;;;;;;;;;EASA;;iBAGc,0CACd,QAAQ,yBACP;;;YCvCS;qBAMC,8DAA2B;;;;YAkB5B,8BAA8B,mBACjC;;;qBCVI,gCAAgC;WAClC;WACA,SAAS;WACT;YACC;WACD;mBAEQ;UAET,oBAAoB,OAAO;;;;UAO3B,sBAAsB;IAC5B,SAAS;IACT,QAAQ;MACT;MAIG;EAIQ,YAAA,SAAS,wBAAwB,QAAQ;EAK/C,UACJ,QACA,SACA,aACA,mBACC,WAAW,kCAAkC,QAC9C,QAAQ,WAAW;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["TranscriptionModelV4StreamOptions","_$__openai_responses_api0.OpenAIResponsesTool","_$__openai_responses_api0.OpenAIResponsesAllowedTool","_$__openai_responses_api0.OpenAIResponsesInput"],"sources":["../../src/chat/openai-chat-language-model-options.ts","../../src/chat/openai-chat-language-model.ts","../../src/completion/openai-completion-language-model-options.ts","../../src/completion/openai-completion-language-model.ts","../../src/openai-config.ts","../../src/embedding/openai-embedding-model-options.ts","../../src/embedding/openai-embedding-model.ts","../../src/image/openai-image-model-options.ts","../../src/image/openai-image-model.ts","../../src/transcription/openai-transcription-model-options.ts","../../src/transcription/openai-transcription-model.ts","../../src/speech/openai-speech-model-options.ts","../../src/speech/openai-speech-model.ts","../../src/responses/openai-responses-api.ts","../../src/tool/web-search.ts","../../src/responses/openai-responses-language-model-options.ts","../../src/responses/openai-responses-language-model.ts","../../src/responses/openai-responses-provider-metadata.ts","../../src/tool/apply-patch.ts","../../src/tool/code-interpreter.ts","../../src/tool/file-search.ts","../../src/tool/image-generation.ts","../../src/tool/programmatic-tool-calling.ts","../../src/tool/web-search-preview.ts"],"mappings":";;;;YAQY;qBAsEC,iEAA8B;;;;;;;;;;;;;;;;;;;;;;;YAwJ/B,iCAAiC,mBACpC;;;KCnLJ;EACH;EACA,gBAAgB;EAChB,MAAM;IAAW;IAAiB;;EAClC,QAAQ;;qBAGG,mCAAmC;WACrC;W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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAUrC,EAAA,KAAA;cA0BI,qCAAmC,EAAA;;;;;;;;;;;;GAYvC,EAAA,KAAA;KAEU,uBAAuB,MAAM;KAE7B,2BACR,+BACA,6BACA,kCACA,8BACA,oCACA,yBACA,+BACA,gCACA,sCACA,qCACA,8BACA,oCACA,gCACA,sCACA,2BACA,iCACA,gCACA,sCACA,gCACA,kCACA,+BACA,2BACA,+BACA,gCACA,qCACA;KAEQ;KAUA,gCACR,MAAM;KAmBE;EACV;EACA;EACA,kBAEI;IACE;IACA;IACA;MAA4B;;;;KAIxB;EACV;EACA;EACA,SAAS;IAEH;IACA;IACA;MAA4B;;;IAG5B;IACA;IACA;MAA4B;;;IAG5B;IACA;IACA;MAA4B;;;IAG5B;IACA;IACA;MAA4B;;;IAG5B;IACA;IACA;IACA;MAA4B;;;IAG5B;IACA;IACA;MAA4B;;;;KAKxB;EACV;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA,SAAS;;KAGC;EACV;EACA;EACA,iBAEI;IAEM;IACA;IACA;MAA4B;;;IAG5B;IACA;IACA;MAA4B;;;IAG5B;IACA;IACA;MAA4B;;;IAG5B;IACA;IACA;IACA;MAA4B;;;IAG5B;IACA;IACA;MAA4B;;;IAG5B;IACA;IACA;MAA4B;;;EAGtC,SAAS;;KAGC;EACN;;EACA;EAAiB;;KAEX;EACV;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA,QAAQ;;KAGE;EACV;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA,QAAQ;;KAGE;EACV;EACA;EACA;;KAOU,8BAA8B,mBACjC;KAGG;EACV;EACA;EACA;IACE;IACA;IACA;IACA;;EAEF,6BAA6B;IAC3B;IACA;IACA;;;KAIQ,gCAAgC,mBACnC;KAGG;EACV;EACA;EACA;;;;;KAMU;EACV;EACA;EACA;EACA;EACA;IACE;IACA;IACA;;;KAIQ;EACV;EACA;EACA;EACA;EACA;EACA,QAAQ;IACN;IACA;IACA;MAAW;;MAAsB;MAAc;;;;KAIvC;EACV;EACA;EACA;EACA;EACA;IAEM;IACA;IACA;;IAGA;IACA;;IAGA;IACA;IACA;;;KAII;EACV;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA,OAAO,MAAM;;KAGH;EACV;EACA;;KAGU;EACV;EACA;EACA;;KAGU;EACV;EACA;IACE;;;KAIQ;EACV;;;;;KAMU;;;;EAIV;;;;EAKA;;;;EAKA;;;;;KAMU;;;;EAIV;;;;EAKA,SAAS,MACL,gDACA;;KAIM;EACV;EACA;EACA;EACA,YAAY;EACZ;EACA;EACA;EACA,kBAAkB;EAClB,gBAAgB;;;;;;KAON;EACN;EAAkB;;EAClB;EAAgB;;EAChB;EAAa;;EAEb,MAAM,QACJ;;KAKI,sBACR;EAEE;EACA;EACA;EACA,OAAO,MAAM;;EAGb;;EAGA;;EAGA;EACA;EACA;IAEM;IACA;;EAGN;EACA;IAEM;IACA;IACA;IACA;IACA;;;EAKN;EACA;EACA;IAEM;IACA;IACA;IACA;IACA;;;EAKN;EACA;IAAsB;IAAc;;;EAGpC;EACA;EACA;EACA;IACM;IAAiB;;EAEvB,SACI,gDACA;;EAIJ;EACA;EACA;EACA;EACA;IAEM;IACA;;EAGN;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;EAaA;EACA;EACA;IAGM;IACA;;EAGN;EACA;EACA,SAAS;EACT;IAIM;MAAU;;;EAGhB;EACA;;EAGA;EACA;EACA;EACA;EACA;IAEM;IACA;IACA;;IAGA;;;EAIN;;EAGA;EACA;IAEM;IACA;IACA;IACA;MACM;;MAEA;MACA;MACA,iBAAiB;QACf;QACA;QACA;;;IAGR,SAAS;MAEH;MACA;MACA;;MAGA;MACA;MACA;M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X,OAAM,yDAAwB;;;;EAVpB;;;;qBCtHC,qEAAkC;;;;qBASlC,sEAAmC;;;;qBAwCnC,gEAAuB,6DAAA;;;;EA1B1B;;;;EAKO;;;;;EAML;;;;EAKA;;;;qBCxCC,6DAA0B;;;;;;;;;;qBAiB1B,8DAA2B,WAAA;qBA4B3B,mDAAgB;;;;;EAUrB;;;;IAIE;;;;IAKA;;;;;IAMA;;;;IAKA;;;;;IAMA;;;;IAKA;;;;IAKA;;;;;;;;;EAUc;;;;EAKL;;;;IAIb;;;;IAIA;;;;IAIA;;;;IAIA;;;;IAIA"}
|
package/dist/internal/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APICallError, InvalidPromptError, InvalidResponseDataError, TooManyEmbeddingValuesForCallError, UnsupportedFunctionalityError, isJSONObject } from "@ai-sdk/provider";
|
|
2
|
-
import { EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL, StreamingToolCallTracker, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, connectToWebSocket, convertBase64ToUint8Array, convertToBase64, convertToFormData, createBinaryResponseHandler, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, createLanguageModelResponseMetadata, createLanguageModelResponseMetadata as getResponseMetadata, createNullLanguageModelUsage, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createProviderExecutedToolFactory, createProviderStreamError, createToolNameMapping, downloadBlob, experimental_toolCaller, generateId, getTopLevelMediaType, isCustomReasoning, isNonNullable, isRecord, lazySchema, mediaTypeToExtension, parseJSON, parseProviderOptions, postFormDataToApi, postJsonToApi, resolveFullMediaType, resolveProviderReference, safeParseJSON, serializeModelOptions, toWebSocketUrl, validateTypes, waitForWebSocketBufferDrain, zodSchema } from "@ai-sdk/provider-utils";
|
|
2
|
+
import { EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL, StreamingToolCallTracker, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, connectToWebSocket, convertBase64ToUint8Array, convertToBase64, convertToFormData, createBinaryResponseHandler, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, createLanguageModelResponseMetadata, createLanguageModelResponseMetadata as getResponseMetadata, createNullLanguageModelUsage, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createProviderExecutedToolFactory, createProviderStreamError, createToolNameMapping, downloadBlob, experimental_toolCaller, generateId, getTopLevelMediaType, isCustomReasoning, isNonNullable, isRecord, lazySchema, mediaTypeToExtension, parseJSON, parseProviderOptions, postFormDataToApi, postJsonToApi, resolveFullMediaType, resolveProviderReference, safeParseJSON, safeValidateTypes, serializeModelOptions, toWebSocketUrl, validateTypes, waitForWebSocketBufferDrain, zodSchema } from "@ai-sdk/provider-utils";
|
|
3
3
|
import { z } from "zod/v4";
|
|
4
4
|
//#region src/openai-error.ts
|
|
5
5
|
const openaiErrorDataSchema = z.object({ error: z.object({
|
|
@@ -1743,7 +1743,7 @@ var OpenAIEmbeddingModel = class OpenAIEmbeddingModel {
|
|
|
1743
1743
|
this.modelId = modelId;
|
|
1744
1744
|
this.config = config;
|
|
1745
1745
|
}
|
|
1746
|
-
async doEmbed({ values, headers, abortSignal, providerOptions }) {
|
|
1746
|
+
async doEmbed({ values, dimensions, headers, abortSignal, providerOptions }) {
|
|
1747
1747
|
if (values.length > this.maxEmbeddingsPerCall) throw new TooManyEmbeddingValuesForCallError({
|
|
1748
1748
|
provider: this.provider,
|
|
1749
1749
|
modelId: this.modelId,
|
|
@@ -1765,7 +1765,7 @@ var OpenAIEmbeddingModel = class OpenAIEmbeddingModel {
|
|
|
1765
1765
|
model: this.modelId,
|
|
1766
1766
|
input: values,
|
|
1767
1767
|
encoding_format: "float",
|
|
1768
|
-
dimensions: openaiOptions.dimensions,
|
|
1768
|
+
dimensions: openaiOptions.dimensions ?? dimensions,
|
|
1769
1769
|
user: openaiOptions.user
|
|
1770
1770
|
},
|
|
1771
1771
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
@@ -3243,6 +3243,59 @@ const programmaticToolCalling = () => experimental_toolCaller(programmaticToolCa
|
|
|
3243
3243
|
}
|
|
3244
3244
|
});
|
|
3245
3245
|
//#endregion
|
|
3246
|
+
//#region src/tool/web-search.ts
|
|
3247
|
+
const webSearchArgsSchema = lazySchema(() => zodSchema(z.object({
|
|
3248
|
+
externalWebAccess: z.boolean().optional(),
|
|
3249
|
+
filters: z.object({
|
|
3250
|
+
allowedDomains: z.array(z.string()).optional(),
|
|
3251
|
+
blockedDomains: z.array(z.string()).optional()
|
|
3252
|
+
}).optional(),
|
|
3253
|
+
searchContextSize: z.enum([
|
|
3254
|
+
"low",
|
|
3255
|
+
"medium",
|
|
3256
|
+
"high"
|
|
3257
|
+
]).optional(),
|
|
3258
|
+
userLocation: z.object({
|
|
3259
|
+
type: z.literal("approximate"),
|
|
3260
|
+
country: z.string().optional(),
|
|
3261
|
+
city: z.string().optional(),
|
|
3262
|
+
region: z.string().optional(),
|
|
3263
|
+
timezone: z.string().optional()
|
|
3264
|
+
}).optional()
|
|
3265
|
+
})));
|
|
3266
|
+
const webSearchInputSchema = lazySchema(() => zodSchema(z.object({})));
|
|
3267
|
+
const webSearchOutputSchema = lazySchema(() => zodSchema(z.object({
|
|
3268
|
+
action: z.discriminatedUnion("type", [
|
|
3269
|
+
z.object({
|
|
3270
|
+
type: z.literal("search"),
|
|
3271
|
+
query: z.string().optional(),
|
|
3272
|
+
queries: z.array(z.string()).optional()
|
|
3273
|
+
}),
|
|
3274
|
+
z.object({
|
|
3275
|
+
type: z.literal("openPage"),
|
|
3276
|
+
url: z.string().nullish()
|
|
3277
|
+
}),
|
|
3278
|
+
z.object({
|
|
3279
|
+
type: z.literal("findInPage"),
|
|
3280
|
+
url: z.string().nullish(),
|
|
3281
|
+
pattern: z.string().nullish()
|
|
3282
|
+
})
|
|
3283
|
+
]).optional(),
|
|
3284
|
+
sources: z.array(z.discriminatedUnion("type", [z.object({
|
|
3285
|
+
type: z.literal("url"),
|
|
3286
|
+
url: z.string()
|
|
3287
|
+
}), z.object({
|
|
3288
|
+
type: z.literal("api"),
|
|
3289
|
+
name: z.string()
|
|
3290
|
+
})])).optional()
|
|
3291
|
+
})));
|
|
3292
|
+
const webSearchToolFactory = createProviderExecutedToolFactory({
|
|
3293
|
+
id: "openai.web_search",
|
|
3294
|
+
inputSchema: webSearchInputSchema,
|
|
3295
|
+
outputSchema: webSearchOutputSchema
|
|
3296
|
+
});
|
|
3297
|
+
const webSearch = (args = {}) => webSearchToolFactory(args);
|
|
3298
|
+
//#endregion
|
|
3246
3299
|
//#region src/responses/expand-parallel-tool-call.ts
|
|
3247
3300
|
const parallelToolName = "parallel";
|
|
3248
3301
|
const recipientNamePrefix = "functions.";
|
|
@@ -3305,6 +3358,47 @@ function mapToolCaller(caller) {
|
|
|
3305
3358
|
caller_id: caller.callerId
|
|
3306
3359
|
} : caller;
|
|
3307
3360
|
}
|
|
3361
|
+
async function convertWebSearchToolResultOutput({ output, id }) {
|
|
3362
|
+
if (output.type !== "json") return;
|
|
3363
|
+
const validation = await safeValidateTypes({
|
|
3364
|
+
value: output.value,
|
|
3365
|
+
schema: webSearchOutputSchema
|
|
3366
|
+
});
|
|
3367
|
+
if (!validation.success || validation.value.action == null) return;
|
|
3368
|
+
const { action, sources } = validation.value;
|
|
3369
|
+
switch (action.type) {
|
|
3370
|
+
case "search": return {
|
|
3371
|
+
type: "web_search_call",
|
|
3372
|
+
id,
|
|
3373
|
+
status: "completed",
|
|
3374
|
+
action: {
|
|
3375
|
+
type: "search",
|
|
3376
|
+
...action.query != null && { query: action.query },
|
|
3377
|
+
...action.queries != null && { queries: action.queries },
|
|
3378
|
+
...sources != null && { sources }
|
|
3379
|
+
}
|
|
3380
|
+
};
|
|
3381
|
+
case "openPage": return {
|
|
3382
|
+
type: "web_search_call",
|
|
3383
|
+
id,
|
|
3384
|
+
status: "completed",
|
|
3385
|
+
action: {
|
|
3386
|
+
type: "open_page",
|
|
3387
|
+
url: action.url
|
|
3388
|
+
}
|
|
3389
|
+
};
|
|
3390
|
+
case "findInPage": return {
|
|
3391
|
+
type: "web_search_call",
|
|
3392
|
+
id,
|
|
3393
|
+
status: "completed",
|
|
3394
|
+
action: {
|
|
3395
|
+
type: "find_in_page",
|
|
3396
|
+
url: action.url,
|
|
3397
|
+
pattern: action.pattern
|
|
3398
|
+
}
|
|
3399
|
+
};
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3308
3402
|
async function convertFunctionToolResultOutput({ output, toolName, outputSchemaToolNames, promptCacheBreakpoint, providerOptionsName, warnings }) {
|
|
3309
3403
|
const hasOutputSchema = outputSchemaToolNames?.has(toolName);
|
|
3310
3404
|
const convertScalarOutput = (value) => promptCacheBreakpoint == null ? value : [{
|
|
@@ -3822,6 +3916,24 @@ async function convertToOpenAIResponsesInput({ prompt, toolNameMapping, systemMe
|
|
|
3822
3916
|
if (part.output.type === "execution-denied" || part.output.type === "json" && typeof part.output.value === "object" && part.output.value != null && "type" in part.output.value && part.output.value.type === "execution-denied") break;
|
|
3823
3917
|
if (hasConversation) break;
|
|
3824
3918
|
const resolvedResultToolName = toolNameMapping.toProviderToolName(part.toolName);
|
|
3919
|
+
if (resolvedResultToolName === "web_search" || resolvedResultToolName === "web_search_preview") {
|
|
3920
|
+
const itemId = (part.providerOptions?.[providerOptionsName])?.itemId ?? part.toolCallId;
|
|
3921
|
+
if (store) {
|
|
3922
|
+
input.push({
|
|
3923
|
+
type: "item_reference",
|
|
3924
|
+
id: itemId
|
|
3925
|
+
});
|
|
3926
|
+
break;
|
|
3927
|
+
}
|
|
3928
|
+
const webSearchCall = await convertWebSearchToolResultOutput({
|
|
3929
|
+
output: part.output,
|
|
3930
|
+
id: itemId
|
|
3931
|
+
});
|
|
3932
|
+
if (webSearchCall != null) {
|
|
3933
|
+
input.push(webSearchCall);
|
|
3934
|
+
break;
|
|
3935
|
+
}
|
|
3936
|
+
}
|
|
3825
3937
|
if (part.toolName === toolSearchToolName) {
|
|
3826
3938
|
const itemId = part.providerOptions?.[providerOptionsName]?.itemId ?? part.providerMetadata?.[providerOptionsName]?.itemId ?? part.toolCallId;
|
|
3827
3939
|
if (store) input.push({
|
|
@@ -4257,6 +4369,40 @@ const openaiResponsesReasoningProviderOptionsSchema = z.object({
|
|
|
4257
4369
|
reasoningEncryptedContent: z.string().nullish()
|
|
4258
4370
|
});
|
|
4259
4371
|
//#endregion
|
|
4372
|
+
//#region src/responses/map-openai-responses-annotation.ts
|
|
4373
|
+
function mapOpenAIResponsesAnnotationSource(annotation, providerOptionsName, id) {
|
|
4374
|
+
if (annotation.type === "url_citation") return {
|
|
4375
|
+
type: "source",
|
|
4376
|
+
sourceType: "url",
|
|
4377
|
+
id,
|
|
4378
|
+
url: annotation.url,
|
|
4379
|
+
title: annotation.title
|
|
4380
|
+
};
|
|
4381
|
+
const filename = annotation.type === "file_path" ? annotation.file_id : annotation.filename;
|
|
4382
|
+
return {
|
|
4383
|
+
type: "source",
|
|
4384
|
+
sourceType: "document",
|
|
4385
|
+
id,
|
|
4386
|
+
mediaType: annotation.type === "file_path" ? "application/octet-stream" : "text/plain",
|
|
4387
|
+
title: filename,
|
|
4388
|
+
filename,
|
|
4389
|
+
providerMetadata: { [providerOptionsName]: {
|
|
4390
|
+
type: annotation.type,
|
|
4391
|
+
fileId: annotation.file_id,
|
|
4392
|
+
...annotation.type === "container_file_citation" ? { containerId: annotation.container_id } : { index: annotation.index }
|
|
4393
|
+
} }
|
|
4394
|
+
};
|
|
4395
|
+
}
|
|
4396
|
+
function mapOpenAIResponsesCitations(annotations, providerOptionsName) {
|
|
4397
|
+
return annotations.flatMap((annotation) => annotation.type === "file_path" ? [] : [{
|
|
4398
|
+
source: mapOpenAIResponsesAnnotationSource(annotation, providerOptionsName, annotation.type === "url_citation" ? annotation.url : annotation.file_id),
|
|
4399
|
+
..."start_index" in annotation ? {
|
|
4400
|
+
startIndex: annotation.start_index,
|
|
4401
|
+
endIndex: annotation.end_index
|
|
4402
|
+
} : {}
|
|
4403
|
+
}]);
|
|
4404
|
+
}
|
|
4405
|
+
//#endregion
|
|
4260
4406
|
//#region src/responses/map-openai-responses-finish-reason.ts
|
|
4261
4407
|
function mapOpenAIResponseFinishReason({ finishReason, hasFunctionCall }) {
|
|
4262
4408
|
switch (finishReason) {
|
|
@@ -5472,59 +5618,6 @@ createProviderExecutedToolFactory({
|
|
|
5472
5618
|
outputSchema: mcpOutputSchema
|
|
5473
5619
|
});
|
|
5474
5620
|
//#endregion
|
|
5475
|
-
//#region src/tool/web-search.ts
|
|
5476
|
-
const webSearchArgsSchema = lazySchema(() => zodSchema(z.object({
|
|
5477
|
-
externalWebAccess: z.boolean().optional(),
|
|
5478
|
-
filters: z.object({
|
|
5479
|
-
allowedDomains: z.array(z.string()).optional(),
|
|
5480
|
-
blockedDomains: z.array(z.string()).optional()
|
|
5481
|
-
}).optional(),
|
|
5482
|
-
searchContextSize: z.enum([
|
|
5483
|
-
"low",
|
|
5484
|
-
"medium",
|
|
5485
|
-
"high"
|
|
5486
|
-
]).optional(),
|
|
5487
|
-
userLocation: z.object({
|
|
5488
|
-
type: z.literal("approximate"),
|
|
5489
|
-
country: z.string().optional(),
|
|
5490
|
-
city: z.string().optional(),
|
|
5491
|
-
region: z.string().optional(),
|
|
5492
|
-
timezone: z.string().optional()
|
|
5493
|
-
}).optional()
|
|
5494
|
-
})));
|
|
5495
|
-
const webSearchInputSchema = lazySchema(() => zodSchema(z.object({})));
|
|
5496
|
-
const webSearchOutputSchema = lazySchema(() => zodSchema(z.object({
|
|
5497
|
-
action: z.discriminatedUnion("type", [
|
|
5498
|
-
z.object({
|
|
5499
|
-
type: z.literal("search"),
|
|
5500
|
-
query: z.string().optional(),
|
|
5501
|
-
queries: z.array(z.string()).optional()
|
|
5502
|
-
}),
|
|
5503
|
-
z.object({
|
|
5504
|
-
type: z.literal("openPage"),
|
|
5505
|
-
url: z.string().nullish()
|
|
5506
|
-
}),
|
|
5507
|
-
z.object({
|
|
5508
|
-
type: z.literal("findInPage"),
|
|
5509
|
-
url: z.string().nullish(),
|
|
5510
|
-
pattern: z.string().nullish()
|
|
5511
|
-
})
|
|
5512
|
-
]).optional(),
|
|
5513
|
-
sources: z.array(z.discriminatedUnion("type", [z.object({
|
|
5514
|
-
type: z.literal("url"),
|
|
5515
|
-
url: z.string()
|
|
5516
|
-
}), z.object({
|
|
5517
|
-
type: z.literal("api"),
|
|
5518
|
-
name: z.string()
|
|
5519
|
-
})])).optional()
|
|
5520
|
-
})));
|
|
5521
|
-
const webSearchToolFactory = createProviderExecutedToolFactory({
|
|
5522
|
-
id: "openai.web_search",
|
|
5523
|
-
inputSchema: webSearchInputSchema,
|
|
5524
|
-
outputSchema: webSearchOutputSchema
|
|
5525
|
-
});
|
|
5526
|
-
const webSearch = (args = {}) => webSearchToolFactory(args);
|
|
5527
|
-
//#endregion
|
|
5528
5621
|
//#region src/tool/web-search-preview.ts
|
|
5529
5622
|
const webSearchPreviewArgsSchema = lazySchema(() => zodSchema(z.object({
|
|
5530
5623
|
searchContextSize: z.enum([
|
|
@@ -6448,6 +6541,9 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
6448
6541
|
const content = [];
|
|
6449
6542
|
const logprobs = [];
|
|
6450
6543
|
const functionTools = options.tools?.filter((tool) => tool.type === "function") ?? [];
|
|
6544
|
+
const hasWebSearchActionSources = response.output.some((part) => part.type === "web_search_call" && part.action?.type === "search" && part.action.sources?.some((source) => source.type === "url"));
|
|
6545
|
+
const hasFileSearchResults = response.output.some((part) => part.type === "file_search_call" && (part.results?.length ?? 0) > 0);
|
|
6546
|
+
const retrievedFileIds = /* @__PURE__ */ new Set();
|
|
6451
6547
|
let hasFunctionCall = false;
|
|
6452
6548
|
const hostedToolSearchCallIds = [];
|
|
6453
6549
|
for (const part of response.output) switch (part.type) {
|
|
@@ -6553,54 +6649,13 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
6553
6649
|
content.push({
|
|
6554
6650
|
type: "text",
|
|
6555
6651
|
text: contentPart.text,
|
|
6652
|
+
...contentPart.annotations.some((annotation) => annotation.type !== "file_path") && { citations: mapOpenAIResponsesCitations(contentPart.annotations, providerOptionsName) },
|
|
6556
6653
|
providerMetadata: { [providerOptionsName]: providerMetadata }
|
|
6557
6654
|
});
|
|
6558
|
-
for (const annotation of contentPart.annotations)
|
|
6559
|
-
type
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
url: annotation.url,
|
|
6563
|
-
title: annotation.title
|
|
6564
|
-
});
|
|
6565
|
-
else if (annotation.type === "file_citation") content.push({
|
|
6566
|
-
type: "source",
|
|
6567
|
-
sourceType: "document",
|
|
6568
|
-
id: this.config.generateId?.() ?? generateId(),
|
|
6569
|
-
mediaType: "text/plain",
|
|
6570
|
-
title: annotation.filename,
|
|
6571
|
-
filename: annotation.filename,
|
|
6572
|
-
providerMetadata: { [providerOptionsName]: {
|
|
6573
|
-
type: annotation.type,
|
|
6574
|
-
fileId: annotation.file_id,
|
|
6575
|
-
index: annotation.index
|
|
6576
|
-
} }
|
|
6577
|
-
});
|
|
6578
|
-
else if (annotation.type === "container_file_citation") content.push({
|
|
6579
|
-
type: "source",
|
|
6580
|
-
sourceType: "document",
|
|
6581
|
-
id: this.config.generateId?.() ?? generateId(),
|
|
6582
|
-
mediaType: "text/plain",
|
|
6583
|
-
title: annotation.filename,
|
|
6584
|
-
filename: annotation.filename,
|
|
6585
|
-
providerMetadata: { [providerOptionsName]: {
|
|
6586
|
-
type: annotation.type,
|
|
6587
|
-
fileId: annotation.file_id,
|
|
6588
|
-
containerId: annotation.container_id
|
|
6589
|
-
} }
|
|
6590
|
-
});
|
|
6591
|
-
else if (annotation.type === "file_path") content.push({
|
|
6592
|
-
type: "source",
|
|
6593
|
-
sourceType: "document",
|
|
6594
|
-
id: this.config.generateId?.() ?? generateId(),
|
|
6595
|
-
mediaType: "application/octet-stream",
|
|
6596
|
-
title: annotation.file_id,
|
|
6597
|
-
filename: annotation.file_id,
|
|
6598
|
-
providerMetadata: { [providerOptionsName]: {
|
|
6599
|
-
type: annotation.type,
|
|
6600
|
-
fileId: annotation.file_id,
|
|
6601
|
-
index: annotation.index
|
|
6602
|
-
} }
|
|
6603
|
-
});
|
|
6655
|
+
for (const annotation of contentPart.annotations) {
|
|
6656
|
+
if (annotation.type === "url_citation" && hasWebSearchActionSources || annotation.type === "file_citation" && hasFileSearchResults) continue;
|
|
6657
|
+
content.push(mapOpenAIResponsesAnnotationSource(annotation, providerOptionsName, this.config.generateId?.() ?? generateId()));
|
|
6658
|
+
}
|
|
6604
6659
|
}
|
|
6605
6660
|
break;
|
|
6606
6661
|
case "function_call": {
|
|
@@ -6688,8 +6743,19 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
6688
6743
|
type: "tool-result",
|
|
6689
6744
|
toolCallId: part.id,
|
|
6690
6745
|
toolName: toolNameMapping.toCustomToolName(webSearchToolName ?? "web_search"),
|
|
6691
|
-
|
|
6746
|
+
...part.status === "failed" || part.status === "incomplete" ? {
|
|
6747
|
+
isError: true,
|
|
6748
|
+
result: { status: part.status }
|
|
6749
|
+
} : { result: mapWebSearchOutput(part.action) }
|
|
6692
6750
|
});
|
|
6751
|
+
if (part.action?.type === "search") {
|
|
6752
|
+
for (const source of part.action.sources ?? []) if (source.type === "url") content.push({
|
|
6753
|
+
type: "source",
|
|
6754
|
+
sourceType: "url",
|
|
6755
|
+
id: this.config.generateId?.() ?? generateId(),
|
|
6756
|
+
url: source.url
|
|
6757
|
+
});
|
|
6758
|
+
}
|
|
6693
6759
|
break;
|
|
6694
6760
|
case "mcp_call": {
|
|
6695
6761
|
const toolCallId = part.approval_request_id != null ? approvalRequestIdToDummyToolCallIdFromPrompt[part.approval_request_id] ?? part.id : part.id;
|
|
@@ -6792,6 +6858,22 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
6792
6858
|
})) ?? null
|
|
6793
6859
|
}
|
|
6794
6860
|
});
|
|
6861
|
+
for (const result of part.results ?? []) {
|
|
6862
|
+
if (retrievedFileIds.has(result.file_id)) continue;
|
|
6863
|
+
retrievedFileIds.add(result.file_id);
|
|
6864
|
+
content.push({
|
|
6865
|
+
type: "source",
|
|
6866
|
+
sourceType: "document",
|
|
6867
|
+
id: this.config.generateId?.() ?? generateId(),
|
|
6868
|
+
mediaType: "text/plain",
|
|
6869
|
+
title: result.filename,
|
|
6870
|
+
filename: result.filename,
|
|
6871
|
+
providerMetadata: { [providerOptionsName]: {
|
|
6872
|
+
type: "file_search",
|
|
6873
|
+
fileId: result.file_id
|
|
6874
|
+
} }
|
|
6875
|
+
});
|
|
6876
|
+
}
|
|
6795
6877
|
break;
|
|
6796
6878
|
case "code_interpreter_call":
|
|
6797
6879
|
content.push({
|
|
@@ -6902,7 +6984,11 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
6902
6984
|
const logprobs = [];
|
|
6903
6985
|
let responseId = null;
|
|
6904
6986
|
const ongoingToolCalls = {};
|
|
6905
|
-
|
|
6987
|
+
let ongoingAnnotations = [];
|
|
6988
|
+
let hasWebSearchActionSources = false;
|
|
6989
|
+
let hasFileSearchResults = false;
|
|
6990
|
+
const retrievedFileIds = /* @__PURE__ */ new Set();
|
|
6991
|
+
const fallbackAnnotations = [];
|
|
6906
6992
|
let activeMessagePhase;
|
|
6907
6993
|
let hasFunctionCall = false;
|
|
6908
6994
|
const activeReasoning = {};
|
|
@@ -6975,6 +7061,11 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
6975
7061
|
id: value.item.call_id,
|
|
6976
7062
|
toolName
|
|
6977
7063
|
});
|
|
7064
|
+
controller.enqueue({
|
|
7065
|
+
type: "tool-input-delta",
|
|
7066
|
+
id: value.item.call_id,
|
|
7067
|
+
delta: "\""
|
|
7068
|
+
});
|
|
6978
7069
|
} else if (value.item.type === "web_search_call") {
|
|
6979
7070
|
ongoingToolCalls[value.output_index] = {
|
|
6980
7071
|
toolName: toolNameMapping.toCustomToolName(webSearchToolName ?? "web_search"),
|
|
@@ -7094,7 +7185,7 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
7094
7185
|
};
|
|
7095
7186
|
else if (value.item.type === "shell_call_output") {} else if (value.item.type === "message") {
|
|
7096
7187
|
activeOutputItemIds[value.output_index] = value.item.id;
|
|
7097
|
-
ongoingAnnotations
|
|
7188
|
+
ongoingAnnotations = [];
|
|
7098
7189
|
activeMessagePhase = value.item.phase ?? void 0;
|
|
7099
7190
|
controller.enqueue({
|
|
7100
7191
|
type: "text-start",
|
|
@@ -7130,6 +7221,7 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
7130
7221
|
controller.enqueue({
|
|
7131
7222
|
type: "text-end",
|
|
7132
7223
|
id: itemId,
|
|
7224
|
+
...ongoingAnnotations.some((annotation) => annotation.type !== "file_path") && { citations: mapOpenAIResponsesCitations(ongoingAnnotations, providerOptionsName) },
|
|
7133
7225
|
providerMetadata: { [providerOptionsName]: {
|
|
7134
7226
|
itemId,
|
|
7135
7227
|
...phase != null && { phase },
|
|
@@ -7248,6 +7340,11 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
7248
7340
|
ongoingToolCalls[value.output_index] = void 0;
|
|
7249
7341
|
hasFunctionCall = true;
|
|
7250
7342
|
const toolName = toolNameMapping.toCustomToolName(value.item.name);
|
|
7343
|
+
controller.enqueue({
|
|
7344
|
+
type: "tool-input-delta",
|
|
7345
|
+
id: value.item.call_id,
|
|
7346
|
+
delta: "\""
|
|
7347
|
+
});
|
|
7251
7348
|
controller.enqueue({
|
|
7252
7349
|
type: "tool-input-end",
|
|
7253
7350
|
id: value.item.call_id
|
|
@@ -7268,8 +7365,22 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
7268
7365
|
type: "tool-result",
|
|
7269
7366
|
toolCallId: value.item.id,
|
|
7270
7367
|
toolName: toolNameMapping.toCustomToolName(webSearchToolName ?? "web_search"),
|
|
7271
|
-
|
|
7368
|
+
...value.item.status === "failed" || value.item.status === "incomplete" ? {
|
|
7369
|
+
isError: true,
|
|
7370
|
+
result: { status: value.item.status }
|
|
7371
|
+
} : { result: mapWebSearchOutput(value.item.action) }
|
|
7272
7372
|
});
|
|
7373
|
+
if (value.item.action?.type === "search") {
|
|
7374
|
+
for (const source of value.item.action.sources ?? []) if (source.type === "url") {
|
|
7375
|
+
hasWebSearchActionSources = true;
|
|
7376
|
+
controller.enqueue({
|
|
7377
|
+
type: "source",
|
|
7378
|
+
sourceType: "url",
|
|
7379
|
+
id: self.config.generateId?.() ?? generateId(),
|
|
7380
|
+
url: source.url
|
|
7381
|
+
});
|
|
7382
|
+
}
|
|
7383
|
+
}
|
|
7273
7384
|
} else if (value.item.type === "computer_call") {
|
|
7274
7385
|
ongoingToolCalls[value.output_index] = void 0;
|
|
7275
7386
|
if (value.item.call_id == null) {
|
|
@@ -7331,6 +7442,23 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
7331
7442
|
})) ?? null
|
|
7332
7443
|
}
|
|
7333
7444
|
});
|
|
7445
|
+
for (const result of value.item.results ?? []) {
|
|
7446
|
+
hasFileSearchResults = true;
|
|
7447
|
+
if (retrievedFileIds.has(result.file_id)) continue;
|
|
7448
|
+
retrievedFileIds.add(result.file_id);
|
|
7449
|
+
controller.enqueue({
|
|
7450
|
+
type: "source",
|
|
7451
|
+
sourceType: "document",
|
|
7452
|
+
id: self.config.generateId?.() ?? generateId(),
|
|
7453
|
+
mediaType: "text/plain",
|
|
7454
|
+
title: result.filename,
|
|
7455
|
+
filename: result.filename,
|
|
7456
|
+
providerMetadata: { [providerOptionsName]: {
|
|
7457
|
+
type: "file_search",
|
|
7458
|
+
fileId: result.file_id
|
|
7459
|
+
} }
|
|
7460
|
+
});
|
|
7461
|
+
}
|
|
7334
7462
|
} else if (value.item.type === "code_interpreter_call") {
|
|
7335
7463
|
ongoingToolCalls[value.output_index] = void 0;
|
|
7336
7464
|
controller.enqueue({
|
|
@@ -7544,7 +7672,7 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
7544
7672
|
if (toolCall != null) controller.enqueue({
|
|
7545
7673
|
type: "tool-input-delta",
|
|
7546
7674
|
id: toolCall.toolCallId,
|
|
7547
|
-
delta: value.delta
|
|
7675
|
+
delta: escapeJSONDelta(value.delta)
|
|
7548
7676
|
});
|
|
7549
7677
|
} else if (isResponseApplyPatchCallOperationDiffDeltaChunk(value)) {
|
|
7550
7678
|
const toolCall = ongoingToolCalls[value.output_index];
|
|
@@ -7728,52 +7856,8 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
7728
7856
|
}
|
|
7729
7857
|
} else if (isResponseAnnotationAddedChunk(value)) {
|
|
7730
7858
|
ongoingAnnotations.push(value.annotation);
|
|
7731
|
-
if (value.annotation.type === "url_citation")
|
|
7732
|
-
|
|
7733
|
-
sourceType: "url",
|
|
7734
|
-
id: self.config.generateId?.() ?? generateId(),
|
|
7735
|
-
url: value.annotation.url,
|
|
7736
|
-
title: value.annotation.title
|
|
7737
|
-
});
|
|
7738
|
-
else if (value.annotation.type === "file_citation") controller.enqueue({
|
|
7739
|
-
type: "source",
|
|
7740
|
-
sourceType: "document",
|
|
7741
|
-
id: self.config.generateId?.() ?? generateId(),
|
|
7742
|
-
mediaType: "text/plain",
|
|
7743
|
-
title: value.annotation.filename,
|
|
7744
|
-
filename: value.annotation.filename,
|
|
7745
|
-
providerMetadata: { [providerOptionsName]: {
|
|
7746
|
-
type: value.annotation.type,
|
|
7747
|
-
fileId: value.annotation.file_id,
|
|
7748
|
-
index: value.annotation.index
|
|
7749
|
-
} }
|
|
7750
|
-
});
|
|
7751
|
-
else if (value.annotation.type === "container_file_citation") controller.enqueue({
|
|
7752
|
-
type: "source",
|
|
7753
|
-
sourceType: "document",
|
|
7754
|
-
id: self.config.generateId?.() ?? generateId(),
|
|
7755
|
-
mediaType: "text/plain",
|
|
7756
|
-
title: value.annotation.filename,
|
|
7757
|
-
filename: value.annotation.filename,
|
|
7758
|
-
providerMetadata: { [providerOptionsName]: {
|
|
7759
|
-
type: value.annotation.type,
|
|
7760
|
-
fileId: value.annotation.file_id,
|
|
7761
|
-
containerId: value.annotation.container_id
|
|
7762
|
-
} }
|
|
7763
|
-
});
|
|
7764
|
-
else if (value.annotation.type === "file_path") controller.enqueue({
|
|
7765
|
-
type: "source",
|
|
7766
|
-
sourceType: "document",
|
|
7767
|
-
id: self.config.generateId?.() ?? generateId(),
|
|
7768
|
-
mediaType: "application/octet-stream",
|
|
7769
|
-
title: value.annotation.file_id,
|
|
7770
|
-
filename: value.annotation.file_id,
|
|
7771
|
-
providerMetadata: { [providerOptionsName]: {
|
|
7772
|
-
type: value.annotation.type,
|
|
7773
|
-
fileId: value.annotation.file_id,
|
|
7774
|
-
index: value.annotation.index
|
|
7775
|
-
} }
|
|
7776
|
-
});
|
|
7859
|
+
if (value.annotation.type === "url_citation" || value.annotation.type === "file_citation") fallbackAnnotations.push(value.annotation);
|
|
7860
|
+
else controller.enqueue(mapOpenAIResponsesAnnotationSource(value.annotation, providerOptionsName, self.config.generateId?.() ?? generateId()));
|
|
7777
7861
|
} else if (isErrorChunk(value)) {
|
|
7778
7862
|
encounteredStreamError = true;
|
|
7779
7863
|
finishReason = {
|
|
@@ -7787,6 +7871,10 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
7787
7871
|
}
|
|
7788
7872
|
},
|
|
7789
7873
|
flush(controller) {
|
|
7874
|
+
for (const annotation of fallbackAnnotations) {
|
|
7875
|
+
if (annotation.type === "url_citation" && hasWebSearchActionSources || annotation.type === "file_citation" && hasFileSearchResults) continue;
|
|
7876
|
+
controller.enqueue(mapOpenAIResponsesAnnotationSource(annotation, providerOptionsName, self.config.generateId?.() ?? generateId()));
|
|
7877
|
+
}
|
|
7790
7878
|
for (const toolCall of Object.values(ongoingToolCalls)) {
|
|
7791
7879
|
if (!toolCall?.suppressInputStreaming) continue;
|
|
7792
7880
|
controller.enqueue({
|