@langchain/openai
Advanced tools
@@ -1,5 +0,4 @@ | ||
| const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs'); | ||
| const require_azure = require('../../utils/azure.cjs'); | ||
| const openai = require_rolldown_runtime.__toESM(require("openai")); | ||
| const __langchain_core_utils_env = require_rolldown_runtime.__toESM(require("@langchain/core/utils/env")); | ||
| let openai = require("openai"); | ||
| let _langchain_core_utils_env = require("@langchain/core/utils/env"); | ||
@@ -30,8 +29,8 @@ //#region src/azure/chat_models/common.ts | ||
| function _constructAzureFields(fields) { | ||
| this.azureOpenAIApiKey = fields?.azureOpenAIApiKey ?? (typeof fields?.openAIApiKey === "string" ? fields?.openAIApiKey : void 0) ?? (typeof fields?.apiKey === "string" ? fields?.apiKey : void 0) ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_KEY"); | ||
| this.azureOpenAIApiInstanceName = fields?.azureOpenAIApiInstanceName ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_INSTANCE_NAME"); | ||
| this.azureOpenAIApiDeploymentName = fields?.azureOpenAIApiDeploymentName ?? fields?.deploymentName ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_DEPLOYMENT_NAME"); | ||
| this.azureOpenAIApiVersion = fields?.azureOpenAIApiVersion ?? fields?.openAIApiVersion ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_VERSION"); | ||
| this.azureOpenAIBasePath = fields?.azureOpenAIBasePath ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_BASE_PATH"); | ||
| this.azureOpenAIEndpoint = fields?.azureOpenAIEndpoint ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_ENDPOINT"); | ||
| this.azureOpenAIApiKey = fields?.azureOpenAIApiKey ?? (typeof fields?.openAIApiKey === "string" ? fields?.openAIApiKey : void 0) ?? (typeof fields?.apiKey === "string" ? fields?.apiKey : void 0) ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_KEY"); | ||
| this.azureOpenAIApiInstanceName = fields?.azureOpenAIApiInstanceName ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_INSTANCE_NAME"); | ||
| this.azureOpenAIApiDeploymentName = fields?.azureOpenAIApiDeploymentName ?? fields?.deploymentName ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_DEPLOYMENT_NAME"); | ||
| this.azureOpenAIApiVersion = fields?.azureOpenAIApiVersion ?? fields?.openAIApiVersion ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_VERSION"); | ||
| this.azureOpenAIBasePath = fields?.azureOpenAIBasePath ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_BASE_PATH"); | ||
| this.azureOpenAIEndpoint = fields?.azureOpenAIEndpoint ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_ENDPOINT"); | ||
| this.azureADTokenProvider = fields?.azureADTokenProvider; | ||
@@ -52,3 +51,3 @@ if (!this.azureOpenAIApiKey && !this.apiKey && !this.azureADTokenProvider) throw new Error("Azure OpenAI API key or Token Provider not found"); | ||
| const endpoint = require_azure.getEndpoint(openAIEndpointConfig); | ||
| const { apiKey: existingApiKey,...clientConfigRest } = this.clientConfig; | ||
| const { apiKey: existingApiKey, ...clientConfigRest } = this.clientConfig; | ||
| const params = { | ||
@@ -55,0 +54,0 @@ ...clientConfigRest, |
@@ -6,3 +6,2 @@ import { AzureOpenAIChatInput } from "../../types.cjs"; | ||
| //#region src/azure/chat_models/common.d.ts | ||
| interface AzureChatOpenAIFields extends BaseChatOpenAIFields, Partial<AzureOpenAIChatInput> { | ||
@@ -9,0 +8,0 @@ /** |
@@ -7,3 +7,2 @@ import { AzureOpenAIChatInput } from "../../types.js"; | ||
| //#region src/azure/chat_models/common.d.ts | ||
| interface AzureChatOpenAIFields extends BaseChatOpenAIFields, Partial<AzureOpenAIChatInput> { | ||
@@ -10,0 +9,0 @@ /** |
@@ -50,3 +50,3 @@ import { getEndpoint, getHeadersWithUserAgent } from "../../utils/azure.js"; | ||
| const endpoint = getEndpoint(openAIEndpointConfig); | ||
| const { apiKey: existingApiKey,...clientConfigRest } = this.clientConfig; | ||
| const { apiKey: existingApiKey, ...clientConfigRest } = this.clientConfig; | ||
| const params = { | ||
@@ -53,0 +53,0 @@ ...clientConfigRest, |
@@ -9,3 +9,2 @@ import { AzureOpenAIChatInput } from "../../types.cjs"; | ||
| //#region src/azure/chat_models/index.d.ts | ||
| /** | ||
@@ -12,0 +11,0 @@ * Azure OpenAI chat model integration. |
@@ -9,3 +9,2 @@ import { AzureOpenAIChatInput } from "../../types.js"; | ||
| //#region src/azure/chat_models/index.d.ts | ||
| /** | ||
@@ -12,0 +11,0 @@ * Azure OpenAI chat model integration. |
@@ -1,7 +0,6 @@ | ||
| const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs'); | ||
| const require_client = require('../utils/client.cjs'); | ||
| const require_azure = require('../utils/azure.cjs'); | ||
| const require_embeddings = require('../embeddings.cjs'); | ||
| const openai = require_rolldown_runtime.__toESM(require("openai")); | ||
| const __langchain_core_utils_env = require_rolldown_runtime.__toESM(require("@langchain/core/utils/env")); | ||
| let openai = require("openai"); | ||
| let _langchain_core_utils_env = require("@langchain/core/utils/env"); | ||
@@ -19,7 +18,7 @@ //#region src/azure/embeddings.ts | ||
| this.batchSize = fields?.batchSize ?? 1; | ||
| this.azureOpenAIApiKey = fields?.azureOpenAIApiKey ?? (typeof fields?.apiKey === "string" ? fields?.apiKey : void 0) ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_KEY"); | ||
| this.azureOpenAIApiVersion = fields?.azureOpenAIApiVersion ?? fields?.openAIApiVersion ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_VERSION"); | ||
| this.azureOpenAIBasePath = fields?.azureOpenAIBasePath ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_BASE_PATH"); | ||
| this.azureOpenAIApiInstanceName = fields?.azureOpenAIApiInstanceName ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_INSTANCE_NAME"); | ||
| this.azureOpenAIApiDeploymentName = (fields?.azureOpenAIApiEmbeddingsDeploymentName || fields?.azureOpenAIApiDeploymentName) ?? ((0, __langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME") || (0, __langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_DEPLOYMENT_NAME")); | ||
| this.azureOpenAIApiKey = fields?.azureOpenAIApiKey ?? (typeof fields?.apiKey === "string" ? fields?.apiKey : void 0) ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_KEY"); | ||
| this.azureOpenAIApiVersion = fields?.azureOpenAIApiVersion ?? fields?.openAIApiVersion ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_VERSION"); | ||
| this.azureOpenAIBasePath = fields?.azureOpenAIBasePath ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_BASE_PATH"); | ||
| this.azureOpenAIApiInstanceName = fields?.azureOpenAIApiInstanceName ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_INSTANCE_NAME"); | ||
| this.azureOpenAIApiDeploymentName = (fields?.azureOpenAIApiEmbeddingsDeploymentName || fields?.azureOpenAIApiDeploymentName) ?? ((0, _langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME") || (0, _langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_DEPLOYMENT_NAME")); | ||
| this.azureADTokenProvider = fields?.azureADTokenProvider; | ||
@@ -38,3 +37,3 @@ } | ||
| const endpoint = require_azure.getEndpoint(openAIEndpointConfig); | ||
| const { apiKey: existingApiKey,...clientConfigRest } = this.clientConfig; | ||
| const { apiKey: existingApiKey, ...clientConfigRest } = this.clientConfig; | ||
| const params = { | ||
@@ -69,7 +68,5 @@ ...clientConfigRest, | ||
| try { | ||
| const res = await this.client.embeddings.create(request, requestOptions); | ||
| return res; | ||
| return await this.client.embeddings.create(request, requestOptions); | ||
| } catch (e) { | ||
| const error = require_client.wrapOpenAIClientError(e); | ||
| throw error; | ||
| throw require_client.wrapOpenAIClientError(e); | ||
| } | ||
@@ -76,0 +73,0 @@ }); |
@@ -14,4 +14,3 @@ import { AzureOpenAIInput } from "../types.cjs"; | ||
| constructor(fields?: Partial<OpenAIEmbeddingsParams> & Partial<AzureOpenAIInput> & { | ||
| verbose?: boolean; | ||
| /** The OpenAI API key to use. */ | ||
| verbose?: boolean; /** The OpenAI API key to use. */ | ||
| apiKey?: string; | ||
@@ -18,0 +17,0 @@ configuration?: ClientOptions; |
@@ -14,4 +14,3 @@ import { AzureOpenAIInput } from "../types.js"; | ||
| constructor(fields?: Partial<OpenAIEmbeddingsParams> & Partial<AzureOpenAIInput> & { | ||
| verbose?: boolean; | ||
| /** The OpenAI API key to use. */ | ||
| verbose?: boolean; /** The OpenAI API key to use. */ | ||
| apiKey?: string; | ||
@@ -18,0 +17,0 @@ configuration?: ClientOptions; |
@@ -36,3 +36,3 @@ import { wrapOpenAIClientError } from "../utils/client.js"; | ||
| const endpoint = getEndpoint(openAIEndpointConfig); | ||
| const { apiKey: existingApiKey,...clientConfigRest } = this.clientConfig; | ||
| const { apiKey: existingApiKey, ...clientConfigRest } = this.clientConfig; | ||
| const params = { | ||
@@ -67,7 +67,5 @@ ...clientConfigRest, | ||
| try { | ||
| const res = await this.client.embeddings.create(request, requestOptions); | ||
| return res; | ||
| return await this.client.embeddings.create(request, requestOptions); | ||
| } catch (e) { | ||
| const error = wrapOpenAIClientError(e); | ||
| throw error; | ||
| throw wrapOpenAIClientError(e); | ||
| } | ||
@@ -74,0 +72,0 @@ }); |
+9
-10
@@ -1,6 +0,5 @@ | ||
| const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs'); | ||
| const require_azure = require('../utils/azure.cjs'); | ||
| const require_llms = require('../llms.cjs'); | ||
| const openai = require_rolldown_runtime.__toESM(require("openai")); | ||
| const __langchain_core_utils_env = require_rolldown_runtime.__toESM(require("@langchain/core/utils/env")); | ||
| let openai = require("openai"); | ||
| let _langchain_core_utils_env = require("@langchain/core/utils/env"); | ||
@@ -37,8 +36,8 @@ //#region src/azure/llms.ts | ||
| super(fields); | ||
| this.azureOpenAIApiDeploymentName = (fields?.azureOpenAIApiCompletionsDeploymentName || fields?.azureOpenAIApiDeploymentName) ?? ((0, __langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_COMPLETIONS_DEPLOYMENT_NAME") || (0, __langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_DEPLOYMENT_NAME")); | ||
| this.azureOpenAIApiKey = fields?.azureOpenAIApiKey ?? (typeof fields?.openAIApiKey === "string" ? fields?.openAIApiKey : void 0) ?? (typeof fields?.apiKey === "string" ? fields?.apiKey : void 0) ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_KEY"); | ||
| this.azureOpenAIApiInstanceName = fields?.azureOpenAIApiInstanceName ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_INSTANCE_NAME"); | ||
| this.azureOpenAIApiVersion = fields?.azureOpenAIApiVersion ?? fields?.openAIApiVersion ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_VERSION"); | ||
| this.azureOpenAIBasePath = fields?.azureOpenAIBasePath ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_BASE_PATH"); | ||
| this.azureOpenAIEndpoint = fields?.azureOpenAIEndpoint ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_ENDPOINT"); | ||
| this.azureOpenAIApiDeploymentName = (fields?.azureOpenAIApiCompletionsDeploymentName || fields?.azureOpenAIApiDeploymentName) ?? ((0, _langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_COMPLETIONS_DEPLOYMENT_NAME") || (0, _langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_DEPLOYMENT_NAME")); | ||
| this.azureOpenAIApiKey = fields?.azureOpenAIApiKey ?? (typeof fields?.openAIApiKey === "string" ? fields?.openAIApiKey : void 0) ?? (typeof fields?.apiKey === "string" ? fields?.apiKey : void 0) ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_KEY"); | ||
| this.azureOpenAIApiInstanceName = fields?.azureOpenAIApiInstanceName ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_INSTANCE_NAME"); | ||
| this.azureOpenAIApiVersion = fields?.azureOpenAIApiVersion ?? fields?.openAIApiVersion ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_API_VERSION"); | ||
| this.azureOpenAIBasePath = fields?.azureOpenAIBasePath ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_BASE_PATH"); | ||
| this.azureOpenAIEndpoint = fields?.azureOpenAIEndpoint ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("AZURE_OPENAI_ENDPOINT"); | ||
| this.azureADTokenProvider = fields?.azureADTokenProvider; | ||
@@ -58,3 +57,3 @@ if (!this.azureOpenAIApiKey && !this.apiKey && !this.azureADTokenProvider) throw new Error("Azure OpenAI API key or Token Provider not found"); | ||
| const endpoint = require_azure.getEndpoint(openAIEndpointConfig); | ||
| const { apiKey: existingApiKey,...clientConfigRest } = this.clientConfig; | ||
| const { apiKey: existingApiKey, ...clientConfigRest } = this.clientConfig; | ||
| const params = { | ||
@@ -61,0 +60,0 @@ ...clientConfigRest, |
| import { AzureOpenAIInput, OpenAICoreRequestOptions, OpenAIInput } from "../types.cjs"; | ||
| import { OpenAI } from "../llms.cjs"; | ||
| import { OpenAI as OpenAI$2 } from "../llms.cjs"; | ||
| import { ClientOptions } from "openai"; | ||
@@ -7,3 +7,3 @@ import { BaseLLMParams } from "@langchain/core/language_models/llms"; | ||
| //#region src/azure/llms.d.ts | ||
| declare class AzureOpenAI extends OpenAI { | ||
| declare class AzureOpenAI extends OpenAI$2 { | ||
| azureOpenAIApiVersion?: string; | ||
@@ -10,0 +10,0 @@ azureOpenAIApiKey?: string; |
| import { AzureOpenAIInput, OpenAICoreRequestOptions, OpenAIInput } from "../types.js"; | ||
| import { OpenAI } from "../llms.js"; | ||
| import { OpenAI as OpenAI$2 } from "../llms.js"; | ||
| import { ClientOptions } from "openai"; | ||
@@ -7,3 +7,3 @@ import { BaseLLMParams } from "@langchain/core/language_models/llms"; | ||
| //#region src/azure/llms.d.ts | ||
| declare class AzureOpenAI$1 extends OpenAI { | ||
| declare class AzureOpenAI$1 extends OpenAI$2 { | ||
| azureOpenAIApiVersion?: string; | ||
@@ -10,0 +10,0 @@ azureOpenAIApiKey?: string; |
| import { getEndpoint, getHeadersWithUserAgent } from "../utils/azure.js"; | ||
| import { OpenAI } from "../llms.js"; | ||
| import { OpenAI as OpenAI$2 } from "../llms.js"; | ||
| import { AzureOpenAI } from "openai"; | ||
@@ -7,3 +7,3 @@ import { getEnvironmentVariable } from "@langchain/core/utils/env"; | ||
| //#region src/azure/llms.ts | ||
| var AzureOpenAI$1 = class extends OpenAI { | ||
| var AzureOpenAI$1 = class extends OpenAI$2 { | ||
| azureOpenAIApiVersion; | ||
@@ -57,3 +57,3 @@ azureOpenAIApiKey; | ||
| const endpoint = getEndpoint(openAIEndpointConfig); | ||
| const { apiKey: existingApiKey,...clientConfigRest } = this.clientConfig; | ||
| const { apiKey: existingApiKey, ...clientConfigRest } = this.clientConfig; | ||
| const params = { | ||
@@ -60,0 +60,0 @@ ...clientConfigRest, |
@@ -1,2 +0,1 @@ | ||
| const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs'); | ||
| const require_client = require('../utils/client.cjs'); | ||
@@ -8,15 +7,15 @@ const require_tools = require('../utils/tools.cjs'); | ||
| const require_profiles = require('./profiles.cjs'); | ||
| const openai = require_rolldown_runtime.__toESM(require("openai")); | ||
| const __langchain_core_utils_types = require_rolldown_runtime.__toESM(require("@langchain/core/utils/types")); | ||
| const __langchain_core_utils_json_schema = require_rolldown_runtime.__toESM(require("@langchain/core/utils/json_schema")); | ||
| const __langchain_core_utils_env = require_rolldown_runtime.__toESM(require("@langchain/core/utils/env")); | ||
| const __langchain_core_language_models_chat_models = require_rolldown_runtime.__toESM(require("@langchain/core/language_models/chat_models")); | ||
| const __langchain_core_language_models_base = require_rolldown_runtime.__toESM(require("@langchain/core/language_models/base")); | ||
| const __langchain_core_runnables = require_rolldown_runtime.__toESM(require("@langchain/core/runnables")); | ||
| const __langchain_core_output_parsers = require_rolldown_runtime.__toESM(require("@langchain/core/output_parsers")); | ||
| const __langchain_core_output_parsers_openai_tools = require_rolldown_runtime.__toESM(require("@langchain/core/output_parsers/openai_tools")); | ||
| let openai = require("openai"); | ||
| let _langchain_core_utils_types = require("@langchain/core/utils/types"); | ||
| let _langchain_core_utils_json_schema = require("@langchain/core/utils/json_schema"); | ||
| let _langchain_core_utils_env = require("@langchain/core/utils/env"); | ||
| let _langchain_core_language_models_chat_models = require("@langchain/core/language_models/chat_models"); | ||
| let _langchain_core_language_models_base = require("@langchain/core/language_models/base"); | ||
| let _langchain_core_runnables = require("@langchain/core/runnables"); | ||
| let _langchain_core_output_parsers = require("@langchain/core/output_parsers"); | ||
| let _langchain_core_output_parsers_openai_tools = require("@langchain/core/output_parsers/openai_tools"); | ||
| //#region src/chat_models/base.ts | ||
| /** @internal */ | ||
| var BaseChatOpenAI = class extends __langchain_core_language_models_chat_models.BaseChatModel { | ||
| var BaseChatOpenAI = class extends _langchain_core_language_models_chat_models.BaseChatModel { | ||
| temperature; | ||
@@ -190,4 +189,4 @@ topP; | ||
| const configApiKey = typeof fields?.configuration?.apiKey === "string" || typeof fields?.configuration?.apiKey === "function" ? fields?.configuration?.apiKey : void 0; | ||
| this.apiKey = fields?.apiKey ?? configApiKey ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("OPENAI_API_KEY"); | ||
| this.organization = fields?.configuration?.organization ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("OPENAI_ORGANIZATION"); | ||
| this.apiKey = fields?.apiKey ?? configApiKey ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("OPENAI_API_KEY"); | ||
| this.organization = fields?.configuration?.organization ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("OPENAI_ORGANIZATION"); | ||
| this.model = fields?.model ?? fields?.modelName ?? this.model; | ||
@@ -257,3 +256,3 @@ this.modelKwargs = fields?.modelKwargs ?? {}; | ||
| _getResponseFormat(resFormat) { | ||
| if (resFormat && resFormat.type === "json_schema" && resFormat.json_schema.schema && (0, __langchain_core_utils_types.isInteropZodSchema)(resFormat.json_schema.schema)) return require_output.interopZodResponseFormat(resFormat.json_schema.schema, resFormat.json_schema.name, { description: resFormat.json_schema.description }); | ||
| if (resFormat && resFormat.type === "json_schema" && resFormat.json_schema.schema && (0, _langchain_core_utils_types.isInteropZodSchema)(resFormat.json_schema.schema)) return require_output.interopZodResponseFormat(resFormat.json_schema.schema, resFormat.json_schema.name, { description: resFormat.json_schema.description }); | ||
| return resFormat; | ||
@@ -270,4 +269,3 @@ } | ||
| if (!this.client) { | ||
| const openAIEndpointConfig = { baseURL: this.clientConfig.baseURL }; | ||
| const endpoint = require_azure.getEndpoint(openAIEndpointConfig); | ||
| const endpoint = require_azure.getEndpoint({ baseURL: this.clientConfig.baseURL }); | ||
| const params = { | ||
@@ -283,11 +281,10 @@ ...this.clientConfig, | ||
| } | ||
| const requestOptions = { | ||
| return { | ||
| ...this.clientConfig, | ||
| ...options | ||
| }; | ||
| return requestOptions; | ||
| } | ||
| _convertChatOpenAIToolToCompletionsTool(tool, fields) { | ||
| if (require_tools.isCustomTool(tool)) return require_tools.convertResponsesCustomTool(tool.metadata.customTool); | ||
| if ((0, __langchain_core_language_models_base.isOpenAITool)(tool)) { | ||
| if ((0, _langchain_core_language_models_base.isOpenAITool)(tool)) { | ||
| if (fields?.strict !== void 0) return { | ||
@@ -374,7 +371,6 @@ ...tool, | ||
| async _getNumTokensFromGenerations(generations) { | ||
| const generationUsages = await Promise.all(generations.map(async (generation) => { | ||
| return (await Promise.all(generations.map(async (generation) => { | ||
| if (generation.message.additional_kwargs?.function_call) return (await this.getNumTokensFromMessages([generation.message])).countPerMessage[0]; | ||
| else return await this.getNumTokens(generation.message.content); | ||
| })); | ||
| return generationUsages.reduce((a, b) => a + b, 0); | ||
| }))).reduce((a, b) => a + b, 0); | ||
| } | ||
@@ -434,14 +430,11 @@ /** @internal */ | ||
| const clientOptions = this._getClientOptions(params?.options); | ||
| const moderationModel = params?.model ?? "omni-moderation-latest"; | ||
| const moderationRequest = { | ||
| input, | ||
| model: moderationModel | ||
| model: params?.model ?? "omni-moderation-latest" | ||
| }; | ||
| return this.caller.call(async () => { | ||
| try { | ||
| const response = await this.client.moderations.create(moderationRequest, clientOptions); | ||
| return response; | ||
| return await this.client.moderations.create(moderationRequest, clientOptions); | ||
| } catch (e) { | ||
| const error = require_client.wrapOpenAIClientError(e); | ||
| throw error; | ||
| throw require_client.wrapOpenAIClientError(e); | ||
| } | ||
@@ -507,5 +500,5 @@ }); | ||
| if (method === "jsonMode") { | ||
| if ((0, __langchain_core_utils_types.isInteropZodSchema)(schema)) outputParser = __langchain_core_output_parsers.StructuredOutputParser.fromZodSchema(schema); | ||
| else outputParser = new __langchain_core_output_parsers.JsonOutputParser(); | ||
| const asJsonSchema = (0, __langchain_core_utils_json_schema.toJsonSchema)(schema); | ||
| if ((0, _langchain_core_utils_types.isInteropZodSchema)(schema)) outputParser = _langchain_core_output_parsers.StructuredOutputParser.fromZodSchema(schema); | ||
| else outputParser = new _langchain_core_output_parsers.JsonOutputParser(); | ||
| const asJsonSchema = (0, _langchain_core_utils_json_schema.toJsonSchema)(schema); | ||
| llm = this.withConfig({ | ||
@@ -525,7 +518,7 @@ outputVersion: "v0", | ||
| name: name ?? "extract", | ||
| description: (0, __langchain_core_utils_types.getSchemaDescription)(schema), | ||
| description: (0, _langchain_core_utils_types.getSchemaDescription)(schema), | ||
| schema, | ||
| strict: config?.strict | ||
| }; | ||
| const asJsonSchema = (0, __langchain_core_utils_json_schema.toJsonSchema)(openaiJsonSchemaParams.schema); | ||
| const asJsonSchema = (0, _langchain_core_utils_json_schema.toJsonSchema)(openaiJsonSchemaParams.schema); | ||
| llm = this.withConfig({ | ||
@@ -546,13 +539,13 @@ outputVersion: "v0", | ||
| }); | ||
| if ((0, __langchain_core_utils_types.isInteropZodSchema)(schema)) { | ||
| const altParser = __langchain_core_output_parsers.StructuredOutputParser.fromZodSchema(schema); | ||
| outputParser = __langchain_core_runnables.RunnableLambda.from((aiMessage) => { | ||
| if ((0, _langchain_core_utils_types.isInteropZodSchema)(schema)) { | ||
| const altParser = _langchain_core_output_parsers.StructuredOutputParser.fromZodSchema(schema); | ||
| outputParser = _langchain_core_runnables.RunnableLambda.from((aiMessage) => { | ||
| if ("parsed" in aiMessage.additional_kwargs) return aiMessage.additional_kwargs.parsed; | ||
| return altParser; | ||
| }); | ||
| } else outputParser = new __langchain_core_output_parsers.JsonOutputParser(); | ||
| } else outputParser = new _langchain_core_output_parsers.JsonOutputParser(); | ||
| } else { | ||
| let functionName = name ?? "extract"; | ||
| if ((0, __langchain_core_utils_types.isInteropZodSchema)(schema)) { | ||
| const asJsonSchema = (0, __langchain_core_utils_json_schema.toJsonSchema)(schema); | ||
| if ((0, _langchain_core_utils_types.isInteropZodSchema)(schema)) { | ||
| const asJsonSchema = (0, _langchain_core_utils_json_schema.toJsonSchema)(schema); | ||
| llm = this.withConfig({ | ||
@@ -581,3 +574,3 @@ outputVersion: "v0", | ||
| }); | ||
| outputParser = new __langchain_core_output_parsers_openai_tools.JsonOutputKeyToolsParser({ | ||
| outputParser = new _langchain_core_output_parsers_openai_tools.JsonOutputKeyToolsParser({ | ||
| returnSingle: true, | ||
@@ -600,3 +593,3 @@ keyName: functionName, | ||
| } | ||
| const asJsonSchema = (0, __langchain_core_utils_json_schema.toJsonSchema)(schema); | ||
| const asJsonSchema = (0, _langchain_core_utils_json_schema.toJsonSchema)(schema); | ||
| llm = this.withConfig({ | ||
@@ -621,3 +614,3 @@ outputVersion: "v0", | ||
| }); | ||
| outputParser = new __langchain_core_output_parsers_openai_tools.JsonOutputKeyToolsParser({ | ||
| outputParser = new _langchain_core_output_parsers_openai_tools.JsonOutputKeyToolsParser({ | ||
| returnSingle: true, | ||
@@ -629,6 +622,6 @@ keyName: functionName | ||
| if (!includeRaw) return llm.pipe(outputParser); | ||
| const parserAssign = __langchain_core_runnables.RunnablePassthrough.assign({ parsed: (input, config$1) => outputParser.invoke(input.raw, config$1) }); | ||
| const parserNone = __langchain_core_runnables.RunnablePassthrough.assign({ parsed: () => null }); | ||
| const parserAssign = _langchain_core_runnables.RunnablePassthrough.assign({ parsed: (input, config) => outputParser.invoke(input.raw, config) }); | ||
| const parserNone = _langchain_core_runnables.RunnablePassthrough.assign({ parsed: () => null }); | ||
| const parsedWithFallback = parserAssign.withFallbacks({ fallbacks: [parserNone] }); | ||
| return __langchain_core_runnables.RunnableSequence.from([{ raw: llm }, parsedWithFallback]); | ||
| return _langchain_core_runnables.RunnableSequence.from([{ raw: llm }, parsedWithFallback]); | ||
| } | ||
@@ -635,0 +628,0 @@ }; |
+10
-16
@@ -6,3 +6,3 @@ import { wrapOpenAIClientError } from "../utils/client.js"; | ||
| import { getStructuredOutputMethod, interopZodResponseFormat } from "../utils/output.js"; | ||
| import profiles_default from "./profiles.js"; | ||
| import PROFILES from "./profiles.js"; | ||
| import { OpenAI as OpenAI$1 } from "openai"; | ||
@@ -267,4 +267,3 @@ import { getSchemaDescription, isInteropZodSchema } from "@langchain/core/utils/types"; | ||
| if (!this.client) { | ||
| const openAIEndpointConfig = { baseURL: this.clientConfig.baseURL }; | ||
| const endpoint = getEndpoint(openAIEndpointConfig); | ||
| const endpoint = getEndpoint({ baseURL: this.clientConfig.baseURL }); | ||
| const params = { | ||
@@ -280,7 +279,6 @@ ...this.clientConfig, | ||
| } | ||
| const requestOptions = { | ||
| return { | ||
| ...this.clientConfig, | ||
| ...options | ||
| }; | ||
| return requestOptions; | ||
| } | ||
@@ -371,7 +369,6 @@ _convertChatOpenAIToolToCompletionsTool(tool, fields) { | ||
| async _getNumTokensFromGenerations(generations) { | ||
| const generationUsages = await Promise.all(generations.map(async (generation) => { | ||
| return (await Promise.all(generations.map(async (generation) => { | ||
| if (generation.message.additional_kwargs?.function_call) return (await this.getNumTokensFromMessages([generation.message])).countPerMessage[0]; | ||
| else return await this.getNumTokens(generation.message.content); | ||
| })); | ||
| return generationUsages.reduce((a, b) => a + b, 0); | ||
| }))).reduce((a, b) => a + b, 0); | ||
| } | ||
@@ -431,14 +428,11 @@ /** @internal */ | ||
| const clientOptions = this._getClientOptions(params?.options); | ||
| const moderationModel = params?.model ?? "omni-moderation-latest"; | ||
| const moderationRequest = { | ||
| input, | ||
| model: moderationModel | ||
| model: params?.model ?? "omni-moderation-latest" | ||
| }; | ||
| return this.caller.call(async () => { | ||
| try { | ||
| const response = await this.client.moderations.create(moderationRequest, clientOptions); | ||
| return response; | ||
| return await this.client.moderations.create(moderationRequest, clientOptions); | ||
| } catch (e) { | ||
| const error = wrapOpenAIClientError(e); | ||
| throw error; | ||
| throw wrapOpenAIClientError(e); | ||
| } | ||
@@ -465,3 +459,3 @@ }); | ||
| get profile() { | ||
| return profiles_default[this.model] ?? {}; | ||
| return PROFILES[this.model] ?? {}; | ||
| } | ||
@@ -621,3 +615,3 @@ /** @internal */ | ||
| if (!includeRaw) return llm.pipe(outputParser); | ||
| const parserAssign = RunnablePassthrough.assign({ parsed: (input, config$1) => outputParser.invoke(input.raw, config$1) }); | ||
| const parserAssign = RunnablePassthrough.assign({ parsed: (input, config) => outputParser.invoke(input.raw, config) }); | ||
| const parserNone = RunnablePassthrough.assign({ parsed: () => null }); | ||
@@ -624,0 +618,0 @@ const parsedWithFallback = parserAssign.withFallbacks({ fallbacks: [parserNone] }); |
@@ -1,2 +0,1 @@ | ||
| const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs'); | ||
| const require_client = require('../utils/client.cjs'); | ||
@@ -7,4 +6,4 @@ const require_tools = require('../utils/tools.cjs'); | ||
| const require_completions = require('../converters/completions.cjs'); | ||
| const __langchain_core_messages = require_rolldown_runtime.__toESM(require("@langchain/core/messages")); | ||
| const __langchain_core_outputs = require_rolldown_runtime.__toESM(require("@langchain/core/outputs")); | ||
| let _langchain_core_messages = require("@langchain/core/messages"); | ||
| let _langchain_core_outputs = require("@langchain/core/outputs"); | ||
@@ -120,5 +119,4 @@ //#region src/chat_models/completions.ts | ||
| for (const part of data?.choices ?? []) { | ||
| const text = part.message?.content ?? ""; | ||
| const generation = { | ||
| text, | ||
| text: part.message?.content ?? "", | ||
| message: this._convertCompletionsMessageToBaseMessage(part.message ?? { role: "assistant" }, data) | ||
@@ -130,4 +128,4 @@ }; | ||
| }; | ||
| if ((0, __langchain_core_messages.isAIMessage)(generation.message)) generation.message.usage_metadata = usageMetadata; | ||
| generation.message = new __langchain_core_messages.AIMessage(Object.fromEntries(Object.entries(generation.message).filter(([key]) => !key.startsWith("lc_")))); | ||
| if ((0, _langchain_core_messages.isAIMessage)(generation.message)) generation.message.usage_metadata = usageMetadata; | ||
| generation.message = new _langchain_core_messages.AIMessage(Object.fromEntries(Object.entries(generation.message).filter(([key]) => !key.startsWith("lc_")))); | ||
| generations.push(generation); | ||
@@ -183,3 +181,3 @@ } | ||
| if (this.logprobs) generationInfo.logprobs = choice.logprobs; | ||
| const generationChunk = new __langchain_core_outputs.ChatGenerationChunk({ | ||
| const generationChunk = new _langchain_core_outputs.ChatGenerationChunk({ | ||
| message: chunk, | ||
@@ -201,4 +199,4 @@ text: chunk.content, | ||
| }; | ||
| const generationChunk = new __langchain_core_outputs.ChatGenerationChunk({ | ||
| message: new __langchain_core_messages.AIMessageChunk({ | ||
| yield new _langchain_core_outputs.ChatGenerationChunk({ | ||
| message: new _langchain_core_messages.AIMessageChunk({ | ||
| content: "", | ||
@@ -216,3 +214,2 @@ response_metadata: { usage: { ...usage } }, | ||
| }); | ||
| yield generationChunk; | ||
| } | ||
@@ -229,4 +226,3 @@ if (options.signal?.aborted) throw new Error("AbortError"); | ||
| } catch (e) { | ||
| const error = require_client.wrapOpenAIClientError(e); | ||
| throw error; | ||
| throw require_client.wrapOpenAIClientError(e); | ||
| } | ||
@@ -233,0 +229,0 @@ }); |
@@ -118,5 +118,4 @@ import { wrapOpenAIClientError } from "../utils/client.js"; | ||
| for (const part of data?.choices ?? []) { | ||
| const text = part.message?.content ?? ""; | ||
| const generation = { | ||
| text, | ||
| text: part.message?.content ?? "", | ||
| message: this._convertCompletionsMessageToBaseMessage(part.message ?? { role: "assistant" }, data) | ||
@@ -197,3 +196,3 @@ }; | ||
| }; | ||
| const generationChunk = new ChatGenerationChunk({ | ||
| yield new ChatGenerationChunk({ | ||
| message: new AIMessageChunk({ | ||
@@ -212,3 +211,2 @@ content: "", | ||
| }); | ||
| yield generationChunk; | ||
| } | ||
@@ -225,4 +223,3 @@ if (options.signal?.aborted) throw new Error("AbortError"); | ||
| } catch (e) { | ||
| const error = wrapOpenAIClientError(e); | ||
| throw error; | ||
| throw wrapOpenAIClientError(e); | ||
| } | ||
@@ -229,0 +226,0 @@ }); |
@@ -563,6 +563,5 @@ | ||
| }; | ||
| var profiles_default = PROFILES; | ||
| //#endregion | ||
| exports.default = profiles_default; | ||
| exports.default = PROFILES; | ||
| //# sourceMappingURL=profiles.cjs.map |
@@ -562,6 +562,5 @@ //#region src/chat_models/profiles.ts | ||
| }; | ||
| var profiles_default = PROFILES; | ||
| //#endregion | ||
| export { profiles_default as default }; | ||
| export { PROFILES as default }; | ||
| //# sourceMappingURL=profiles.js.map |
@@ -1,2 +0,1 @@ | ||
| const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs'); | ||
| const require_client = require('../utils/client.cjs'); | ||
@@ -6,3 +5,3 @@ const require_tools = require('../utils/tools.cjs'); | ||
| const require_responses = require('../converters/responses.cjs'); | ||
| const __langchain_core_language_models_base = require_rolldown_runtime.__toESM(require("@langchain/core/language_models/base")); | ||
| let _langchain_core_language_models_base = require("@langchain/core/language_models/base"); | ||
@@ -53,3 +52,2 @@ //#region src/chat_models/responses.ts | ||
| } | ||
| return void 0; | ||
| })(), | ||
@@ -70,3 +68,3 @@ text: (() => { | ||
| }; | ||
| return void 0; | ||
| return; | ||
| } | ||
@@ -163,4 +161,3 @@ return { | ||
| } catch (e) { | ||
| const error = require_client.wrapOpenAIClientError(e); | ||
| throw error; | ||
| throw require_client.wrapOpenAIClientError(e); | ||
| } | ||
@@ -183,3 +180,3 @@ }); | ||
| }); | ||
| } else if ((0, __langchain_core_language_models_base.isOpenAITool)(tool)) reducedTools.push({ | ||
| } else if ((0, _langchain_core_language_models_base.isOpenAITool)(tool)) reducedTools.push({ | ||
| type: "function", | ||
@@ -186,0 +183,0 @@ name: tool.function.name, |
@@ -51,3 +51,2 @@ import { wrapOpenAIClientError } from "../utils/client.js"; | ||
| } | ||
| return void 0; | ||
| })(), | ||
@@ -68,3 +67,3 @@ text: (() => { | ||
| }; | ||
| return void 0; | ||
| return; | ||
| } | ||
@@ -161,4 +160,3 @@ return { | ||
| } catch (e) { | ||
| const error = wrapOpenAIClientError(e); | ||
| throw error; | ||
| throw wrapOpenAIClientError(e); | ||
| } | ||
@@ -165,0 +163,0 @@ }); |
@@ -1,6 +0,5 @@ | ||
| const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs'); | ||
| const require_misc = require('../utils/misc.cjs'); | ||
| const require_output = require('../utils/output.cjs'); | ||
| const __langchain_core_messages = require_rolldown_runtime.__toESM(require("@langchain/core/messages")); | ||
| const __langchain_core_output_parsers_openai_tools = require_rolldown_runtime.__toESM(require("@langchain/core/output_parsers/openai_tools")); | ||
| let _langchain_core_messages = require("@langchain/core/messages"); | ||
| let _langchain_core_output_parsers_openai_tools = require("@langchain/core/output_parsers/openai_tools"); | ||
@@ -27,12 +26,9 @@ //#region src/converters/completions.ts | ||
| }; | ||
| if (block.source_type === "base64") { | ||
| const url = `data:${block.mime_type ?? ""};base64,${block.data}`; | ||
| return { | ||
| type: "image_url", | ||
| image_url: { | ||
| url, | ||
| ...block.metadata?.detail ? { detail: block.metadata.detail } : {} | ||
| } | ||
| }; | ||
| } | ||
| if (block.source_type === "base64") return { | ||
| type: "image_url", | ||
| image_url: { | ||
| url: `data:${block.mime_type ?? ""};base64,${block.data}`, | ||
| ...block.metadata?.detail ? { detail: block.metadata.detail } : {} | ||
| } | ||
| }; | ||
| throw new Error(`Image content blocks with source_type ${block.source_type} are not supported for ChatOpenAI`); | ||
@@ -42,3 +38,3 @@ }, | ||
| if (block.source_type === "url") { | ||
| const data = (0, __langchain_core_messages.parseBase64DataUrl)({ dataUrl: block.url }); | ||
| const data = (0, _langchain_core_messages.parseBase64DataUrl)({ dataUrl: block.url }); | ||
| if (!data) throw new Error(`URL audio blocks with source_type ${block.source_type} must be formatted as a data URL for ChatOpenAI`); | ||
@@ -48,3 +44,3 @@ const rawMimeType = data.mime_type || block.mime_type || ""; | ||
| try { | ||
| mimeType = (0, __langchain_core_messages.parseMimeType)(rawMimeType); | ||
| mimeType = (0, _langchain_core_messages.parseMimeType)(rawMimeType); | ||
| } catch { | ||
@@ -65,3 +61,3 @@ throw new Error(`Audio blocks with source_type ${block.source_type} must have mime type of audio/wav or audio/mp3`); | ||
| try { | ||
| mimeType = (0, __langchain_core_messages.parseMimeType)(block.mime_type ?? ""); | ||
| mimeType = (0, _langchain_core_messages.parseMimeType)(block.mime_type ?? ""); | ||
| } catch { | ||
@@ -83,3 +79,3 @@ throw new Error(`Audio blocks with source_type ${block.source_type} must have mime type of audio/wav or audio/mp3`); | ||
| if (block.source_type === "url") { | ||
| const data = (0, __langchain_core_messages.parseBase64DataUrl)({ dataUrl: block.url }); | ||
| const data = (0, _langchain_core_messages.parseBase64DataUrl)({ dataUrl: block.url }); | ||
| const filename = require_misc.getRequiredFilenameFromMetadata(block); | ||
@@ -175,5 +171,5 @@ if (!data) throw new Error(`URL file blocks with source_type ${block.source_type} must be formatted as a data URL for ChatOpenAI`); | ||
| for (const rawToolCall of rawToolCalls ?? []) try { | ||
| toolCalls.push((0, __langchain_core_output_parsers_openai_tools.parseToolCall)(rawToolCall, { returnId: true })); | ||
| toolCalls.push((0, _langchain_core_output_parsers_openai_tools.parseToolCall)(rawToolCall, { returnId: true })); | ||
| } catch (e) { | ||
| invalidToolCalls.push((0, __langchain_core_output_parsers_openai_tools.makeInvalidToolCall)(rawToolCall, e.message)); | ||
| invalidToolCalls.push((0, _langchain_core_output_parsers_openai_tools.makeInvalidToolCall)(rawToolCall, e.message)); | ||
| } | ||
@@ -194,5 +190,4 @@ const additional_kwargs = { | ||
| if (message.audio) additional_kwargs.audio = message.audio; | ||
| const content = require_output.handleMultiModalOutput(message.content || "", rawResponse.choices?.[0]?.message); | ||
| return new __langchain_core_messages.AIMessage({ | ||
| content, | ||
| return new _langchain_core_messages.AIMessage({ | ||
| content: require_output.handleMultiModalOutput(message.content || "", rawResponse.choices?.[0]?.message), | ||
| tool_calls: toolCalls, | ||
@@ -205,3 +200,3 @@ invalid_tool_calls: invalidToolCalls, | ||
| } | ||
| default: return new __langchain_core_messages.ChatMessage(message.content || "", message.role ?? "unknown"); | ||
| default: return new _langchain_core_messages.ChatMessage(message.content || "", message.role ?? "unknown"); | ||
| } | ||
@@ -284,3 +279,3 @@ }; | ||
| }; | ||
| if (role === "user") return new __langchain_core_messages.HumanMessageChunk({ | ||
| if (role === "user") return new _langchain_core_messages.HumanMessageChunk({ | ||
| content, | ||
@@ -298,3 +293,3 @@ response_metadata | ||
| }); | ||
| return new __langchain_core_messages.AIMessageChunk({ | ||
| return new _langchain_core_messages.AIMessageChunk({ | ||
| content, | ||
@@ -306,7 +301,7 @@ tool_call_chunks: toolCallChunks, | ||
| }); | ||
| } else if (role === "system") return new __langchain_core_messages.SystemMessageChunk({ | ||
| } else if (role === "system") return new _langchain_core_messages.SystemMessageChunk({ | ||
| content, | ||
| response_metadata | ||
| }); | ||
| else if (role === "developer") return new __langchain_core_messages.SystemMessageChunk({ | ||
| else if (role === "developer") return new _langchain_core_messages.SystemMessageChunk({ | ||
| content, | ||
@@ -316,3 +311,3 @@ response_metadata, | ||
| }); | ||
| else if (role === "function") return new __langchain_core_messages.FunctionMessageChunk({ | ||
| else if (role === "function") return new _langchain_core_messages.FunctionMessageChunk({ | ||
| content, | ||
@@ -323,3 +318,3 @@ additional_kwargs, | ||
| }); | ||
| else if (role === "tool") return new __langchain_core_messages.ToolMessageChunk({ | ||
| else if (role === "tool") return new _langchain_core_messages.ToolMessageChunk({ | ||
| content, | ||
@@ -330,3 +325,3 @@ additional_kwargs, | ||
| }); | ||
| else return new __langchain_core_messages.ChatMessageChunk({ | ||
| else return new _langchain_core_messages.ChatMessageChunk({ | ||
| content, | ||
@@ -378,5 +373,5 @@ role, | ||
| if (block.data) { | ||
| const format = (0, __langchain_core_messages.iife)(() => { | ||
| const [, format$1] = block.mimeType.split("/"); | ||
| if (format$1 === "wav" || format$1 === "mp3") return format$1; | ||
| const format = (0, _langchain_core_messages.iife)(() => { | ||
| const [, format] = block.mimeType.split("/"); | ||
| if (format === "wav" || format === "mp3") return format; | ||
| return "wav"; | ||
@@ -409,3 +404,2 @@ }); | ||
| } | ||
| return void 0; | ||
| }; | ||
@@ -492,3 +486,3 @@ /** | ||
| }; | ||
| else if (role === "tool" && __langchain_core_messages.ToolMessage.isInstance(message)) return { | ||
| else if (role === "tool" && _langchain_core_messages.ToolMessage.isInstance(message)) return { | ||
| role: "tool", | ||
@@ -595,3 +589,3 @@ tool_call_id: message.tool_call_id, | ||
| const content = typeof message.content === "string" ? message.content : message.content.flatMap((m) => { | ||
| if ((0, __langchain_core_messages.isDataContentBlock)(m)) return (0, __langchain_core_messages.convertToProviderContentBlock)(m, completionsApiContentBlockConverter); | ||
| if ((0, _langchain_core_messages.isDataContentBlock)(m)) return (0, _langchain_core_messages.convertToProviderContentBlock)(m, completionsApiContentBlockConverter); | ||
| if (typeof m === "object" && m !== null && "type" in m && m.type === "tool_use") return []; | ||
@@ -606,14 +600,11 @@ return m; | ||
| if (message.additional_kwargs.function_call != null) completionParam.function_call = message.additional_kwargs.function_call; | ||
| if (__langchain_core_messages.AIMessage.isInstance(message) && !!message.tool_calls?.length) completionParam.tool_calls = message.tool_calls.map(__langchain_core_output_parsers_openai_tools.convertLangChainToolCallToOpenAI); | ||
| if (_langchain_core_messages.AIMessage.isInstance(message) && !!message.tool_calls?.length) completionParam.tool_calls = message.tool_calls.map(_langchain_core_output_parsers_openai_tools.convertLangChainToolCallToOpenAI); | ||
| else { | ||
| if (message.additional_kwargs.tool_calls != null) completionParam.tool_calls = message.additional_kwargs.tool_calls; | ||
| if (__langchain_core_messages.ToolMessage.isInstance(message) && message.tool_call_id != null) completionParam.tool_call_id = message.tool_call_id; | ||
| if (_langchain_core_messages.ToolMessage.isInstance(message) && message.tool_call_id != null) completionParam.tool_call_id = message.tool_call_id; | ||
| } | ||
| if (message.additional_kwargs.audio && typeof message.additional_kwargs.audio === "object" && "id" in message.additional_kwargs.audio) { | ||
| const audioMessage = { | ||
| role: "assistant", | ||
| audio: { id: message.additional_kwargs.audio.id } | ||
| }; | ||
| return [completionParam, audioMessage]; | ||
| } | ||
| if (message.additional_kwargs.audio && typeof message.additional_kwargs.audio === "object" && "id" in message.additional_kwargs.audio) return [completionParam, { | ||
| role: "assistant", | ||
| audio: { id: message.additional_kwargs.audio.id } | ||
| }]; | ||
| return completionParam; | ||
@@ -620,0 +611,0 @@ }); |
@@ -7,3 +7,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/converters/completions.d.ts | ||
| /** | ||
@@ -10,0 +9,0 @@ * @deprecated This converter is an internal detail of the OpenAI provider. Do not use it directly. This will be revisited in a future release. |
@@ -7,3 +7,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/converters/completions.d.ts | ||
| /** | ||
@@ -10,0 +9,0 @@ * @deprecated This converter is an internal detail of the OpenAI provider. Do not use it directly. This will be revisited in a future release. |
@@ -26,12 +26,9 @@ import { getRequiredFilenameFromMetadata, isReasoningModel, messageToOpenAIRole } from "../utils/misc.js"; | ||
| }; | ||
| if (block.source_type === "base64") { | ||
| const url = `data:${block.mime_type ?? ""};base64,${block.data}`; | ||
| return { | ||
| type: "image_url", | ||
| image_url: { | ||
| url, | ||
| ...block.metadata?.detail ? { detail: block.metadata.detail } : {} | ||
| } | ||
| }; | ||
| } | ||
| if (block.source_type === "base64") return { | ||
| type: "image_url", | ||
| image_url: { | ||
| url: `data:${block.mime_type ?? ""};base64,${block.data}`, | ||
| ...block.metadata?.detail ? { detail: block.metadata.detail } : {} | ||
| } | ||
| }; | ||
| throw new Error(`Image content blocks with source_type ${block.source_type} are not supported for ChatOpenAI`); | ||
@@ -188,5 +185,4 @@ }, | ||
| if (message.audio) additional_kwargs.audio = message.audio; | ||
| const content = handleMultiModalOutput(message.content || "", rawResponse.choices?.[0]?.message); | ||
| return new AIMessage({ | ||
| content, | ||
| content: handleMultiModalOutput(message.content || "", rawResponse.choices?.[0]?.message), | ||
| tool_calls: toolCalls, | ||
@@ -366,4 +362,4 @@ invalid_tool_calls: invalidToolCalls, | ||
| const format = iife(() => { | ||
| const [, format$1] = block.mimeType.split("/"); | ||
| if (format$1 === "wav" || format$1 === "mp3") return format$1; | ||
| const [, format] = block.mimeType.split("/"); | ||
| if (format === "wav" || format === "mp3") return format; | ||
| return "wav"; | ||
@@ -396,3 +392,2 @@ }); | ||
| } | ||
| return void 0; | ||
| }; | ||
@@ -596,9 +591,6 @@ /** | ||
| } | ||
| if (message.additional_kwargs.audio && typeof message.additional_kwargs.audio === "object" && "id" in message.additional_kwargs.audio) { | ||
| const audioMessage = { | ||
| role: "assistant", | ||
| audio: { id: message.additional_kwargs.audio.id } | ||
| }; | ||
| return [completionParam, audioMessage]; | ||
| } | ||
| if (message.additional_kwargs.audio && typeof message.additional_kwargs.audio === "object" && "id" in message.additional_kwargs.audio) return [completionParam, { | ||
| role: "assistant", | ||
| audio: { id: message.additional_kwargs.audio.id } | ||
| }]; | ||
| return completionParam; | ||
@@ -605,0 +597,0 @@ }); |
| import { completionsApiContentBlockConverter, convertCompletionsDeltaToBaseMessageChunk, convertCompletionsMessageToBaseMessage, convertMessagesToCompletionsMessageParams, convertStandardContentBlockToCompletionsContentPart, convertStandardContentMessageToCompletionsMessage } from "./completions.js"; | ||
| import { convertMessagesToResponsesInput, convertReasoningSummaryToResponsesReasoningItem, convertResponsesDeltaToChatGenerationChunk, convertResponsesMessageToAIMessage, convertResponsesUsageToUsageMetadata, convertStandardContentMessageToResponsesInput } from "./responses.js"; | ||
| export { }; |
@@ -1,8 +0,7 @@ | ||
| const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs'); | ||
| const require_tools = require('../utils/tools.cjs'); | ||
| const require_misc = require('../utils/misc.cjs'); | ||
| const require_completions = require('./completions.cjs'); | ||
| const __langchain_core_messages = require_rolldown_runtime.__toESM(require("@langchain/core/messages")); | ||
| const __langchain_core_outputs = require_rolldown_runtime.__toESM(require("@langchain/core/outputs")); | ||
| const __langchain_core_output_parsers_openai_tools = require_rolldown_runtime.__toESM(require("@langchain/core/output_parsers/openai_tools")); | ||
| let _langchain_core_messages = require("@langchain/core/messages"); | ||
| let _langchain_core_outputs = require("@langchain/core/outputs"); | ||
| let _langchain_core_output_parsers_openai_tools = require("@langchain/core/output_parsers/openai_tools"); | ||
@@ -268,7 +267,7 @@ //#region src/converters/responses.ts | ||
| try { | ||
| tool_calls.push((0, __langchain_core_output_parsers_openai_tools.parseToolCall)(fnAdapter, { returnId: true })); | ||
| tool_calls.push((0, _langchain_core_output_parsers_openai_tools.parseToolCall)(fnAdapter, { returnId: true })); | ||
| } catch (e) { | ||
| let errMessage; | ||
| if (typeof e === "object" && e != null && "message" in e && typeof e.message === "string") errMessage = e.message; | ||
| invalid_tool_calls.push((0, __langchain_core_output_parsers_openai_tools.makeInvalidToolCall)(fnAdapter, errMessage)); | ||
| invalid_tool_calls.push((0, _langchain_core_output_parsers_openai_tools.makeInvalidToolCall)(fnAdapter, errMessage)); | ||
| } | ||
@@ -287,7 +286,7 @@ additional_kwargs[_FUNCTION_CALL_IDS_MAP_KEY] ??= {}; | ||
| if (parsed) tool_calls.push(parsed); | ||
| else invalid_tool_calls.push((0, __langchain_core_output_parsers_openai_tools.makeInvalidToolCall)(item, "Malformed custom tool call")); | ||
| else invalid_tool_calls.push((0, _langchain_core_output_parsers_openai_tools.makeInvalidToolCall)(item, "Malformed custom tool call")); | ||
| } else if (item.type === "computer_call") { | ||
| const parsed = require_tools.parseComputerCall(item); | ||
| if (parsed) tool_calls.push(parsed); | ||
| else invalid_tool_calls.push((0, __langchain_core_output_parsers_openai_tools.makeInvalidToolCall)(item, "Malformed computer call")); | ||
| else invalid_tool_calls.push((0, _langchain_core_output_parsers_openai_tools.makeInvalidToolCall)(item, "Malformed computer call")); | ||
| } else if (item.type === "image_generation_call") { | ||
@@ -307,3 +306,3 @@ if (item.result) content.push({ | ||
| } | ||
| return new __langchain_core_messages.AIMessage({ | ||
| return new _langchain_core_messages.AIMessage({ | ||
| id: messageId, | ||
@@ -568,5 +567,5 @@ content, | ||
| else return null; | ||
| return new __langchain_core_outputs.ChatGenerationChunk({ | ||
| return new _langchain_core_outputs.ChatGenerationChunk({ | ||
| text: content.map((part) => part.text).join(""), | ||
| message: new __langchain_core_messages.AIMessageChunk({ | ||
| message: new _langchain_core_messages.AIMessageChunk({ | ||
| id, | ||
@@ -622,3 +621,3 @@ content, | ||
| const convertStandardContentMessageToResponsesInput = (message) => { | ||
| const isResponsesMessage = __langchain_core_messages.AIMessage.isInstance(message) && message.response_metadata?.model_provider === "openai"; | ||
| const isResponsesMessage = _langchain_core_messages.AIMessage.isInstance(message) && message.response_metadata?.model_provider === "openai"; | ||
| function* iterateItems() { | ||
@@ -683,10 +682,8 @@ const messageRole = require_misc.iife(() => { | ||
| const base64Data = typeof block.data === "string" ? block.data : Buffer.from(block.data).toString("base64"); | ||
| const mimeType = block.mimeType ?? "image/png"; | ||
| return { | ||
| type: "input_image", | ||
| detail, | ||
| image_url: `data:${mimeType};base64,${base64Data}` | ||
| image_url: `data:${block.mimeType ?? "image/png"};base64,${base64Data}` | ||
| }; | ||
| } | ||
| return void 0; | ||
| }; | ||
@@ -713,10 +710,8 @@ const resolveFileItem = (block) => { | ||
| const encoded = typeof block.data === "string" ? block.data : Buffer.from(block.data).toString("base64"); | ||
| const mimeType = block.mimeType ?? "application/octet-stream"; | ||
| return { | ||
| type: "input_file", | ||
| file_data: `data:${mimeType};base64,${encoded}`, | ||
| file_data: `data:${block.mimeType ?? "application/octet-stream"};base64,${encoded}`, | ||
| ...filename ? { filename } : {} | ||
| }; | ||
| } | ||
| return void 0; | ||
| }; | ||
@@ -726,4 +721,3 @@ const convertReasoningBlock = (block) => { | ||
| if (Array.isArray(block.summary)) { | ||
| const candidate = block.summary; | ||
| const mapped = candidate?.map((item) => item?.text).filter((text) => typeof text === "string") ?? []; | ||
| const mapped = block.summary?.map((item) => item?.text).filter((text) => typeof text === "string") ?? []; | ||
| if (mapped.length > 0) return mapped; | ||
@@ -897,4 +891,10 @@ } | ||
| const toolMessage = lcMsg; | ||
| if (additional_kwargs?.type === "computer_call_output") { | ||
| const output = (() => { | ||
| if (additional_kwargs?.type === "computer_call_output") | ||
| /** | ||
| * Cast needed because OpenAI SDK types don't yet include input_image | ||
| * for computer-use-preview model output format | ||
| */ | ||
| return { | ||
| type: "computer_call_output", | ||
| output: (() => { | ||
| if (typeof toolMessage.content === "string") return { | ||
@@ -925,13 +925,5 @@ type: "input_image", | ||
| throw new Error("Invalid computer call output"); | ||
| })(); | ||
| /** | ||
| * Cast needed because OpenAI SDK types don't yet include input_image | ||
| * for computer-use-preview model output format | ||
| */ | ||
| return { | ||
| type: "computer_call_output", | ||
| output, | ||
| call_id: toolMessage.tool_call_id | ||
| }; | ||
| } | ||
| })(), | ||
| call_id: toolMessage.tool_call_id | ||
| }; | ||
| if (toolMessage.additional_kwargs?.customTool) return { | ||
@@ -994,3 +986,3 @@ type: "custom_tool_call_output", | ||
| const functionCallIds = additional_kwargs?.[_FUNCTION_CALL_IDS_MAP_KEY]; | ||
| if (__langchain_core_messages.AIMessage.isInstance(lcMsg) && !!lcMsg.tool_calls?.length) input.push(...lcMsg.tool_calls.map((toolCall) => { | ||
| if (_langchain_core_messages.AIMessage.isInstance(lcMsg) && !!lcMsg.tool_calls?.length) input.push(...lcMsg.tool_calls.map((toolCall) => { | ||
| if (require_tools.isCustomToolCall(toolCall)) return { | ||
@@ -1034,4 +1026,3 @@ type: "custom_tool_call", | ||
| if (toolOutputs != null) { | ||
| const castToolOutputs = toolOutputs; | ||
| const fallthroughCalls = castToolOutputs?.filter((item) => fallthroughCallTypes.includes(item.type)); | ||
| const fallthroughCalls = toolOutputs?.filter((item) => fallthroughCallTypes.includes(item.type)); | ||
| if (fallthroughCalls.length > 0) input.push(...fallthroughCalls); | ||
@@ -1047,5 +1038,5 @@ } | ||
| }; | ||
| const messages$1 = []; | ||
| const messages = []; | ||
| const content = lcMsg.content.flatMap((item) => { | ||
| if (item.type === "mcp_approval_response") messages$1.push({ | ||
| if (item.type === "mcp_approval_response") messages.push({ | ||
| type: "mcp_approval_response", | ||
@@ -1055,3 +1046,3 @@ approval_request_id: item.approval_request_id, | ||
| }); | ||
| if ((0, __langchain_core_messages.isDataContentBlock)(item)) return (0, __langchain_core_messages.convertToProviderContentBlock)(item, require_completions.completionsApiContentBlockConverter); | ||
| if ((0, _langchain_core_messages.isDataContentBlock)(item)) return (0, _langchain_core_messages.convertToProviderContentBlock)(item, require_completions.completionsApiContentBlockConverter); | ||
| if (item.type === "text") return { | ||
@@ -1061,23 +1052,17 @@ type: "input_text", | ||
| }; | ||
| if (item.type === "image_url") { | ||
| const imageUrl = require_misc.iife(() => { | ||
| if (item.type === "image_url") return { | ||
| type: "input_image", | ||
| image_url: require_misc.iife(() => { | ||
| if (typeof item.image_url === "string") return item.image_url; | ||
| else if (typeof item.image_url === "object" && item.image_url !== null && "url" in item.image_url) return item.image_url.url; | ||
| return void 0; | ||
| }); | ||
| const detail = require_misc.iife(() => { | ||
| }), | ||
| detail: require_misc.iife(() => { | ||
| if (typeof item.image_url === "string") return "auto"; | ||
| else if (typeof item.image_url === "object" && item.image_url !== null && "detail" in item.image_url) return item.image_url.detail; | ||
| return void 0; | ||
| }); | ||
| return { | ||
| type: "input_image", | ||
| image_url: imageUrl, | ||
| detail | ||
| }; | ||
| } | ||
| }) | ||
| }; | ||
| if (item.type === "input_text" || item.type === "input_image" || item.type === "input_file") return item; | ||
| return []; | ||
| }); | ||
| if (content.length > 0) messages$1.push({ | ||
| if (content.length > 0) messages.push({ | ||
| type: "message", | ||
@@ -1087,3 +1072,3 @@ role, | ||
| }); | ||
| return messages$1; | ||
| return messages; | ||
| } | ||
@@ -1090,0 +1075,0 @@ console.warn(`Unsupported role found when converting to OpenAI Responses API: ${role}`); |
| import { isComputerToolCall, isCustomToolCall, parseComputerCall, parseCustomToolCall } from "../utils/tools.js"; | ||
| import { getFilenameFromMetadata, getRequiredFilenameFromMetadata, iife, isReasoningModel, messageToOpenAIRole } from "../utils/misc.js"; | ||
| import { getFilenameFromMetadata, getRequiredFilenameFromMetadata, iife as iife$1, isReasoningModel, messageToOpenAIRole } from "../utils/misc.js"; | ||
| import { completionsApiContentBlockConverter } from "./completions.js"; | ||
@@ -619,3 +619,3 @@ import { AIMessage, AIMessageChunk, convertToProviderContentBlock, isDataContentBlock } from "@langchain/core/messages"; | ||
| function* iterateItems() { | ||
| const messageRole = iife(() => { | ||
| const messageRole = iife$1(() => { | ||
| try { | ||
@@ -661,3 +661,3 @@ const role = messageToOpenAIRole(message); | ||
| const resolveImageItem = (block) => { | ||
| const detail = iife(() => { | ||
| const detail = iife$1(() => { | ||
| const raw = block.metadata?.detail; | ||
@@ -679,10 +679,8 @@ if (raw === "low" || raw === "high" || raw === "auto") return raw; | ||
| const base64Data = typeof block.data === "string" ? block.data : Buffer.from(block.data).toString("base64"); | ||
| const mimeType = block.mimeType ?? "image/png"; | ||
| return { | ||
| type: "input_image", | ||
| detail, | ||
| image_url: `data:${mimeType};base64,${base64Data}` | ||
| image_url: `data:${block.mimeType ?? "image/png"};base64,${base64Data}` | ||
| }; | ||
| } | ||
| return void 0; | ||
| }; | ||
@@ -709,16 +707,13 @@ const resolveFileItem = (block) => { | ||
| const encoded = typeof block.data === "string" ? block.data : Buffer.from(block.data).toString("base64"); | ||
| const mimeType = block.mimeType ?? "application/octet-stream"; | ||
| return { | ||
| type: "input_file", | ||
| file_data: `data:${mimeType};base64,${encoded}`, | ||
| file_data: `data:${block.mimeType ?? "application/octet-stream"};base64,${encoded}`, | ||
| ...filename ? { filename } : {} | ||
| }; | ||
| } | ||
| return void 0; | ||
| }; | ||
| const convertReasoningBlock = (block) => { | ||
| const summaryEntries = iife(() => { | ||
| const summaryEntries = iife$1(() => { | ||
| if (Array.isArray(block.summary)) { | ||
| const candidate = block.summary; | ||
| const mapped = candidate?.map((item) => item?.text).filter((text) => typeof text === "string") ?? []; | ||
| const mapped = block.summary?.map((item) => item?.text).filter((text) => typeof text === "string") ?? []; | ||
| if (mapped.length > 0) return mapped; | ||
@@ -892,4 +887,10 @@ } | ||
| const toolMessage = lcMsg; | ||
| if (additional_kwargs?.type === "computer_call_output") { | ||
| const output = (() => { | ||
| if (additional_kwargs?.type === "computer_call_output") | ||
| /** | ||
| * Cast needed because OpenAI SDK types don't yet include input_image | ||
| * for computer-use-preview model output format | ||
| */ | ||
| return { | ||
| type: "computer_call_output", | ||
| output: (() => { | ||
| if (typeof toolMessage.content === "string") return { | ||
@@ -920,13 +921,5 @@ type: "input_image", | ||
| throw new Error("Invalid computer call output"); | ||
| })(); | ||
| /** | ||
| * Cast needed because OpenAI SDK types don't yet include input_image | ||
| * for computer-use-preview model output format | ||
| */ | ||
| return { | ||
| type: "computer_call_output", | ||
| output, | ||
| call_id: toolMessage.tool_call_id | ||
| }; | ||
| } | ||
| })(), | ||
| call_id: toolMessage.tool_call_id | ||
| }; | ||
| if (toolMessage.additional_kwargs?.customTool) return { | ||
@@ -975,3 +968,3 @@ type: "custom_tool_call_output", | ||
| ...lcMsg.id && !zdrEnabled && lcMsg.id.startsWith("msg_") ? { id: lcMsg.id } : {}, | ||
| content: iife(() => { | ||
| content: iife$1(() => { | ||
| if (typeof content === "string") return content; | ||
@@ -1029,4 +1022,3 @@ return content.flatMap((item) => { | ||
| if (toolOutputs != null) { | ||
| const castToolOutputs = toolOutputs; | ||
| const fallthroughCalls = castToolOutputs?.filter((item) => fallthroughCallTypes.includes(item.type)); | ||
| const fallthroughCalls = toolOutputs?.filter((item) => fallthroughCallTypes.includes(item.type)); | ||
| if (fallthroughCalls.length > 0) input.push(...fallthroughCalls); | ||
@@ -1042,5 +1034,5 @@ } | ||
| }; | ||
| const messages$1 = []; | ||
| const messages = []; | ||
| const content = lcMsg.content.flatMap((item) => { | ||
| if (item.type === "mcp_approval_response") messages$1.push({ | ||
| if (item.type === "mcp_approval_response") messages.push({ | ||
| type: "mcp_approval_response", | ||
@@ -1055,23 +1047,17 @@ approval_request_id: item.approval_request_id, | ||
| }; | ||
| if (item.type === "image_url") { | ||
| const imageUrl = iife(() => { | ||
| if (item.type === "image_url") return { | ||
| type: "input_image", | ||
| image_url: iife$1(() => { | ||
| if (typeof item.image_url === "string") return item.image_url; | ||
| else if (typeof item.image_url === "object" && item.image_url !== null && "url" in item.image_url) return item.image_url.url; | ||
| return void 0; | ||
| }); | ||
| const detail = iife(() => { | ||
| }), | ||
| detail: iife$1(() => { | ||
| if (typeof item.image_url === "string") return "auto"; | ||
| else if (typeof item.image_url === "object" && item.image_url !== null && "detail" in item.image_url) return item.image_url.detail; | ||
| return void 0; | ||
| }); | ||
| return { | ||
| type: "input_image", | ||
| image_url: imageUrl, | ||
| detail | ||
| }; | ||
| } | ||
| }) | ||
| }; | ||
| if (item.type === "input_text" || item.type === "input_image" || item.type === "input_file") return item; | ||
| return []; | ||
| }); | ||
| if (content.length > 0) messages$1.push({ | ||
| if (content.length > 0) messages.push({ | ||
| type: "message", | ||
@@ -1081,3 +1067,3 @@ role, | ||
| }); | ||
| return messages$1; | ||
| return messages; | ||
| } | ||
@@ -1084,0 +1070,0 @@ console.warn(`Unsupported role found when converting to OpenAI Responses API: ${role}`); |
+11
-15
@@ -1,8 +0,7 @@ | ||
| const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs'); | ||
| const require_client = require('./utils/client.cjs'); | ||
| const require_azure = require('./utils/azure.cjs'); | ||
| const openai = require_rolldown_runtime.__toESM(require("openai")); | ||
| const __langchain_core_utils_env = require_rolldown_runtime.__toESM(require("@langchain/core/utils/env")); | ||
| const __langchain_core_utils_chunk_array = require_rolldown_runtime.__toESM(require("@langchain/core/utils/chunk_array")); | ||
| const __langchain_core_embeddings = require_rolldown_runtime.__toESM(require("@langchain/core/embeddings")); | ||
| let openai = require("openai"); | ||
| let _langchain_core_utils_env = require("@langchain/core/utils/env"); | ||
| let _langchain_core_utils_chunk_array = require("@langchain/core/utils/chunk_array"); | ||
| let _langchain_core_embeddings = require("@langchain/core/embeddings"); | ||
@@ -26,3 +25,3 @@ //#region src/embeddings.ts | ||
| */ | ||
| var OpenAIEmbeddings = class extends __langchain_core_embeddings.Embeddings { | ||
| var OpenAIEmbeddings = class extends _langchain_core_embeddings.Embeddings { | ||
| model = "text-embedding-ada-002"; | ||
@@ -50,4 +49,4 @@ /** @deprecated Use "model" instead */ | ||
| super(fieldsWithDefaults); | ||
| const apiKey = fieldsWithDefaults?.apiKey ?? fieldsWithDefaults?.openAIApiKey ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("OPENAI_API_KEY"); | ||
| this.organization = fieldsWithDefaults?.configuration?.organization ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("OPENAI_ORGANIZATION"); | ||
| const apiKey = fieldsWithDefaults?.apiKey ?? fieldsWithDefaults?.openAIApiKey ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("OPENAI_API_KEY"); | ||
| this.organization = fieldsWithDefaults?.configuration?.organization ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("OPENAI_ORGANIZATION"); | ||
| this.model = fieldsWithDefaults?.model ?? fieldsWithDefaults?.modelName ?? this.model; | ||
@@ -75,3 +74,3 @@ this.modelName = this.model; | ||
| async embedDocuments(texts) { | ||
| const batches = (0, __langchain_core_utils_chunk_array.chunkArray)(this.stripNewLines ? texts.map((t) => t.replace(/\n/g, " ")) : texts, this.batchSize); | ||
| const batches = (0, _langchain_core_utils_chunk_array.chunkArray)(this.stripNewLines ? texts.map((t) => t.replace(/\n/g, " ")) : texts, this.batchSize); | ||
| const batchRequests = batches.map((batch) => { | ||
@@ -120,4 +119,3 @@ const params = { | ||
| if (!this.client) { | ||
| const openAIEndpointConfig = { baseURL: this.clientConfig.baseURL }; | ||
| const endpoint = require_azure.getEndpoint(openAIEndpointConfig); | ||
| const endpoint = require_azure.getEndpoint({ baseURL: this.clientConfig.baseURL }); | ||
| const params = { | ||
@@ -136,7 +134,5 @@ ...this.clientConfig, | ||
| try { | ||
| const res = await this.client.embeddings.create(request, requestOptions); | ||
| return res; | ||
| return await this.client.embeddings.create(request, requestOptions); | ||
| } catch (e) { | ||
| const error = require_client.wrapOpenAIClientError(e); | ||
| throw error; | ||
| throw require_client.wrapOpenAIClientError(e); | ||
| } | ||
@@ -143,0 +139,0 @@ }); |
@@ -6,3 +6,2 @@ import { OpenAIApiKey } from "./types.cjs"; | ||
| //#region src/embeddings.d.ts | ||
| /** | ||
@@ -89,4 +88,3 @@ * @see https://platform.openai.com/docs/guides/embeddings#embedding-models | ||
| */ | ||
| openAIApiKey?: OpenAIApiKey; | ||
| /** The OpenAI API key to use. */ | ||
| openAIApiKey?: OpenAIApiKey; /** The OpenAI API key to use. */ | ||
| apiKey?: OpenAIApiKey; | ||
@@ -93,0 +91,0 @@ configuration?: ClientOptions; |
@@ -6,3 +6,2 @@ import { OpenAIApiKey } from "./types.js"; | ||
| //#region src/embeddings.d.ts | ||
| /** | ||
@@ -89,4 +88,3 @@ * @see https://platform.openai.com/docs/guides/embeddings#embedding-models | ||
| */ | ||
| openAIApiKey?: OpenAIApiKey; | ||
| /** The OpenAI API key to use. */ | ||
| openAIApiKey?: OpenAIApiKey; /** The OpenAI API key to use. */ | ||
| apiKey?: OpenAIApiKey; | ||
@@ -93,0 +91,0 @@ configuration?: ClientOptions; |
@@ -116,4 +116,3 @@ import { wrapOpenAIClientError } from "./utils/client.js"; | ||
| if (!this.client) { | ||
| const openAIEndpointConfig = { baseURL: this.clientConfig.baseURL }; | ||
| const endpoint = getEndpoint(openAIEndpointConfig); | ||
| const endpoint = getEndpoint({ baseURL: this.clientConfig.baseURL }); | ||
| const params = { | ||
@@ -132,7 +131,5 @@ ...this.clientConfig, | ||
| try { | ||
| const res = await this.client.embeddings.create(request, requestOptions); | ||
| return res; | ||
| return await this.client.embeddings.create(request, requestOptions); | ||
| } catch (e) { | ||
| const error = wrapOpenAIClientError(e); | ||
| throw error; | ||
| throw wrapOpenAIClientError(e); | ||
| } | ||
@@ -139,0 +136,0 @@ }); |
+2
-2
@@ -1,2 +0,2 @@ | ||
| const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs'); | ||
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const require_client = require('./utils/client.cjs'); | ||
@@ -23,3 +23,3 @@ const require_misc = require('./utils/misc.cjs'); | ||
| require('./converters/index.cjs'); | ||
| const openai = require_rolldown_runtime.__toESM(require("openai")); | ||
| let openai = require("openai"); | ||
@@ -26,0 +26,0 @@ exports.AzureChatOpenAI = require_index$1.AzureChatOpenAI; |
+27
-33
@@ -1,10 +0,9 @@ | ||
| const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs'); | ||
| const require_client = require('./utils/client.cjs'); | ||
| const require_azure = require('./utils/azure.cjs'); | ||
| const openai = require_rolldown_runtime.__toESM(require("openai")); | ||
| const __langchain_core_outputs = require_rolldown_runtime.__toESM(require("@langchain/core/outputs")); | ||
| const __langchain_core_utils_env = require_rolldown_runtime.__toESM(require("@langchain/core/utils/env")); | ||
| const __langchain_core_language_models_base = require_rolldown_runtime.__toESM(require("@langchain/core/language_models/base")); | ||
| const __langchain_core_language_models_llms = require_rolldown_runtime.__toESM(require("@langchain/core/language_models/llms")); | ||
| const __langchain_core_utils_chunk_array = require_rolldown_runtime.__toESM(require("@langchain/core/utils/chunk_array")); | ||
| let openai = require("openai"); | ||
| let _langchain_core_outputs = require("@langchain/core/outputs"); | ||
| let _langchain_core_utils_env = require("@langchain/core/utils/env"); | ||
| let _langchain_core_language_models_base = require("@langchain/core/language_models/base"); | ||
| let _langchain_core_language_models_llms = require("@langchain/core/language_models/llms"); | ||
| let _langchain_core_utils_chunk_array = require("@langchain/core/utils/chunk_array"); | ||
@@ -40,3 +39,3 @@ //#region src/llms.ts | ||
| */ | ||
| var OpenAI = class extends __langchain_core_language_models_llms.BaseLLM { | ||
| var OpenAI = class extends _langchain_core_language_models_llms.BaseLLM { | ||
| static lc_name() { | ||
@@ -88,5 +87,5 @@ return "OpenAI"; | ||
| super(fields ?? {}); | ||
| this.openAIApiKey = fields?.apiKey ?? fields?.openAIApiKey ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("OPENAI_API_KEY"); | ||
| this.openAIApiKey = fields?.apiKey ?? fields?.openAIApiKey ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("OPENAI_API_KEY"); | ||
| this.apiKey = this.openAIApiKey; | ||
| this.organization = fields?.configuration?.organization ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("OPENAI_ORGANIZATION"); | ||
| this.organization = fields?.configuration?.organization ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("OPENAI_ORGANIZATION"); | ||
| this.model = fields?.model ?? fields?.modelName ?? this.model; | ||
@@ -177,3 +176,3 @@ if ((this.model?.startsWith("gpt-3.5-turbo") || this.model?.startsWith("gpt-4") || this.model?.startsWith("o1")) && !this.model?.includes("-instruct")) throw new Error([ | ||
| async _generate(prompts, options, runManager) { | ||
| const subPrompts = (0, __langchain_core_utils_chunk_array.chunkArray)(prompts, this.batchSize); | ||
| const subPrompts = (0, _langchain_core_utils_chunk_array.chunkArray)(prompts, this.batchSize); | ||
| const choices = []; | ||
@@ -184,3 +183,3 @@ const tokenUsage = {}; | ||
| if (prompts.length !== 1) throw new Error("max_tokens set to -1 not supported for multiple inputs"); | ||
| params.max_tokens = await (0, __langchain_core_language_models_base.calculateMaxTokens)({ | ||
| params.max_tokens = await (0, _langchain_core_language_models_base.calculateMaxTokens)({ | ||
| prompt: prompts[0], | ||
@@ -192,3 +191,3 @@ modelName: this.model | ||
| const data = params.stream ? await (async () => { | ||
| const choices$1 = []; | ||
| const choices = []; | ||
| let response; | ||
@@ -208,5 +207,5 @@ const stream = await this.completionWithRetry({ | ||
| for (const part of message.choices) { | ||
| if (!choices$1[part.index]) choices$1[part.index] = part; | ||
| if (!choices[part.index]) choices[part.index] = part; | ||
| else { | ||
| const choice = choices$1[part.index]; | ||
| const choice = choices[part.index]; | ||
| choice.text += part.text; | ||
@@ -225,3 +224,3 @@ choice.finish_reason = part.finish_reason; | ||
| ...response, | ||
| choices: choices$1 | ||
| choices | ||
| }; | ||
@@ -246,11 +245,10 @@ })() : await this.completionWithRetry({ | ||
| } | ||
| const generations = (0, __langchain_core_utils_chunk_array.chunkArray)(choices, this.n).map((promptChoices) => promptChoices.map((choice) => ({ | ||
| text: choice.text ?? "", | ||
| generationInfo: { | ||
| finishReason: choice.finish_reason, | ||
| logprobs: choice.logprobs | ||
| } | ||
| }))); | ||
| return { | ||
| generations, | ||
| generations: (0, _langchain_core_utils_chunk_array.chunkArray)(choices, this.n).map((promptChoices) => promptChoices.map((choice) => ({ | ||
| text: choice.text ?? "", | ||
| generationInfo: { | ||
| finishReason: choice.finish_reason, | ||
| logprobs: choice.logprobs | ||
| } | ||
| }))), | ||
| llmOutput: { tokenUsage } | ||
@@ -269,3 +267,3 @@ }; | ||
| if (!choice) continue; | ||
| const chunk = new __langchain_core_outputs.GenerationChunk({ | ||
| const chunk = new _langchain_core_outputs.GenerationChunk({ | ||
| text: choice.text, | ||
@@ -283,7 +281,5 @@ generationInfo: { finishReason: choice.finish_reason } | ||
| try { | ||
| const res = await this.client.completions.create(request, requestOptions); | ||
| return res; | ||
| return await this.client.completions.create(request, requestOptions); | ||
| } catch (e) { | ||
| const error = require_client.wrapOpenAIClientError(e); | ||
| throw error; | ||
| throw require_client.wrapOpenAIClientError(e); | ||
| } | ||
@@ -300,4 +296,3 @@ }); | ||
| if (!this.client) { | ||
| const openAIEndpointConfig = { baseURL: this.clientConfig.baseURL }; | ||
| const endpoint = require_azure.getEndpoint(openAIEndpointConfig); | ||
| const endpoint = require_azure.getEndpoint({ baseURL: this.clientConfig.baseURL }); | ||
| const params = { | ||
@@ -313,7 +308,6 @@ ...this.clientConfig, | ||
| } | ||
| const requestOptions = { | ||
| return { | ||
| ...this.clientConfig, | ||
| ...options | ||
| }; | ||
| return requestOptions; | ||
| } | ||
@@ -320,0 +314,0 @@ _llmType() { |
+0
-1
@@ -8,3 +8,2 @@ import { OpenAIApiKey, OpenAICallOptions, OpenAICoreRequestOptions, OpenAIInput } from "./types.cjs"; | ||
| //#region src/llms.d.ts | ||
| /** | ||
@@ -11,0 +10,0 @@ * Wrapper around OpenAI large language models. |
+0
-1
@@ -8,3 +8,2 @@ import { OpenAIApiKey, OpenAICallOptions, OpenAICoreRequestOptions, OpenAIInput } from "./types.js"; | ||
| //#region src/llms.d.ts | ||
| /** | ||
@@ -11,0 +10,0 @@ * Wrapper around OpenAI large language models. |
+15
-20
@@ -187,3 +187,3 @@ import { wrapOpenAIClientError } from "./utils/client.js"; | ||
| const data = params.stream ? await (async () => { | ||
| const choices$1 = []; | ||
| const choices = []; | ||
| let response; | ||
@@ -203,5 +203,5 @@ const stream = await this.completionWithRetry({ | ||
| for (const part of message.choices) { | ||
| if (!choices$1[part.index]) choices$1[part.index] = part; | ||
| if (!choices[part.index]) choices[part.index] = part; | ||
| else { | ||
| const choice = choices$1[part.index]; | ||
| const choice = choices[part.index]; | ||
| choice.text += part.text; | ||
@@ -220,3 +220,3 @@ choice.finish_reason = part.finish_reason; | ||
| ...response, | ||
| choices: choices$1 | ||
| choices | ||
| }; | ||
@@ -241,11 +241,10 @@ })() : await this.completionWithRetry({ | ||
| } | ||
| const generations = chunkArray(choices, this.n).map((promptChoices) => promptChoices.map((choice) => ({ | ||
| text: choice.text ?? "", | ||
| generationInfo: { | ||
| finishReason: choice.finish_reason, | ||
| logprobs: choice.logprobs | ||
| } | ||
| }))); | ||
| return { | ||
| generations, | ||
| generations: chunkArray(choices, this.n).map((promptChoices) => promptChoices.map((choice) => ({ | ||
| text: choice.text ?? "", | ||
| generationInfo: { | ||
| finishReason: choice.finish_reason, | ||
| logprobs: choice.logprobs | ||
| } | ||
| }))), | ||
| llmOutput: { tokenUsage } | ||
@@ -277,7 +276,5 @@ }; | ||
| try { | ||
| const res = await this.client.completions.create(request, requestOptions); | ||
| return res; | ||
| return await this.client.completions.create(request, requestOptions); | ||
| } catch (e) { | ||
| const error = wrapOpenAIClientError(e); | ||
| throw error; | ||
| throw wrapOpenAIClientError(e); | ||
| } | ||
@@ -294,4 +291,3 @@ }); | ||
| if (!this.client) { | ||
| const openAIEndpointConfig = { baseURL: this.clientConfig.baseURL }; | ||
| const endpoint = getEndpoint(openAIEndpointConfig); | ||
| const endpoint = getEndpoint({ baseURL: this.clientConfig.baseURL }); | ||
| const params = { | ||
@@ -307,7 +303,6 @@ ...this.clientConfig, | ||
| } | ||
| const requestOptions = { | ||
| return { | ||
| ...this.clientConfig, | ||
| ...options | ||
| }; | ||
| return requestOptions; | ||
| } | ||
@@ -314,0 +309,0 @@ _llmType() { |
@@ -1,4 +0,3 @@ | ||
| const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs'); | ||
| const __langchain_core_tools = require_rolldown_runtime.__toESM(require("@langchain/core/tools")); | ||
| const zod_v4 = require_rolldown_runtime.__toESM(require("zod/v4")); | ||
| let _langchain_core_tools = require("@langchain/core/tools"); | ||
| let zod_v4 = require("zod/v4"); | ||
@@ -102,3 +101,3 @@ //#region src/tools/applyPatch.ts | ||
| function applyPatch(options) { | ||
| const patchTool = (0, __langchain_core_tools.tool)(options.execute, { | ||
| const patchTool = (0, _langchain_core_tools.tool)(options.execute, { | ||
| name: TOOL_NAME, | ||
@@ -105,0 +104,0 @@ description: "Apply structured diffs to create, update, or delete files in the codebase.", |
@@ -6,3 +6,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/tools/applyPatch.d.ts | ||
| /** | ||
@@ -9,0 +8,0 @@ * Re-export operation types from OpenAI SDK for convenience. |
@@ -6,3 +6,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/tools/applyPatch.d.ts | ||
| /** | ||
@@ -9,0 +8,0 @@ * Re-export operation types from OpenAI SDK for convenience. |
@@ -5,3 +5,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/tools/codeInterpreter.d.ts | ||
| /** | ||
@@ -8,0 +7,0 @@ * Memory limit options for the Code Interpreter container. |
@@ -5,3 +5,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/tools/codeInterpreter.d.ts | ||
| /** | ||
@@ -8,0 +7,0 @@ * Memory limit options for the Code Interpreter container. |
@@ -1,5 +0,4 @@ | ||
| const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs'); | ||
| const __langchain_core_messages = require_rolldown_runtime.__toESM(require("@langchain/core/messages")); | ||
| const __langchain_core_tools = require_rolldown_runtime.__toESM(require("@langchain/core/tools")); | ||
| const zod_v4 = require_rolldown_runtime.__toESM(require("zod/v4")); | ||
| let _langchain_core_messages = require("@langchain/core/messages"); | ||
| let _langchain_core_tools = require("@langchain/core/tools"); | ||
| let zod_v4 = require("zod/v4"); | ||
@@ -189,9 +188,4 @@ //#region src/tools/computerUse.ts | ||
| function computerUse(options) { | ||
| const computerTool = (0, __langchain_core_tools.tool)(async (input, runtime) => { | ||
| /** | ||
| * get computer_use call id from runtime | ||
| */ | ||
| const aiMessage = runtime.state?.messages.at(-1); | ||
| const computerToolCall = aiMessage?.tool_calls?.find((tc) => tc.name === "computer_use"); | ||
| const computerToolCallId = computerToolCall?.id; | ||
| const computerTool = (0, _langchain_core_tools.tool)(async (input, runtime) => { | ||
| const computerToolCallId = ((runtime.state?.messages.at(-1))?.tool_calls?.find((tc) => tc.name === "computer_use"))?.id; | ||
| if (!computerToolCallId) throw new Error("Computer use call id not found"); | ||
@@ -202,3 +196,3 @@ const result = await options.execute(input.action, runtime); | ||
| */ | ||
| if (typeof result === "string") return new __langchain_core_messages.ToolMessage({ | ||
| if (typeof result === "string") return new _langchain_core_messages.ToolMessage({ | ||
| content: result, | ||
@@ -211,3 +205,3 @@ tool_call_id: computerToolCallId, | ||
| */ | ||
| return new __langchain_core_messages.ToolMessage({ | ||
| return new _langchain_core_messages.ToolMessage({ | ||
| ...result, | ||
@@ -214,0 +208,0 @@ tool_call_id: computerToolCallId, |
@@ -7,3 +7,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/tools/computerUse.d.ts | ||
| /** | ||
@@ -10,0 +9,0 @@ * The type of computer environment to control. |
@@ -7,3 +7,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/tools/computerUse.d.ts | ||
| /** | ||
@@ -10,0 +9,0 @@ * The type of computer environment to control. |
@@ -189,8 +189,3 @@ import { ToolMessage } from "@langchain/core/messages"; | ||
| const computerTool = tool(async (input, runtime) => { | ||
| /** | ||
| * get computer_use call id from runtime | ||
| */ | ||
| const aiMessage = runtime.state?.messages.at(-1); | ||
| const computerToolCall = aiMessage?.tool_calls?.find((tc) => tc.name === "computer_use"); | ||
| const computerToolCallId = computerToolCall?.id; | ||
| const computerToolCallId = ((runtime.state?.messages.at(-1))?.tool_calls?.find((tc) => tc.name === "computer_use"))?.id; | ||
| if (!computerToolCallId) throw new Error("Computer use call id not found"); | ||
@@ -197,0 +192,0 @@ const result = await options.execute(input.action, runtime); |
@@ -1,9 +0,8 @@ | ||
| const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs'); | ||
| const __langchain_core_runnables = require_rolldown_runtime.__toESM(require("@langchain/core/runnables")); | ||
| const __langchain_core_tools = require_rolldown_runtime.__toESM(require("@langchain/core/tools")); | ||
| const __langchain_core_singletons = require_rolldown_runtime.__toESM(require("@langchain/core/singletons")); | ||
| let _langchain_core_runnables = require("@langchain/core/runnables"); | ||
| let _langchain_core_tools = require("@langchain/core/tools"); | ||
| let _langchain_core_singletons = require("@langchain/core/singletons"); | ||
| //#region src/tools/custom.ts | ||
| function customTool(func, fields) { | ||
| return new __langchain_core_tools.DynamicTool({ | ||
| return new _langchain_core_tools.DynamicTool({ | ||
| ...fields, | ||
@@ -13,4 +12,4 @@ description: "", | ||
| func: async (input, runManager, config) => new Promise((resolve, reject) => { | ||
| const childConfig = (0, __langchain_core_runnables.patchConfig)(config, { callbacks: runManager?.getChild() }); | ||
| __langchain_core_singletons.AsyncLocalStorageProviderSingleton.runWithConfig((0, __langchain_core_runnables.pickRunnableConfigKeys)(childConfig), async () => { | ||
| const childConfig = (0, _langchain_core_runnables.patchConfig)(config, { callbacks: runManager?.getChild() }); | ||
| _langchain_core_singletons.AsyncLocalStorageProviderSingleton.runWithConfig((0, _langchain_core_runnables.pickRunnableConfigKeys)(childConfig), async () => { | ||
| try { | ||
@@ -17,0 +16,0 @@ resolve(func(input, childConfig)); |
+10
-16
@@ -1,5 +0,4 @@ | ||
| const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs'); | ||
| const openai = require_rolldown_runtime.__toESM(require("openai")); | ||
| const __langchain_core_utils_env = require_rolldown_runtime.__toESM(require("@langchain/core/utils/env")); | ||
| const __langchain_core_tools = require_rolldown_runtime.__toESM(require("@langchain/core/tools")); | ||
| let openai = require("openai"); | ||
| let _langchain_core_utils_env = require("@langchain/core/utils/env"); | ||
| let _langchain_core_tools = require("@langchain/core/tools"); | ||
@@ -10,3 +9,3 @@ //#region src/tools/dalle.ts | ||
| */ | ||
| var DallEAPIWrapper = class extends __langchain_core_tools.Tool { | ||
| var DallEAPIWrapper = class extends _langchain_core_tools.Tool { | ||
| static lc_name() { | ||
@@ -32,11 +31,8 @@ return "DallEAPIWrapper"; | ||
| super(fields); | ||
| const openAIApiKey = fields?.apiKey ?? fields?.openAIApiKey ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("OPENAI_API_KEY"); | ||
| const organization = fields?.organization ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("OPENAI_ORGANIZATION"); | ||
| const clientConfig = { | ||
| apiKey: openAIApiKey, | ||
| organization, | ||
| this.client = new openai.OpenAI({ | ||
| apiKey: fields?.apiKey ?? fields?.openAIApiKey ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("OPENAI_API_KEY"), | ||
| organization: fields?.organization ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("OPENAI_ORGANIZATION"), | ||
| dangerouslyAllowBrowser: true, | ||
| baseURL: fields?.baseUrl | ||
| }; | ||
| this.client = new openai.OpenAI(clientConfig); | ||
| }); | ||
| this.model = fields?.model ?? fields?.modelName ?? this.model; | ||
@@ -62,3 +58,3 @@ this.style = fields?.style ?? this.style; | ||
| if (this.dallEResponseFormat === "url") return response.flatMap((res) => { | ||
| const imageUrlContent = res.data?.flatMap((item) => { | ||
| return res.data?.flatMap((item) => { | ||
| if (!item.url) return []; | ||
@@ -70,6 +66,5 @@ return { | ||
| }).filter((item) => item !== void 0 && item.type === "image_url" && typeof item.image_url === "string" && item.image_url !== void 0) ?? []; | ||
| return imageUrlContent; | ||
| }); | ||
| else return response.flatMap((res) => { | ||
| const b64Content = res.data?.flatMap((item) => { | ||
| return res.data?.flatMap((item) => { | ||
| if (!item.b64_json) return []; | ||
@@ -81,3 +76,2 @@ return { | ||
| }).filter((item) => item !== void 0 && item.type === "image_url" && typeof item.image_url === "object" && "url" in item.image_url && typeof item.image_url.url === "string" && item.image_url.url !== void 0) ?? []; | ||
| return b64Content; | ||
| }); | ||
@@ -84,0 +78,0 @@ } |
@@ -6,3 +6,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/tools/dalle.d.ts | ||
| /** | ||
@@ -9,0 +8,0 @@ * @see https://platform.openai.com/docs/api-reference/images/create |
@@ -6,3 +6,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/tools/dalle.d.ts | ||
| /** | ||
@@ -9,0 +8,0 @@ * @see https://platform.openai.com/docs/api-reference/images/create |
+6
-11
@@ -30,11 +30,8 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| super(fields); | ||
| const openAIApiKey = fields?.apiKey ?? fields?.openAIApiKey ?? getEnvironmentVariable("OPENAI_API_KEY"); | ||
| const organization = fields?.organization ?? getEnvironmentVariable("OPENAI_ORGANIZATION"); | ||
| const clientConfig = { | ||
| apiKey: openAIApiKey, | ||
| organization, | ||
| this.client = new OpenAI$1({ | ||
| apiKey: fields?.apiKey ?? fields?.openAIApiKey ?? getEnvironmentVariable("OPENAI_API_KEY"), | ||
| organization: fields?.organization ?? getEnvironmentVariable("OPENAI_ORGANIZATION"), | ||
| dangerouslyAllowBrowser: true, | ||
| baseURL: fields?.baseUrl | ||
| }; | ||
| this.client = new OpenAI$1(clientConfig); | ||
| }); | ||
| this.model = fields?.model ?? fields?.modelName ?? this.model; | ||
@@ -60,3 +57,3 @@ this.style = fields?.style ?? this.style; | ||
| if (this.dallEResponseFormat === "url") return response.flatMap((res) => { | ||
| const imageUrlContent = res.data?.flatMap((item) => { | ||
| return res.data?.flatMap((item) => { | ||
| if (!item.url) return []; | ||
@@ -68,6 +65,5 @@ return { | ||
| }).filter((item) => item !== void 0 && item.type === "image_url" && typeof item.image_url === "string" && item.image_url !== void 0) ?? []; | ||
| return imageUrlContent; | ||
| }); | ||
| else return response.flatMap((res) => { | ||
| const b64Content = res.data?.flatMap((item) => { | ||
| return res.data?.flatMap((item) => { | ||
| if (!item.b64_json) return []; | ||
@@ -79,3 +75,2 @@ return { | ||
| }).filter((item) => item !== void 0 && item.type === "image_url" && typeof item.image_url === "object" && "url" in item.image_url && typeof item.image_url.url === "string" && item.image_url.url !== void 0) ?? []; | ||
| return b64Content; | ||
| }); | ||
@@ -82,0 +77,0 @@ } |
@@ -5,3 +5,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/tools/fileSearch.d.ts | ||
| /** | ||
@@ -8,0 +7,0 @@ * Comparison operators for file attribute filtering. |
@@ -5,3 +5,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/tools/fileSearch.d.ts | ||
| /** | ||
@@ -8,0 +7,0 @@ * Comparison operators for file attribute filtering. |
@@ -5,3 +5,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/tools/imageGeneration.d.ts | ||
| /** | ||
@@ -8,0 +7,0 @@ * Optional mask for inpainting. Allows you to specify areas of the image |
@@ -5,3 +5,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/tools/imageGeneration.d.ts | ||
| /** | ||
@@ -8,0 +7,0 @@ * Optional mask for inpainting. Allows you to specify areas of the image |
@@ -13,3 +13,2 @@ import { DallEAPIWrapper, DallEAPIWrapperParams, OpenAIImageModelId } from "./dalle.cjs"; | ||
| //#region src/tools/index.d.ts | ||
| declare const tools: { | ||
@@ -16,0 +15,0 @@ webSearch: typeof webSearch; |
@@ -13,3 +13,2 @@ import { DallEAPIWrapper, DallEAPIWrapperParams, OpenAIImageModelId } from "./dalle.js"; | ||
| //#region src/tools/index.d.ts | ||
| declare const tools: { | ||
@@ -16,0 +15,0 @@ webSearch: typeof webSearch; |
@@ -1,4 +0,3 @@ | ||
| const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs'); | ||
| const __langchain_core_tools = require_rolldown_runtime.__toESM(require("@langchain/core/tools")); | ||
| const zod_v4 = require_rolldown_runtime.__toESM(require("zod/v4")); | ||
| let _langchain_core_tools = require("@langchain/core/tools"); | ||
| let zod_v4 = require("zod/v4"); | ||
@@ -131,3 +130,3 @@ //#region src/tools/localShell.ts | ||
| function localShell(options) { | ||
| const shellTool = (0, __langchain_core_tools.tool)(options.execute, { | ||
| const shellTool = (0, _langchain_core_tools.tool)(options.execute, { | ||
| name: TOOL_NAME, | ||
@@ -134,0 +133,0 @@ description: "Execute shell commands locally on the machine. Commands are provided as argv tokens.", |
@@ -6,3 +6,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/tools/localShell.d.ts | ||
| /** | ||
@@ -9,0 +8,0 @@ * Re-export action type from OpenAI SDK for convenience. |
@@ -6,3 +6,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/tools/localShell.d.ts | ||
| /** | ||
@@ -9,0 +8,0 @@ * Re-export action type from OpenAI SDK for convenience. |
@@ -5,3 +5,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/tools/mcp.d.ts | ||
| /** | ||
@@ -8,0 +7,0 @@ * Available connector IDs for OpenAI's built-in service connectors. |
@@ -5,3 +5,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/tools/mcp.d.ts | ||
| /** | ||
@@ -8,0 +7,0 @@ * Available connector IDs for OpenAI's built-in service connectors. |
@@ -1,4 +0,3 @@ | ||
| const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs'); | ||
| const __langchain_core_tools = require_rolldown_runtime.__toESM(require("@langchain/core/tools")); | ||
| const zod_v4 = require_rolldown_runtime.__toESM(require("zod/v4")); | ||
| let _langchain_core_tools = require("@langchain/core/tools"); | ||
| let zod_v4 = require("zod/v4"); | ||
@@ -149,3 +148,3 @@ //#region src/tools/shell.ts | ||
| }; | ||
| const shellTool = (0, __langchain_core_tools.tool)(executeWrapper, { | ||
| const shellTool = (0, _langchain_core_tools.tool)(executeWrapper, { | ||
| name: TOOL_NAME, | ||
@@ -152,0 +151,0 @@ description: "Execute shell commands in a managed environment. Commands can be run concurrently.", |
@@ -6,3 +6,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/tools/shell.d.ts | ||
| /** | ||
@@ -9,0 +8,0 @@ * Re-export action type from OpenAI SDK for convenience. |
@@ -6,3 +6,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/tools/shell.d.ts | ||
| /** | ||
@@ -9,0 +8,0 @@ * Re-export action type from OpenAI SDK for convenience. |
@@ -5,3 +5,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/tools/webSearch.d.ts | ||
| /** | ||
@@ -8,0 +7,0 @@ * User location configuration for geographic search refinement. |
@@ -5,3 +5,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/tools/webSearch.d.ts | ||
| /** | ||
@@ -8,0 +7,0 @@ * User location configuration for geographic search refinement. |
+0
-1
@@ -8,3 +8,2 @@ import { ClientOptions, OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/types.d.ts | ||
| /** | ||
@@ -11,0 +10,0 @@ * @see https://platform.openai.com/docs/models |
+0
-1
@@ -8,3 +8,2 @@ import { ClientOptions, OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/types.d.ts | ||
| /** | ||
@@ -11,0 +10,0 @@ * @see https://platform.openai.com/docs/models |
@@ -1,4 +0,3 @@ | ||
| const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs'); | ||
| const require_misc = require('./misc.cjs'); | ||
| const __langchain_core_utils_env = require_rolldown_runtime.__toESM(require("@langchain/core/utils/env")); | ||
| let _langchain_core_utils_env = require("@langchain/core/utils/env"); | ||
@@ -87,3 +86,3 @@ //#region src/utils/azure.ts | ||
| function getFormattedEnv() { | ||
| let env = (0, __langchain_core_utils_env.getEnv)(); | ||
| let env = (0, _langchain_core_utils_env.getEnv)(); | ||
| if (env === "node" || env === "deno") env = `(${env}/${process.version}; ${process.platform}; ${process.arch})`; | ||
@@ -90,0 +89,0 @@ return env; |
@@ -1,6 +0,11 @@ | ||
| const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs'); | ||
| const require_errors = require('./errors.cjs'); | ||
| const openai = require_rolldown_runtime.__toESM(require("openai")); | ||
| let openai = require("openai"); | ||
| let _langchain_core_errors = require("@langchain/core/errors"); | ||
| //#region src/utils/client.ts | ||
| function _isContextOverflowError(e) { | ||
| if (String(e).includes("context_length_exceeded")) return true; | ||
| if ("message" in e && typeof e.message === "string" && (e.message.includes("Input tokens exceed the configured limit") || e.message.includes("exceeds the context window"))) return true; | ||
| return false; | ||
| } | ||
| function wrapOpenAIClientError(e) { | ||
@@ -15,3 +20,4 @@ if (!e || typeof e !== "object") return e; | ||
| error.name = "AbortError"; | ||
| } else if ("status" in e && e.status === 400 && "message" in e && typeof e.message === "string" && e.message.includes("tool_calls")) error = require_errors.addLangChainErrorFields(e, "INVALID_TOOL_RESULTS"); | ||
| } else if (_isContextOverflowError(e)) error = new _langchain_core_errors.ContextOverflowError("message" in e && typeof e.message === "string" ? e.message : String(e), { cause: e }); | ||
| else if ("status" in e && e.status === 400 && "message" in e && typeof e.message === "string" && e.message.includes("tool_calls")) error = require_errors.addLangChainErrorFields(e, "INVALID_TOOL_RESULTS"); | ||
| else if ("status" in e && e.status === 401) error = require_errors.addLangChainErrorFields(e, "MODEL_AUTHENTICATION"); | ||
@@ -18,0 +24,0 @@ else if ("status" in e && e.status === 429) error = require_errors.addLangChainErrorFields(e, "MODEL_RATE_LIMIT"); |
| import { addLangChainErrorFields } from "./errors.js"; | ||
| import { APIConnectionTimeoutError, APIUserAbortError } from "openai"; | ||
| import { ContextOverflowError } from "@langchain/core/errors"; | ||
| //#region src/utils/client.ts | ||
| function _isContextOverflowError(e) { | ||
| if (String(e).includes("context_length_exceeded")) return true; | ||
| if ("message" in e && typeof e.message === "string" && (e.message.includes("Input tokens exceed the configured limit") || e.message.includes("exceeds the context window"))) return true; | ||
| return false; | ||
| } | ||
| function wrapOpenAIClientError(e) { | ||
@@ -14,3 +20,4 @@ if (!e || typeof e !== "object") return e; | ||
| error.name = "AbortError"; | ||
| } else if ("status" in e && e.status === 400 && "message" in e && typeof e.message === "string" && e.message.includes("tool_calls")) error = addLangChainErrorFields(e, "INVALID_TOOL_RESULTS"); | ||
| } else if (_isContextOverflowError(e)) error = new ContextOverflowError("message" in e && typeof e.message === "string" ? e.message : String(e), { cause: e }); | ||
| else if ("status" in e && e.status === 400 && "message" in e && typeof e.message === "string" && e.message.includes("tool_calls")) error = addLangChainErrorFields(e, "INVALID_TOOL_RESULTS"); | ||
| else if ("status" in e && e.status === 401) error = addLangChainErrorFields(e, "MODEL_AUTHENTICATION"); | ||
@@ -17,0 +24,0 @@ else if ("status" in e && e.status === 429) error = addLangChainErrorFields(e, "MODEL_RATE_LIMIT"); |
@@ -1,3 +0,2 @@ | ||
| const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs'); | ||
| const __langchain_core_messages = require_rolldown_runtime.__toESM(require("@langchain/core/messages")); | ||
| let _langchain_core_messages = require("@langchain/core/messages"); | ||
@@ -33,3 +32,3 @@ //#region src/utils/misc.ts | ||
| case "generic": | ||
| if (!__langchain_core_messages.ChatMessage.isInstance(message)) throw new Error("Invalid generic chat message"); | ||
| if (!_langchain_core_messages.ChatMessage.isInstance(message)) throw new Error("Invalid generic chat message"); | ||
| return extractGenericMessageCustomRole(message); | ||
@@ -36,0 +35,0 @@ default: throw new Error(`Unknown message type: ${type}`); |
@@ -5,3 +5,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/utils/misc.d.ts | ||
| declare function messageToOpenAIRole(message: BaseMessage): OpenAI$1.ChatCompletionRole; | ||
@@ -8,0 +7,0 @@ //#endregion |
@@ -5,3 +5,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/utils/misc.d.ts | ||
| declare function messageToOpenAIRole(message: BaseMessage): OpenAI$1.ChatCompletionRole; | ||
@@ -8,0 +7,0 @@ //#endregion |
@@ -1,6 +0,5 @@ | ||
| const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs'); | ||
| const __langchain_core_utils_types = require_rolldown_runtime.__toESM(require("@langchain/core/utils/types")); | ||
| const __langchain_core_utils_json_schema = require_rolldown_runtime.__toESM(require("@langchain/core/utils/json_schema")); | ||
| const zod_v4_core = require_rolldown_runtime.__toESM(require("zod/v4/core")); | ||
| const openai_helpers_zod = require_rolldown_runtime.__toESM(require("openai/helpers/zod")); | ||
| let _langchain_core_utils_types = require("@langchain/core/utils/types"); | ||
| let _langchain_core_utils_json_schema = require("@langchain/core/utils/json_schema"); | ||
| let zod_v4_core = require("zod/v4/core"); | ||
| let openai_helpers_zod = require("openai/helpers/zod"); | ||
@@ -53,4 +52,4 @@ //#region src/utils/output.ts | ||
| function interopZodResponseFormat(zodSchema, name, props) { | ||
| if ((0, __langchain_core_utils_types.isZodSchemaV3)(zodSchema)) return (0, openai_helpers_zod.zodResponseFormat)(zodSchema, name, props); | ||
| if ((0, __langchain_core_utils_types.isZodSchemaV4)(zodSchema)) return makeParseableResponseFormat({ | ||
| if ((0, _langchain_core_utils_types.isZodSchemaV3)(zodSchema)) return (0, openai_helpers_zod.zodResponseFormat)(zodSchema, name, props); | ||
| if ((0, _langchain_core_utils_types.isZodSchemaV4)(zodSchema)) return makeParseableResponseFormat({ | ||
| type: "json_schema", | ||
@@ -61,3 +60,3 @@ json_schema: { | ||
| strict: true, | ||
| schema: (0, __langchain_core_utils_json_schema.toJsonSchema)(zodSchema, { | ||
| schema: (0, _langchain_core_utils_json_schema.toJsonSchema)(zodSchema, { | ||
| cycles: "ref", | ||
@@ -64,0 +63,0 @@ reused: "ref", |
@@ -36,4 +36,3 @@ const require_completions = require('../converters/completions.cjs'); | ||
| function convertPromptToOpenAI(formattedPrompt) { | ||
| const messages = formattedPrompt.toChatMessages(); | ||
| return { messages: require_completions.convertMessagesToCompletionsMessageParams({ messages }) }; | ||
| return { messages: require_completions.convertMessagesToCompletionsMessageParams({ messages: formattedPrompt.toChatMessages() }) }; | ||
| } | ||
@@ -40,0 +39,0 @@ |
@@ -5,3 +5,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/utils/prompts.d.ts | ||
| /** | ||
@@ -8,0 +7,0 @@ * Convert a formatted LangChain prompt (e.g. pulled from the hub) into |
@@ -5,3 +5,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/utils/prompts.d.ts | ||
| /** | ||
@@ -8,0 +7,0 @@ * Convert a formatted LangChain prompt (e.g. pulled from the hub) into |
@@ -36,4 +36,3 @@ import { convertMessagesToCompletionsMessageParams } from "../converters/completions.js"; | ||
| function convertPromptToOpenAI(formattedPrompt) { | ||
| const messages = formattedPrompt.toChatMessages(); | ||
| return { messages: convertMessagesToCompletionsMessageParams({ messages }) }; | ||
| return { messages: convertMessagesToCompletionsMessageParams({ messages: formattedPrompt.toChatMessages() }) }; | ||
| } | ||
@@ -40,0 +39,0 @@ |
+9
-12
@@ -1,5 +0,4 @@ | ||
| const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs'); | ||
| const __langchain_core_utils_function_calling = require_rolldown_runtime.__toESM(require("@langchain/core/utils/function_calling")); | ||
| const __langchain_core_utils_types = require_rolldown_runtime.__toESM(require("@langchain/core/utils/types")); | ||
| const __langchain_core_utils_json_schema = require_rolldown_runtime.__toESM(require("@langchain/core/utils/json_schema")); | ||
| let _langchain_core_utils_function_calling = require("@langchain/core/utils/function_calling"); | ||
| let _langchain_core_utils_types = require("@langchain/core/utils/types"); | ||
| let _langchain_core_utils_json_schema = require("@langchain/core/utils/json_schema"); | ||
@@ -20,3 +19,3 @@ //#region src/utils/tools.ts | ||
| let toolDef; | ||
| if ((0, __langchain_core_utils_function_calling.isLangChainTool)(tool)) toolDef = (0, __langchain_core_utils_function_calling.convertToOpenAITool)(tool); | ||
| if ((0, _langchain_core_utils_function_calling.isLangChainTool)(tool)) toolDef = (0, _langchain_core_utils_function_calling.convertToOpenAITool)(tool); | ||
| else toolDef = tool; | ||
@@ -78,3 +77,3 @@ if (fields?.strict !== void 0) toolDef.function.strict = fields.strict; | ||
| function formatToOpenAIToolChoice(toolChoice) { | ||
| if (!toolChoice) return void 0; | ||
| if (!toolChoice) return; | ||
| else if (toolChoice === "any" || toolChoice === "required") return "required"; | ||
@@ -110,3 +109,3 @@ else if (toolChoice === "auto") return "auto"; | ||
| function parseCustomToolCall(rawToolCall) { | ||
| if (rawToolCall.type !== "custom_tool_call") return void 0; | ||
| if (rawToolCall.type !== "custom_tool_call") return; | ||
| return { | ||
@@ -130,3 +129,3 @@ ...rawToolCall, | ||
| function parseComputerCall(rawToolCall) { | ||
| if (rawToolCall.type !== "computer_call") return void 0; | ||
| if (rawToolCall.type !== "computer_call") return; | ||
| return { | ||
@@ -155,3 +154,3 @@ ...rawToolCall, | ||
| const getFormat = () => { | ||
| if (!tool.custom.format) return void 0; | ||
| if (!tool.custom.format) return; | ||
| if (tool.custom.format.type === "grammar") return { | ||
@@ -163,3 +162,2 @@ type: "grammar", | ||
| if (tool.custom.format.type === "text") return { type: "text" }; | ||
| return void 0; | ||
| }; | ||
@@ -175,3 +173,3 @@ return { | ||
| const getFormat = () => { | ||
| if (!tool.format) return void 0; | ||
| if (!tool.format) return; | ||
| if (tool.format.type === "grammar") return { | ||
@@ -185,3 +183,2 @@ type: "grammar", | ||
| if (tool.format.type === "text") return { type: "text" }; | ||
| return void 0; | ||
| }; | ||
@@ -188,0 +185,0 @@ return { |
@@ -6,3 +6,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/utils/tools.d.ts | ||
| type OpenAIToolChoice = OpenAI$1.ChatCompletionToolChoiceOption | "any" | string; | ||
@@ -9,0 +8,0 @@ type ResponsesToolChoice = NonNullable<OpenAI$1.Responses.ResponseCreateParams["tool_choice"]>; |
@@ -7,3 +7,2 @@ import { OpenAI as OpenAI$1 } from "openai"; | ||
| //#region src/utils/tools.d.ts | ||
| type OpenAIToolChoice = OpenAI$1.ChatCompletionToolChoiceOption | "any" | string; | ||
@@ -10,0 +9,0 @@ type ResponsesToolChoice = NonNullable<OpenAI$1.Responses.ResponseCreateParams["tool_choice"]>; |
@@ -76,3 +76,3 @@ import { convertToOpenAITool, isLangChainTool } from "@langchain/core/utils/function_calling"; | ||
| function formatToOpenAIToolChoice(toolChoice) { | ||
| if (!toolChoice) return void 0; | ||
| if (!toolChoice) return; | ||
| else if (toolChoice === "any" || toolChoice === "required") return "required"; | ||
@@ -108,3 +108,3 @@ else if (toolChoice === "auto") return "auto"; | ||
| function parseCustomToolCall(rawToolCall) { | ||
| if (rawToolCall.type !== "custom_tool_call") return void 0; | ||
| if (rawToolCall.type !== "custom_tool_call") return; | ||
| return { | ||
@@ -128,3 +128,3 @@ ...rawToolCall, | ||
| function parseComputerCall(rawToolCall) { | ||
| if (rawToolCall.type !== "computer_call") return void 0; | ||
| if (rawToolCall.type !== "computer_call") return; | ||
| return { | ||
@@ -153,3 +153,3 @@ ...rawToolCall, | ||
| const getFormat = () => { | ||
| if (!tool.custom.format) return void 0; | ||
| if (!tool.custom.format) return; | ||
| if (tool.custom.format.type === "grammar") return { | ||
@@ -161,3 +161,2 @@ type: "grammar", | ||
| if (tool.custom.format.type === "text") return { type: "text" }; | ||
| return void 0; | ||
| }; | ||
@@ -173,3 +172,3 @@ return { | ||
| const getFormat = () => { | ||
| if (!tool.format) return void 0; | ||
| if (!tool.format) return; | ||
| if (tool.format.type === "grammar") return { | ||
@@ -183,3 +182,2 @@ type: "grammar", | ||
| if (tool.format.type === "text") return { type: "text" }; | ||
| return void 0; | ||
| }; | ||
@@ -186,0 +184,0 @@ return { |
+5
-5
| { | ||
| "name": "@langchain/openai", | ||
| "version": "1.2.7", | ||
| "version": "1.2.8-dev-1771365493298", | ||
| "description": "OpenAI integrations for LangChain.js", | ||
@@ -22,3 +22,3 @@ "author": "LangChain", | ||
| "peerDependencies": { | ||
| "@langchain/core": "^1.0.0" | ||
| "@langchain/core": "1.1.25-dev-1771365493298" | ||
| }, | ||
@@ -29,3 +29,3 @@ "devDependencies": { | ||
| "@tsconfig/recommended": "^1.0.10", | ||
| "@types/node": "^24.10.1", | ||
| "@types/node": "^25.2.3", | ||
| "@vitest/coverage-v8": "^3.2.4", | ||
@@ -41,6 +41,6 @@ "dotenv": "^17.2.1", | ||
| "zod-to-json-schema": "^3.24.6", | ||
| "@langchain/core": "^1.1.21", | ||
| "@langchain/eslint": "0.1.1", | ||
| "@langchain/standard-tests": "0.0.23", | ||
| "@langchain/tsconfig": "0.0.1" | ||
| "@langchain/tsconfig": "0.0.1", | ||
| "@langchain/core": "^1.1.25-dev-1771365493298" | ||
| }, | ||
@@ -47,0 +47,0 @@ "publishConfig": { |
| //#region rolldown:runtime | ||
| var __create = Object.create; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __getProtoOf = Object.getPrototypeOf; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { | ||
| key = keys[i]; | ||
| if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { | ||
| get: ((k) => from[k]).bind(null, key), | ||
| enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable | ||
| }); | ||
| } | ||
| return to; | ||
| }; | ||
| var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { | ||
| value: mod, | ||
| enumerable: true | ||
| }) : target, mod)); | ||
| //#endregion | ||
| exports.__toESM = __toESM; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 5 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 5 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
1832490
-20%275
-0.36%18701
-0.77%2
100%