@langchain/openai 1.1.2 → 1.2.0-dev-1765431816670
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +583 -2
- package/dist/azure/chat_models/common.d.cts.map +1 -1
- package/dist/azure/chat_models/common.d.ts +1 -0
- package/dist/azure/chat_models/common.d.ts.map +1 -1
- package/dist/azure/chat_models/completions.d.cts.map +1 -1
- package/dist/azure/chat_models/completions.d.ts.map +1 -1
- package/dist/azure/chat_models/index.d.cts +1 -1
- package/dist/azure/chat_models/index.d.cts.map +1 -1
- package/dist/azure/chat_models/index.d.ts.map +1 -1
- package/dist/azure/chat_models/responses.d.cts.map +1 -1
- package/dist/azure/chat_models/responses.d.ts.map +1 -1
- package/dist/azure/embeddings.d.cts.map +1 -1
- package/dist/azure/embeddings.d.ts.map +1 -1
- package/dist/azure/llms.d.cts +0 -1
- package/dist/azure/llms.d.cts.map +1 -1
- package/dist/azure/llms.d.ts +0 -1
- package/dist/azure/llms.d.ts.map +1 -1
- package/dist/chat_models/base.cjs +5 -1
- package/dist/chat_models/base.cjs.map +1 -1
- package/dist/chat_models/base.d.cts +8 -22
- package/dist/chat_models/base.d.cts.map +1 -1
- package/dist/chat_models/base.d.ts +6 -20
- package/dist/chat_models/base.d.ts.map +1 -1
- package/dist/chat_models/base.js +6 -2
- package/dist/chat_models/base.js.map +1 -1
- package/dist/chat_models/completions.cjs.map +1 -1
- package/dist/chat_models/completions.d.cts +1 -3
- package/dist/chat_models/completions.d.cts.map +1 -1
- package/dist/chat_models/completions.d.ts +1 -3
- package/dist/chat_models/completions.d.ts.map +1 -1
- package/dist/chat_models/completions.js.map +1 -1
- package/dist/chat_models/index.d.cts +42 -4
- package/dist/chat_models/index.d.cts.map +1 -1
- package/dist/chat_models/index.d.ts +42 -4
- package/dist/chat_models/index.d.ts.map +1 -1
- package/dist/chat_models/responses.d.cts +2 -2
- package/dist/chat_models/responses.d.cts.map +1 -1
- package/dist/chat_models/responses.d.ts +2 -2
- package/dist/chat_models/responses.d.ts.map +1 -1
- package/dist/converters/completions.cjs +22 -12
- package/dist/converters/completions.cjs.map +1 -1
- package/dist/converters/completions.d.cts +0 -1
- package/dist/converters/completions.d.cts.map +1 -1
- package/dist/converters/completions.d.ts +0 -1
- package/dist/converters/completions.d.ts.map +1 -1
- package/dist/converters/completions.js +23 -13
- package/dist/converters/completions.js.map +1 -1
- package/dist/converters/index.d.ts +2 -0
- package/dist/converters/responses.cjs +37 -4
- package/dist/converters/responses.cjs.map +1 -1
- package/dist/converters/responses.d.cts.map +1 -1
- package/dist/converters/responses.d.ts.map +1 -1
- package/dist/converters/responses.js +39 -6
- package/dist/converters/responses.js.map +1 -1
- package/dist/embeddings.d.cts +0 -1
- package/dist/embeddings.d.cts.map +1 -1
- package/dist/embeddings.d.ts +0 -1
- package/dist/embeddings.d.ts.map +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +13 -2
- package/dist/index.js +2 -2
- package/dist/llms.d.cts +0 -1
- package/dist/llms.d.cts.map +1 -1
- package/dist/llms.d.ts +0 -1
- package/dist/llms.d.ts.map +1 -1
- package/dist/tools/applyPatch.cjs +116 -0
- package/dist/tools/applyPatch.cjs.map +1 -0
- package/dist/tools/applyPatch.d.cts +148 -0
- package/dist/tools/applyPatch.d.cts.map +1 -0
- package/dist/tools/applyPatch.d.ts +148 -0
- package/dist/tools/applyPatch.d.ts.map +1 -0
- package/dist/tools/applyPatch.js +115 -0
- package/dist/tools/applyPatch.js.map +1 -0
- package/dist/tools/codeInterpreter.cjs +95 -0
- package/dist/tools/codeInterpreter.cjs.map +1 -0
- package/dist/tools/codeInterpreter.d.cts +125 -0
- package/dist/tools/codeInterpreter.d.cts.map +1 -0
- package/dist/tools/codeInterpreter.d.ts +125 -0
- package/dist/tools/codeInterpreter.d.ts.map +1 -0
- package/dist/tools/codeInterpreter.js +94 -0
- package/dist/tools/codeInterpreter.js.map +1 -0
- package/dist/tools/computerUse.cjs +240 -0
- package/dist/tools/computerUse.cjs.map +1 -0
- package/dist/tools/computerUse.d.cts +234 -0
- package/dist/tools/computerUse.d.cts.map +1 -0
- package/dist/tools/computerUse.d.ts +234 -0
- package/dist/tools/computerUse.d.ts.map +1 -0
- package/dist/tools/computerUse.js +239 -0
- package/dist/tools/computerUse.js.map +1 -0
- package/dist/tools/custom.d.cts +1 -1
- package/dist/tools/custom.d.cts.map +1 -1
- package/dist/tools/custom.d.ts.map +1 -1
- package/dist/tools/dalle.d.cts +1 -2
- package/dist/tools/dalle.d.cts.map +1 -1
- package/dist/tools/dalle.d.ts +1 -2
- package/dist/tools/dalle.d.ts.map +1 -1
- package/dist/tools/fileSearch.cjs +137 -0
- package/dist/tools/fileSearch.cjs.map +1 -0
- package/dist/tools/fileSearch.d.cts +224 -0
- package/dist/tools/fileSearch.d.cts.map +1 -0
- package/dist/tools/fileSearch.d.ts +224 -0
- package/dist/tools/fileSearch.d.ts.map +1 -0
- package/dist/tools/fileSearch.js +136 -0
- package/dist/tools/fileSearch.js.map +1 -0
- package/dist/tools/imageGeneration.cjs +128 -0
- package/dist/tools/imageGeneration.cjs.map +1 -0
- package/dist/tools/imageGeneration.d.cts +199 -0
- package/dist/tools/imageGeneration.d.cts.map +1 -0
- package/dist/tools/imageGeneration.d.ts +199 -0
- package/dist/tools/imageGeneration.d.ts.map +1 -0
- package/dist/tools/imageGeneration.js +127 -0
- package/dist/tools/imageGeneration.js.map +1 -0
- package/dist/tools/index.cjs +26 -0
- package/dist/tools/index.cjs.map +1 -0
- package/dist/tools/index.d.cts +27 -0
- package/dist/tools/index.d.cts.map +1 -0
- package/dist/tools/index.d.ts +27 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +26 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/localShell.cjs +145 -0
- package/dist/tools/localShell.cjs.map +1 -0
- package/dist/tools/localShell.d.cts +167 -0
- package/dist/tools/localShell.d.cts.map +1 -0
- package/dist/tools/localShell.d.ts +167 -0
- package/dist/tools/localShell.d.ts.map +1 -0
- package/dist/tools/localShell.js +144 -0
- package/dist/tools/localShell.js.map +1 -0
- package/dist/tools/mcp.cjs +53 -0
- package/dist/tools/mcp.cjs.map +1 -0
- package/dist/tools/mcp.d.cts +177 -0
- package/dist/tools/mcp.d.cts.map +1 -0
- package/dist/tools/mcp.d.ts +177 -0
- package/dist/tools/mcp.d.ts.map +1 -0
- package/dist/tools/mcp.js +52 -0
- package/dist/tools/mcp.js.map +1 -0
- package/dist/tools/shell.cjs +163 -0
- package/dist/tools/shell.cjs.map +1 -0
- package/dist/tools/shell.d.cts +221 -0
- package/dist/tools/shell.d.cts.map +1 -0
- package/dist/tools/shell.d.ts +221 -0
- package/dist/tools/shell.d.ts.map +1 -0
- package/dist/tools/shell.js +162 -0
- package/dist/tools/shell.js.map +1 -0
- package/dist/tools/webSearch.cjs +73 -0
- package/dist/tools/webSearch.cjs.map +1 -0
- package/dist/tools/webSearch.d.cts +130 -0
- package/dist/tools/webSearch.d.cts.map +1 -0
- package/dist/tools/webSearch.d.ts +130 -0
- package/dist/tools/webSearch.d.ts.map +1 -0
- package/dist/tools/webSearch.js +72 -0
- package/dist/tools/webSearch.js.map +1 -0
- package/dist/types.d.cts +2 -4
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.ts +1 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/azure.d.cts +1 -5
- package/dist/utils/azure.d.cts.map +1 -1
- package/dist/utils/azure.d.ts +1 -5
- package/dist/utils/azure.d.ts.map +1 -1
- package/dist/utils/client.d.cts.map +1 -1
- package/dist/utils/client.d.ts.map +1 -1
- package/dist/utils/misc.cjs +6 -0
- package/dist/utils/misc.cjs.map +1 -1
- package/dist/utils/misc.d.cts +1 -1
- package/dist/utils/misc.d.cts.map +1 -1
- package/dist/utils/misc.d.ts +1 -1
- package/dist/utils/misc.d.ts.map +1 -1
- package/dist/utils/misc.js +6 -1
- package/dist/utils/misc.js.map +1 -1
- package/dist/utils/prompts.d.cts +0 -1
- package/dist/utils/prompts.d.cts.map +1 -1
- package/dist/utils/prompts.d.ts +0 -1
- package/dist/utils/prompts.d.ts.map +1 -1
- package/dist/utils/tools.cjs +39 -1
- package/dist/utils/tools.cjs.map +1 -1
- package/dist/utils/tools.d.cts.map +1 -1
- package/dist/utils/tools.d.ts.map +1 -1
- package/dist/utils/tools.js +37 -2
- package/dist/utils/tools.js.map +1 -1
- package/package.json +18 -15
- package/dist/langchain-core/dist/callbacks/base.d.ts +0 -1
- package/dist/langchain-core/dist/callbacks/manager.d.ts +0 -2
- package/dist/langchain-core/dist/language_models/base.d.ts +0 -5
- package/dist/langchain-core/dist/language_models/chat_models.d.cts +0 -13
- package/dist/langchain-core/dist/language_models/chat_models.d.cts.map +0 -1
- package/dist/langchain-core/dist/language_models/chat_models.d.ts +0 -20
- package/dist/langchain-core/dist/language_models/chat_models.d.ts.map +0 -1
- package/dist/langchain-core/dist/runnables/base.d.ts +0 -7
- package/dist/langchain-core/dist/runnables/graph.d.ts +0 -1
- package/dist/langchain-core/dist/runnables/types.d.ts +0 -2
- package/dist/langchain-core/dist/tools/types.d.ts +0 -5
- package/dist/langchain-core/dist/tracers/base.d.ts +0 -2
- package/dist/langchain-core/dist/tracers/event_stream.d.ts +0 -1
- package/dist/langchain-core/dist/tracers/log_stream.d.ts +0 -3
- package/dist/langchain-core/dist/types/_internal.d.cts +0 -11
- package/dist/langchain-core/dist/types/_internal.d.cts.map +0 -1
- package/dist/langchain-core/dist/types/_internal.d.ts +0 -11
- package/dist/langchain-core/dist/types/_internal.d.ts.map +0 -1
- package/dist/langchain-core/dist/utils/stream.d.cts +0 -26
- package/dist/langchain-core/dist/utils/stream.d.cts.map +0 -1
- package/dist/langchain-core/dist/utils/stream.d.ts +0 -26
- package/dist/langchain-core/dist/utils/stream.d.ts.map +0 -1
- package/dist/langchain-core/dist/utils/types/index.d.ts +0 -1
- package/dist/langchain-core/dist/utils/types/zod.d.ts +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webSearch.js","names":["options?: WebSearchOptions"],"sources":["../../src/tools/webSearch.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n\n/**\n * User location configuration for geographic search refinement.\n */\nexport interface WebSearchUserLocation {\n /**\n * The type of location. Currently only \"approximate\" is supported.\n */\n type: \"approximate\";\n /**\n * Two-letter ISO country code (e.g., \"US\", \"GB\").\n * @see https://en.wikipedia.org/wiki/ISO_3166-1\n */\n country?: string;\n /**\n * City name (e.g., \"San Francisco\", \"London\").\n */\n city?: string;\n /**\n * Region or state name (e.g., \"California\", \"London\").\n */\n region?: string;\n /**\n * IANA timezone (e.g., \"America/Los_Angeles\", \"Europe/London\").\n * @see https://timeapi.io/documentation/iana-timezones\n */\n timezone?: string;\n}\n\n/**\n * Domain filtering configuration for web search.\n */\nexport interface WebSearchFilters {\n /**\n * Allow-list of up to 100 domains to limit search results.\n * Omit the HTTP/HTTPS prefix (e.g., \"openai.com\" instead of \"https://openai.com/\").\n * Includes subdomains automatically.\n */\n allowedDomains?: string[];\n}\n\n/**\n * Options for the OpenAI web search tool.\n */\nexport interface WebSearchOptions {\n /**\n * Domain filtering configuration.\n * Limit results to a specific set of up to 100 domains.\n */\n filters?: WebSearchFilters;\n /**\n * Approximate user location for geographic search refinement.\n * Not supported for deep research models.\n */\n userLocation?: WebSearchUserLocation;\n /**\n * High level guidance for the amount of context window space to use for the\n * search. One of `low`, `medium`, or `high`. `medium` is the default.\n */\n search_context_size?: \"low\" | \"medium\" | \"high\";\n}\n\n/**\n * OpenAI web search tool type for the Responses API.\n */\nexport type WebSearchTool = OpenAIClient.Responses.WebSearchTool;\n\n/**\n * Creates a web search tool that allows OpenAI models to search the web\n * for up-to-date information before generating a response.\n *\n * Web search supports three main types:\n * 1. **Non-reasoning web search**: Quick lookups where the model passes queries\n * directly to the search tool.\n * 2. **Agentic search with reasoning models**: The model actively manages the\n * search process, analyzing results and deciding whether to keep searching.\n * 3. **Deep research**: Extended investigations using models like `o3-deep-research`\n * or `gpt-5` with high reasoning effort.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-web-search | OpenAI Web Search Documentation}\n * @param options - Configuration options for the web search tool\n * @returns A web search tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n *\n * const model = new ChatOpenAI({\n * model: \"gpt-4o\",\n * });\n *\n * // Basic usage\n * const response = await model.invoke(\"What was a positive news story from today?\", {\n * tools: [tools.webSearch()],\n * });\n *\n * // With domain filtering\n * const filteredResponse = await model.invoke(\"Latest AI research news\", {\n * tools: [tools.webSearch({\n * filters: {\n * allowedDomains: [\"arxiv.org\", \"nature.com\", \"science.org\"],\n * },\n * })],\n * });\n *\n * // With user location for geographic relevance\n * const localResponse = await model.invoke(\"What are the best restaurants near me?\", {\n * tools: [tools.webSearch({\n * userLocation: {\n * type: \"approximate\",\n * country: \"US\",\n * city: \"San Francisco\",\n * region: \"California\",\n * timezone: \"America/Los_Angeles\",\n * },\n * })],\n * });\n *\n * // Cache-only mode (no live internet access)\n * const cachedResponse = await model.invoke(\"Find information about OpenAI\", {\n * tools: [tools.webSearch({\n * externalWebAccess: false,\n * })],\n * });\n * ```\n */\nexport function webSearch(options?: WebSearchOptions): ServerTool {\n return {\n type: \"web_search\",\n filters: options?.filters?.allowedDomains\n ? { allowed_domains: options.filters.allowedDomains }\n : undefined,\n user_location: options?.userLocation,\n search_context_size: options?.search_context_size,\n } satisfies WebSearchTool;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgIA,SAAgB,UAAUA,SAAwC;AAChE,QAAO;EACL,MAAM;EACN,SAAS,SAAS,SAAS,iBACvB,EAAE,iBAAiB,QAAQ,QAAQ,eAAgB,IACnD;EACJ,eAAe,SAAS;EACxB,qBAAqB,SAAS;CAC/B;AACF"}
|
package/dist/types.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ClientOptions, OpenAI as OpenAI$1 } from "openai";
|
|
2
|
-
import { TiktokenModel } from "js-tiktoken/lite";
|
|
3
2
|
import { BaseLanguageModelCallOptions } from "@langchain/core/language_models/base";
|
|
4
|
-
import { ResponseFormatJSONObject, ResponseFormatJSONSchema, ResponseFormatText, ResponseFormatTextGrammar, ResponseFormatTextPython } from "openai/resources/shared";
|
|
5
3
|
import { InteropZodObject } from "@langchain/core/utils/types";
|
|
4
|
+
import { ResponseFormatJSONObject, ResponseFormatJSONSchema, ResponseFormatText, ResponseFormatTextGrammar, ResponseFormatTextPython } from "openai/resources/shared";
|
|
5
|
+
import { TiktokenModel } from "js-tiktoken/lite";
|
|
6
6
|
|
|
7
7
|
//#region src/types.d.ts
|
|
8
8
|
|
|
@@ -57,7 +57,6 @@ declare interface OpenAIBaseInput {
|
|
|
57
57
|
* https://platform.openai.com/docs/api-reference/completions/create |
|
|
58
58
|
* `openai.createCompletion`} that are not explicitly specified on this class.
|
|
59
59
|
*/
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
60
|
modelKwargs?: Record<string, any>;
|
|
62
61
|
/**
|
|
63
62
|
* List of stop words to use when generating
|
|
@@ -239,7 +238,6 @@ type ChatOpenAIResponseFormatJSONSchema = Omit<ResponseFormatJSONSchema, "json_s
|
|
|
239
238
|
* The schema for the response format, described as a JSON Schema object
|
|
240
239
|
* or a Zod object.
|
|
241
240
|
*/
|
|
242
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
243
241
|
schema: Record<string, any> | InteropZodObject;
|
|
244
242
|
};
|
|
245
243
|
};
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":["OpenAI","OpenAIClient","ClientOptions","ResponseFormatText","ResponseFormatJSONObject","ResponseFormatJSONSchema","ResponseFormatTextPython","ResponseFormatTextGrammar","TiktokenModel","BaseLanguageModelCallOptions","InteropZodObject","OpenAIChatModelId","ChatModel","NonNullable","OpenAIVerbosityParam","OpenAIApiKey","OpenAIBaseInput","Record","OpenAICoreRequestOptions","RequestOptions","OpenAICallOptions","OpenAIInput","OpenAIChatInput","Chat","ChatCompletionMessageParam","ChatCompletionModality","Array","ChatCompletionAudioParam","Reasoning","Responses","ResponseCreateParams","AzureOpenAIInput","Promise","AzureOpenAIChatInput","ChatOpenAIResponseFormatJSONSchema","Omit","ChatOpenAIReasoningSummary","ResponseReasoningItem","Summary","ChatOpenAIResponseFormat","ResponseFormatConfiguration"],"sources":["../src/types.d.ts"],"sourcesContent":["import type { OpenAI as OpenAIClient, ClientOptions } from \"openai\";\nimport type { ResponseFormatText, ResponseFormatJSONObject, ResponseFormatJSONSchema, ResponseFormatTextPython, ResponseFormatTextGrammar } from \"openai/resources/shared\";\nimport { TiktokenModel } from \"js-tiktoken/lite\";\nimport type { BaseLanguageModelCallOptions } from \"@langchain/core/language_models/base\";\nimport { InteropZodObject } from \"@langchain/core/utils/types\";\n// reexport this type from the included package so we can easily override and extend it if needed in the future\n// also makes it easier for folks to import this type without digging around into the dependent packages\nexport type { TiktokenModel };\n/**\n * @see https://platform.openai.com/docs/models\n */\nexport type OpenAIChatModelId = OpenAIClient.ChatModel | (string & NonNullable<unknown>);\nexport type OpenAIVerbosityParam = \"low\" | \"medium\" | \"high\" | null;\nexport type OpenAIApiKey = ClientOptions[\"apiKey\"];\nexport declare interface OpenAIBaseInput {\n /** Sampling temperature to use */\n temperature: number;\n /**\n * Maximum number of tokens to generate in the completion. -1 returns as many\n * tokens as possible given the prompt and the model's maximum context size.\n */\n maxTokens?: number;\n /**\n * Maximum number of tokens to generate in the completion. -1 returns as many\n * tokens as possible given the prompt and the model's maximum context size.\n * Alias for `maxTokens` for reasoning models.\n */\n maxCompletionTokens?: number;\n /** Total probability mass of tokens to consider at each step */\n topP: number;\n /** Penalizes repeated tokens according to frequency */\n frequencyPenalty: number;\n /** Penalizes repeated tokens */\n presencePenalty: number;\n /** Number of completions to generate for each prompt */\n n: number;\n /** Dictionary used to adjust the probability of specific tokens being generated */\n logitBias?: Record<string, number>;\n /** Unique string identifier representing your end-user, which can help OpenAI to monitor and detect abuse. */\n user?: string;\n /** Whether to stream the results or not. Enabling disables tokenUsage reporting */\n streaming: boolean;\n /**\n * Whether or not to include token usage data in streamed chunks.\n * @default true\n */\n streamUsage?: boolean;\n /**\n * Model name to use\n * Alias for `model`\n * @deprecated Use \"model\" instead.\n */\n modelName: string;\n /** Model name to use */\n model: OpenAIChatModelId;\n /** Holds any additional parameters that are valid to pass to {@link\n * https://platform.openai.com/docs/api-reference/completions/create |\n * `openai.createCompletion`} that are not explicitly specified on this class.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n modelKwargs?: Record<string, any>;\n /**\n * List of stop words to use when generating\n * Alias for `stopSequences`\n */\n stop?: string[];\n /** List of stop words to use when generating */\n stopSequences?: string[];\n /**\n * Timeout to use when making requests to OpenAI.\n */\n timeout?: number;\n /**\n * API key to use when making requests to OpenAI. Defaults to the value of\n * `OPENAI_API_KEY` environment variable.\n * Alias for `apiKey`\n */\n openAIApiKey?: OpenAIApiKey;\n /**\n * API key to use when making requests to OpenAI. Defaults to the value of\n * `OPENAI_API_KEY` environment variable.\n */\n apiKey?: OpenAIApiKey;\n /**\n * The verbosity of the model's response.\n */\n verbosity?: OpenAIVerbosityParam;\n}\nexport type OpenAICoreRequestOptions = OpenAIClient.RequestOptions;\nexport interface OpenAICallOptions extends BaseLanguageModelCallOptions {\n /**\n * Additional options to pass to the underlying axios request.\n */\n options?: OpenAICoreRequestOptions;\n}\n/**\n * Input to OpenAI class.\n */\nexport declare interface OpenAIInput extends OpenAIBaseInput {\n /** Generates `bestOf` completions server side and returns the \"best\" */\n bestOf?: number;\n /** Batch size to use when passing multiple documents to generate */\n batchSize: number;\n}\nexport interface OpenAIChatInput extends OpenAIBaseInput {\n /**\n * Whether to return log probabilities of the output tokens or not.\n * If true, returns the log probabilities of each output token returned in the content of message.\n */\n logprobs?: boolean;\n /**\n * An integer between 0 and 5 specifying the number of most likely tokens to return at each token position,\n * each with an associated log probability. logprobs must be set to true if this parameter is used.\n */\n topLogprobs?: number;\n /** ChatGPT messages to pass as a prefix to the prompt */\n prefixMessages?: OpenAIClient.Chat.ChatCompletionMessageParam[];\n /**\n * Whether to include the raw OpenAI response in the output message's \"additional_kwargs\" field.\n * Currently in experimental beta.\n */\n __includeRawResponse?: boolean;\n /**\n * Whether the model supports the `strict` argument when passing in tools.\n * If `undefined` the `strict` argument will not be passed to OpenAI.\n */\n supportsStrictToolCalling?: boolean;\n /**\n * Output types that you would like the model to generate for this request. Most\n * models are capable of generating text, which is the default:\n *\n * `[\"text\"]`\n *\n * The `gpt-4o-audio-preview` model can also be used to\n * [generate audio](https://platform.openai.com/docs/guides/audio). To request that\n * this model generate both text and audio responses, you can use:\n *\n * `[\"text\", \"audio\"]`\n */\n modalities?: Array<OpenAIClient.Chat.ChatCompletionModality>;\n /**\n * Parameters for audio output. Required when audio output is requested with\n * `modalities: [\"audio\"]`.\n * [Learn more](https://platform.openai.com/docs/guides/audio).\n */\n audio?: OpenAIClient.Chat.ChatCompletionAudioParam;\n /**\n * Options for reasoning models.\n *\n * Note that some options, like reasoning summaries, are only available when using the responses\n * API. This option is ignored when not using a reasoning model.\n */\n reasoning?: OpenAIClient.Reasoning;\n /**\n * Should be set to `true` in tenancies with Zero Data Retention\n * @see https://platform.openai.com/docs/guides/your-data\n *\n * @default false\n */\n zdrEnabled?: boolean;\n /**\n * Service tier to use for this request. Can be \"auto\", \"default\", or \"flex\" or \"priority\".\n * Specifies the service tier for prioritization and latency optimization.\n */\n service_tier?: OpenAIClient.Responses.ResponseCreateParams[\"service_tier\"];\n /**\n * Used by OpenAI to cache responses for similar requests to optimize your cache\n * hit rates. Replaces the `user` field.\n * [Learn more](https://platform.openai.com/docs/guides/prompt-caching).\n */\n promptCacheKey?: string;\n}\nexport interface AzureOpenAIInput {\n /**\n * API version to use when making requests to Azure OpenAI.\n */\n azureOpenAIApiVersion?: string;\n /**\n * API key to use when making requests to Azure OpenAI.\n */\n azureOpenAIApiKey?: string;\n /**\n * Azure OpenAI API instance name to use when making requests to Azure OpenAI.\n * this is the name of the instance you created in the Azure portal.\n * e.g. \"my-openai-instance\"\n * this will be used in the endpoint URL: https://my-openai-instance.openai.azure.com/openai/deployments/{DeploymentName}/\n */\n azureOpenAIApiInstanceName?: string;\n /**\n * Azure OpenAI API deployment name to use for completions when making requests to Azure OpenAI.\n * This is the name of the deployment you created in the Azure portal.\n * e.g. \"my-openai-deployment\"\n * this will be used in the endpoint URL: https://{InstanceName}.openai.azure.com/openai/deployments/my-openai-deployment/\n */\n azureOpenAIApiDeploymentName?: string;\n /**\n * Azure OpenAI API deployment name to use for embedding when making requests to Azure OpenAI.\n * This is the name of the deployment you created in the Azure portal.\n * This will fallback to azureOpenAIApiDeploymentName if not provided.\n * e.g. \"my-openai-deployment\"\n * this will be used in the endpoint URL: https://{InstanceName}.openai.azure.com/openai/deployments/my-openai-deployment/\n */\n azureOpenAIApiEmbeddingsDeploymentName?: string;\n /**\n * Azure OpenAI API deployment name to use for completions when making requests to Azure OpenAI.\n * Completions are only available for gpt-3.5-turbo and text-davinci-003 deployments.\n * This is the name of the deployment you created in the Azure portal.\n * This will fallback to azureOpenAIApiDeploymentName if not provided.\n * e.g. \"my-openai-deployment\"\n * this will be used in the endpoint URL: https://{InstanceName}.openai.azure.com/openai/deployments/my-openai-deployment/\n */\n azureOpenAIApiCompletionsDeploymentName?: string;\n /**\n * Custom base url for Azure OpenAI API. This is useful in case you have a deployment in another region.\n * e.g. setting this value to \"https://westeurope.api.cognitive.microsoft.com/openai/deployments\"\n * will be result in the endpoint URL: https://westeurope.api.cognitive.microsoft.com/openai/deployments/{DeploymentName}/\n */\n azureOpenAIBasePath?: string;\n /**\n * Custom endpoint for Azure OpenAI API. This is useful in case you have a deployment in another region.\n * e.g. setting this value to \"https://westeurope.api.cognitive.microsoft.com/\"\n * will be result in the endpoint URL: https://westeurope.api.cognitive.microsoft.com/openai/deployments/{DeploymentName}/\n */\n azureOpenAIEndpoint?: string;\n /**\n * A function that returns an access token for Microsoft Entra (formerly known as Azure Active Directory),\n * which will be invoked on every request.\n */\n azureADTokenProvider?: () => Promise<string>;\n}\nexport interface AzureOpenAIChatInput extends OpenAIChatInput, AzureOpenAIInput {\n openAIApiVersion?: string;\n openAIBasePath?: string;\n deploymentName?: string;\n}\ntype ChatOpenAIResponseFormatJSONSchema = Omit<ResponseFormatJSONSchema, \"json_schema\"> & {\n json_schema: Omit<ResponseFormatJSONSchema[\"json_schema\"], \"schema\"> & {\n /**\n * The schema for the response format, described as a JSON Schema object\n * or a Zod object.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema: Record<string, any> | InteropZodObject;\n };\n};\n/**\n * The summary of a model's reasoning step.\n */\nexport type ChatOpenAIReasoningSummary = Omit<OpenAIClient.Responses.ResponseReasoningItem, \"summary\"> & {\n /**\n * The summary of the reasoning step. The index field will be populated if the response was\n * streamed. This allows LangChain to recompose the reasoning summary output correctly when the\n * AIMessage is used as an input for future generation requests.\n */\n summary: Array<OpenAIClient.Responses.ResponseReasoningItem.Summary & {\n index?: number;\n }>;\n};\nexport type ChatOpenAIResponseFormat = ResponseFormatText | ResponseFormatJSONObject | ResponseFormatTextGrammar | ResponseFormatTextPython | ChatOpenAIResponseFormatJSONSchema;\nexport type ResponseFormatConfiguration = ResponseFormatText | ResponseFormatJSONObject | ResponseFormatJSONSchema;\n"],"mappings":";;;;;;;;;;;AAW8E,KAAlEW,iBAAAA,GAAoBV,QAAAA,CAAaW,SAAiC,GAAA,CAAA,MAAA,GAAXC,WAAW,CAAA,OAAA,CAAA,CAAA;AAClEC,KAAAA,oBAAAA,GAAoB,KAAA,GAAA,QAAA,GAAA,MAAA,GAAA,IAAA;AACpBC,KAAAA,YAAAA,GAAeb,aAAAA,CAAAA,QAAa,CAAA;AACfc,kBAAAA,eAAAA,CAAe;EAAA;EAAA,WAuBxBC,EAAAA,MAAAA;EAAM;;;;EA6CG,SAITH,CAAAA,EAAAA,MAAAA;EAAoB;AAEpC;AACA;;;EAIsC,mBAJKL,CAAAA,EAAAA,MAAAA;EAA4B;EAS9CY,IAAAA,EAAAA,MAAAA;EAMRC;EAAe,gBAAA,EAAA,MAAA;EAAA;EAYiC,eAuB7BC,EAAKE,MAAAA;EAAsB;EAAzC,CAAA,EAMVxB,MAAAA;EAA0C;EAOhB,SAYnBA,CAAAA,EA/HHgB,MA+HgBY,CAAAA,MAAUC,EAAAA,MAAAA,CAAAA;EAAoB;EA5DN,IAAA,CAAA,EAAA,MAAA;EAoEvCC;EA0DAE,SAAAA,EAAAA,OAAAA;EAAoB;;;AAA0C;EAK1EC,WAAAA,CAAAA,EAAAA,OAAAA;EAAkC;;;;;EAClB,SAMLjB,EAAAA,MAAAA;EAAM;EAAgC,KAAA,EA5L3CN,iBA4L2C;EAM1CyB;;;;EAAiC;EAM0B,WAA1DV,CAAAA,EAlMKT,MAkMLS,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA;EAAK;AAIlB;;;EAAyD,IAAGtB,CAAAA,EAAAA,MAAAA,EAAAA;EAAwB;EAA4B,aAAGE,CAAAA,EAAAA,MAAAA,EAAAA;EAAwB;AAAqC;AAChL;EAAuC,OAAA,CAAA,EAAA,MAAA;EAAA;;;AAA2E;;iBAtL/FS;;;;;WAKNA;;;;cAIGD;;KAEJI,wBAAAA,GAA2BjB,QAAAA,CAAakB;UACnCC,iBAAAA,SAA0BX;;;;YAI7BS;;;;;kBAKWG,WAAAA,SAAoBL;;;;;;UAM5BM,eAAAA,SAAwBN;;;;;;;;;;;;mBAYpBf,QAAAA,CAAasB,IAAAA,CAAKC;;;;;;;;;;;;;;;;;;;;;;;eAuBtBE,MAAMzB,QAAAA,CAAasB,IAAAA,CAAKE;;;;;;UAM7BxB,QAAAA,CAAasB,IAAAA,CAAKI;;;;;;;cAOd1B,QAAAA,CAAa2B;;;;;;;;;;;;iBAYV3B,QAAAA,CAAa4B,SAAAA,CAAUC;;;;;;;;UAQzBC,gBAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAwDgBC;;UAEhBC,oBAAAA,SAA6BX,iBAAiBS;;;;;KAK1DG,kCAAAA,GAAqCC,KAAK9B;eAC9B8B,KAAK9B;;;;;;YAMNY,sBAAsBP;;;;;;KAM1B0B,0BAAAA,GAA6BD,KAAKlC,QAAAA,CAAa4B,SAAAA,CAAUQ;;;;;;WAMxDX,MAAMzB,QAAAA,CAAa4B,SAAAA,CAAUQ,qBAAAA,CAAsBC;;;;KAIpDC,wBAAAA,GAA2BpC,qBAAqBC,2BAA2BG,4BAA4BD,2BAA2B4B;KAClIM,2BAAAA,GAA8BrC,qBAAqBC,2BAA2BC"}
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":["OpenAI","OpenAIClient","ClientOptions","ResponseFormatText","ResponseFormatJSONObject","ResponseFormatJSONSchema","ResponseFormatTextPython","ResponseFormatTextGrammar","TiktokenModel","BaseLanguageModelCallOptions","InteropZodObject","OpenAIChatModelId","ChatModel","NonNullable","OpenAIVerbosityParam","OpenAIApiKey","OpenAIBaseInput","Record","OpenAICoreRequestOptions","RequestOptions","OpenAICallOptions","OpenAIInput","OpenAIChatInput","Chat","ChatCompletionMessageParam","ChatCompletionModality","Array","ChatCompletionAudioParam","Reasoning","Responses","ResponseCreateParams","AzureOpenAIInput","Promise","AzureOpenAIChatInput","ChatOpenAIResponseFormatJSONSchema","Omit","ChatOpenAIReasoningSummary","ResponseReasoningItem","Summary","ChatOpenAIResponseFormat","ResponseFormatConfiguration"],"sources":["../src/types.d.ts"],"sourcesContent":["import type { OpenAI as OpenAIClient, ClientOptions } from \"openai\";\nimport type { ResponseFormatText, ResponseFormatJSONObject, ResponseFormatJSONSchema, ResponseFormatTextPython, ResponseFormatTextGrammar } from \"openai/resources/shared\";\nimport { TiktokenModel } from \"js-tiktoken/lite\";\nimport type { BaseLanguageModelCallOptions } from \"@langchain/core/language_models/base\";\nimport { InteropZodObject } from \"@langchain/core/utils/types\";\nexport type { TiktokenModel };\n/**\n * @see https://platform.openai.com/docs/models\n */\nexport type OpenAIChatModelId = OpenAIClient.ChatModel | (string & NonNullable<unknown>);\nexport type OpenAIVerbosityParam = \"low\" | \"medium\" | \"high\" | null;\nexport type OpenAIApiKey = ClientOptions[\"apiKey\"];\nexport declare interface OpenAIBaseInput {\n /** Sampling temperature to use */\n temperature: number;\n /**\n * Maximum number of tokens to generate in the completion. -1 returns as many\n * tokens as possible given the prompt and the model's maximum context size.\n */\n maxTokens?: number;\n /**\n * Maximum number of tokens to generate in the completion. -1 returns as many\n * tokens as possible given the prompt and the model's maximum context size.\n * Alias for `maxTokens` for reasoning models.\n */\n maxCompletionTokens?: number;\n /** Total probability mass of tokens to consider at each step */\n topP: number;\n /** Penalizes repeated tokens according to frequency */\n frequencyPenalty: number;\n /** Penalizes repeated tokens */\n presencePenalty: number;\n /** Number of completions to generate for each prompt */\n n: number;\n /** Dictionary used to adjust the probability of specific tokens being generated */\n logitBias?: Record<string, number>;\n /** Unique string identifier representing your end-user, which can help OpenAI to monitor and detect abuse. */\n user?: string;\n /** Whether to stream the results or not. Enabling disables tokenUsage reporting */\n streaming: boolean;\n /**\n * Whether or not to include token usage data in streamed chunks.\n * @default true\n */\n streamUsage?: boolean;\n /**\n * Model name to use\n * Alias for `model`\n * @deprecated Use \"model\" instead.\n */\n modelName: string;\n /** Model name to use */\n model: OpenAIChatModelId;\n /** Holds any additional parameters that are valid to pass to {@link\n * https://platform.openai.com/docs/api-reference/completions/create |\n * `openai.createCompletion`} that are not explicitly specified on this class.\n */\n modelKwargs?: Record<string, any>;\n /**\n * List of stop words to use when generating\n * Alias for `stopSequences`\n */\n stop?: string[];\n /** List of stop words to use when generating */\n stopSequences?: string[];\n /**\n * Timeout to use when making requests to OpenAI.\n */\n timeout?: number;\n /**\n * API key to use when making requests to OpenAI. Defaults to the value of\n * `OPENAI_API_KEY` environment variable.\n * Alias for `apiKey`\n */\n openAIApiKey?: OpenAIApiKey;\n /**\n * API key to use when making requests to OpenAI. Defaults to the value of\n * `OPENAI_API_KEY` environment variable.\n */\n apiKey?: OpenAIApiKey;\n /**\n * The verbosity of the model's response.\n */\n verbosity?: OpenAIVerbosityParam;\n}\nexport type OpenAICoreRequestOptions = OpenAIClient.RequestOptions;\nexport interface OpenAICallOptions extends BaseLanguageModelCallOptions {\n /**\n * Additional options to pass to the underlying axios request.\n */\n options?: OpenAICoreRequestOptions;\n}\n/**\n * Input to OpenAI class.\n */\nexport declare interface OpenAIInput extends OpenAIBaseInput {\n /** Generates `bestOf` completions server side and returns the \"best\" */\n bestOf?: number;\n /** Batch size to use when passing multiple documents to generate */\n batchSize: number;\n}\nexport interface OpenAIChatInput extends OpenAIBaseInput {\n /**\n * Whether to return log probabilities of the output tokens or not.\n * If true, returns the log probabilities of each output token returned in the content of message.\n */\n logprobs?: boolean;\n /**\n * An integer between 0 and 5 specifying the number of most likely tokens to return at each token position,\n * each with an associated log probability. logprobs must be set to true if this parameter is used.\n */\n topLogprobs?: number;\n /** ChatGPT messages to pass as a prefix to the prompt */\n prefixMessages?: OpenAIClient.Chat.ChatCompletionMessageParam[];\n /**\n * Whether to include the raw OpenAI response in the output message's \"additional_kwargs\" field.\n * Currently in experimental beta.\n */\n __includeRawResponse?: boolean;\n /**\n * Whether the model supports the `strict` argument when passing in tools.\n * If `undefined` the `strict` argument will not be passed to OpenAI.\n */\n supportsStrictToolCalling?: boolean;\n /**\n * Output types that you would like the model to generate for this request. Most\n * models are capable of generating text, which is the default:\n *\n * `[\"text\"]`\n *\n * The `gpt-4o-audio-preview` model can also be used to\n * [generate audio](https://platform.openai.com/docs/guides/audio). To request that\n * this model generate both text and audio responses, you can use:\n *\n * `[\"text\", \"audio\"]`\n */\n modalities?: Array<OpenAIClient.Chat.ChatCompletionModality>;\n /**\n * Parameters for audio output. Required when audio output is requested with\n * `modalities: [\"audio\"]`.\n * [Learn more](https://platform.openai.com/docs/guides/audio).\n */\n audio?: OpenAIClient.Chat.ChatCompletionAudioParam;\n /**\n * Options for reasoning models.\n *\n * Note that some options, like reasoning summaries, are only available when using the responses\n * API. This option is ignored when not using a reasoning model.\n */\n reasoning?: OpenAIClient.Reasoning;\n /**\n * Should be set to `true` in tenancies with Zero Data Retention\n * @see https://platform.openai.com/docs/guides/your-data\n *\n * @default false\n */\n zdrEnabled?: boolean;\n /**\n * Service tier to use for this request. Can be \"auto\", \"default\", or \"flex\" or \"priority\".\n * Specifies the service tier for prioritization and latency optimization.\n */\n service_tier?: OpenAIClient.Responses.ResponseCreateParams[\"service_tier\"];\n /**\n * Used by OpenAI to cache responses for similar requests to optimize your cache\n * hit rates. Replaces the `user` field.\n * [Learn more](https://platform.openai.com/docs/guides/prompt-caching).\n */\n promptCacheKey?: string;\n}\nexport interface AzureOpenAIInput {\n /**\n * API version to use when making requests to Azure OpenAI.\n */\n azureOpenAIApiVersion?: string;\n /**\n * API key to use when making requests to Azure OpenAI.\n */\n azureOpenAIApiKey?: string;\n /**\n * Azure OpenAI API instance name to use when making requests to Azure OpenAI.\n * this is the name of the instance you created in the Azure portal.\n * e.g. \"my-openai-instance\"\n * this will be used in the endpoint URL: https://my-openai-instance.openai.azure.com/openai/deployments/{DeploymentName}/\n */\n azureOpenAIApiInstanceName?: string;\n /**\n * Azure OpenAI API deployment name to use for completions when making requests to Azure OpenAI.\n * This is the name of the deployment you created in the Azure portal.\n * e.g. \"my-openai-deployment\"\n * this will be used in the endpoint URL: https://{InstanceName}.openai.azure.com/openai/deployments/my-openai-deployment/\n */\n azureOpenAIApiDeploymentName?: string;\n /**\n * Azure OpenAI API deployment name to use for embedding when making requests to Azure OpenAI.\n * This is the name of the deployment you created in the Azure portal.\n * This will fallback to azureOpenAIApiDeploymentName if not provided.\n * e.g. \"my-openai-deployment\"\n * this will be used in the endpoint URL: https://{InstanceName}.openai.azure.com/openai/deployments/my-openai-deployment/\n */\n azureOpenAIApiEmbeddingsDeploymentName?: string;\n /**\n * Azure OpenAI API deployment name to use for completions when making requests to Azure OpenAI.\n * Completions are only available for gpt-3.5-turbo and text-davinci-003 deployments.\n * This is the name of the deployment you created in the Azure portal.\n * This will fallback to azureOpenAIApiDeploymentName if not provided.\n * e.g. \"my-openai-deployment\"\n * this will be used in the endpoint URL: https://{InstanceName}.openai.azure.com/openai/deployments/my-openai-deployment/\n */\n azureOpenAIApiCompletionsDeploymentName?: string;\n /**\n * Custom base url for Azure OpenAI API. This is useful in case you have a deployment in another region.\n * e.g. setting this value to \"https://westeurope.api.cognitive.microsoft.com/openai/deployments\"\n * will be result in the endpoint URL: https://westeurope.api.cognitive.microsoft.com/openai/deployments/{DeploymentName}/\n */\n azureOpenAIBasePath?: string;\n /**\n * Custom endpoint for Azure OpenAI API. This is useful in case you have a deployment in another region.\n * e.g. setting this value to \"https://westeurope.api.cognitive.microsoft.com/\"\n * will be result in the endpoint URL: https://westeurope.api.cognitive.microsoft.com/openai/deployments/{DeploymentName}/\n */\n azureOpenAIEndpoint?: string;\n /**\n * A function that returns an access token for Microsoft Entra (formerly known as Azure Active Directory),\n * which will be invoked on every request.\n */\n azureADTokenProvider?: () => Promise<string>;\n}\nexport interface AzureOpenAIChatInput extends OpenAIChatInput, AzureOpenAIInput {\n openAIApiVersion?: string;\n openAIBasePath?: string;\n deploymentName?: string;\n}\ntype ChatOpenAIResponseFormatJSONSchema = Omit<ResponseFormatJSONSchema, \"json_schema\"> & {\n json_schema: Omit<ResponseFormatJSONSchema[\"json_schema\"], \"schema\"> & {\n /**\n * The schema for the response format, described as a JSON Schema object\n * or a Zod object.\n */\n schema: Record<string, any> | InteropZodObject;\n };\n};\n/**\n * The summary of a model's reasoning step.\n */\nexport type ChatOpenAIReasoningSummary = Omit<OpenAIClient.Responses.ResponseReasoningItem, \"summary\"> & {\n /**\n * The summary of the reasoning step. The index field will be populated if the response was\n * streamed. This allows LangChain to recompose the reasoning summary output correctly when the\n * AIMessage is used as an input for future generation requests.\n */\n summary: Array<OpenAIClient.Responses.ResponseReasoningItem.Summary & {\n index?: number;\n }>;\n};\nexport type ChatOpenAIResponseFormat = ResponseFormatText | ResponseFormatJSONObject | ResponseFormatTextGrammar | ResponseFormatTextPython | ChatOpenAIResponseFormatJSONSchema;\nexport type ResponseFormatConfiguration = ResponseFormatText | ResponseFormatJSONObject | ResponseFormatJSONSchema;\n//# sourceMappingURL=types.d.ts.map"],"mappings":";;;;;;;;;AASA;AACA;AACYe,KAFAJ,iBAAAA,GAAoBV,QAAAA,CAAaW,SAEL,GAAA,CAAA,MAAA,GAF2BC,WAE3B,CAAA,OAAA,CAAA,CAAA;AACfG,KAFbF,oBAAAA,GAE4B,KAAA,GAAA,QAAA,GAAA,MAAA,GAAA,IAAA;AAuBxBG,KAxBJF,YAAAA,GAAeb,aAwBXe,CAAAA,QAAAA,CAAAA;AAiBLN,kBAxCcK,eAAAA,CAwCdL;EAKOM;EAiBCF,WAAAA,EAAAA,MAAAA;EAKNA;;AAIuB;AAEpC;EACiBK,SAAAA,CAAAA,EAAAA,MAAAA;EASQC;AAMzB;;;;EAyCYpB,mBAAkB0B,CAAAA,EAAAA,MAAAA;EAOd1B;EAYGA,IAAAA,EAAa4B,MAAAA;EA5DSb;EAAe,gBAAA,EAAA,MAAA;EAoEvCe;EA0DAE,eAAAA,EAAAA,MAAoB;EAKhCC;EAA0C7B,CAAAA,EAAAA,MAAAA;EAAL8B;EACpB9B,SAAAA,CAAAA,EAtMNY,MAsMMZ,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA;EAAL8B;EAKDlB,IAAAA,CAAAA,EAAAA,MAAAA;EAAsBP;EAAgB,SAAA,EAAA,OAAA;EAM1C0B;;;;EAMCV,WAAAA,CAAAA,EAAAA,OAAAA;EAAK;AAIlB;;;;EAAmHpB,SAAAA,EAAAA,MAAAA;EAA2B4B;EAAkC,KAAA,EA1MrKvB,iBA0MqK;EACpK6B;;;;EAAsG,WAAA,CAAA,EAtMhGvB,MAsMgG,CAAA,MAAA,EAAA,GAAA,CAAA;;;;;;;;;;;;;;;;;iBArL/FF;;;;;WAKNA;;;;cAIGD;;KAEJI,wBAAAA,GAA2BjB,QAAAA,CAAakB;UACnCC,iBAAAA,SAA0BX;;;;YAI7BS;;;;;kBAKWG,WAAAA,SAAoBL;;;;;;UAM5BM,eAAAA,SAAwBN;;;;;;;;;;;;mBAYpBf,QAAAA,CAAasB,IAAAA,CAAKC;;;;;;;;;;;;;;;;;;;;;;;eAuBtBE,MAAMzB,QAAAA,CAAasB,IAAAA,CAAKE;;;;;;UAM7BxB,QAAAA,CAAasB,IAAAA,CAAKI;;;;;;;cAOd1B,QAAAA,CAAa2B;;;;;;;;;;;;iBAYV3B,QAAAA,CAAa4B,SAAAA,CAAUC;;;;;;;;UAQzBC,gBAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAwDgBC;;UAEhBC,oBAAAA,SAA6BX,iBAAiBS;;;;;KAK1DG,kCAAAA,GAAqCC,KAAK9B;eAC9B8B,KAAK9B;;;;;YAKNY,sBAAsBP;;;;;;KAM1B0B,0BAAAA,GAA6BD,KAAKlC,QAAAA,CAAa4B,SAAAA,CAAUQ;;;;;;WAMxDX,MAAMzB,QAAAA,CAAa4B,SAAAA,CAAUQ,qBAAAA,CAAsBC;;;;KAIpDC,wBAAAA,GAA2BpC,qBAAqBC,2BAA2BG,4BAA4BD,2BAA2B4B;KAClIM,2BAAAA,GAA8BrC,qBAAqBC,2BAA2BC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ClientOptions, OpenAI as OpenAI$1 } from "openai";
|
|
2
2
|
import { InteropZodObject } from "@langchain/core/utils/types";
|
|
3
3
|
import { BaseLanguageModelCallOptions } from "@langchain/core/language_models/base";
|
|
4
|
-
import { TiktokenModel } from "js-tiktoken/lite";
|
|
5
4
|
import { ResponseFormatJSONObject, ResponseFormatJSONSchema, ResponseFormatText, ResponseFormatTextGrammar, ResponseFormatTextPython } from "openai/resources/shared";
|
|
5
|
+
import { TiktokenModel } from "js-tiktoken/lite";
|
|
6
6
|
|
|
7
7
|
//#region src/types.d.ts
|
|
8
8
|
|
|
@@ -57,7 +57,6 @@ declare interface OpenAIBaseInput {
|
|
|
57
57
|
* https://platform.openai.com/docs/api-reference/completions/create |
|
|
58
58
|
* `openai.createCompletion`} that are not explicitly specified on this class.
|
|
59
59
|
*/
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
60
|
modelKwargs?: Record<string, any>;
|
|
62
61
|
/**
|
|
63
62
|
* List of stop words to use when generating
|
|
@@ -239,7 +238,6 @@ type ChatOpenAIResponseFormatJSONSchema = Omit<ResponseFormatJSONSchema, "json_s
|
|
|
239
238
|
* The schema for the response format, described as a JSON Schema object
|
|
240
239
|
* or a Zod object.
|
|
241
240
|
*/
|
|
242
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
243
241
|
schema: Record<string, any> | InteropZodObject;
|
|
244
242
|
};
|
|
245
243
|
};
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":["OpenAI","OpenAIClient","ClientOptions","ResponseFormatText","ResponseFormatJSONObject","ResponseFormatJSONSchema","ResponseFormatTextPython","ResponseFormatTextGrammar","TiktokenModel","BaseLanguageModelCallOptions","InteropZodObject","OpenAIChatModelId","ChatModel","NonNullable","OpenAIVerbosityParam","OpenAIApiKey","OpenAIBaseInput","Record","OpenAICoreRequestOptions","RequestOptions","OpenAICallOptions","OpenAIInput","OpenAIChatInput","Chat","ChatCompletionMessageParam","ChatCompletionModality","Array","ChatCompletionAudioParam","Reasoning","Responses","ResponseCreateParams","AzureOpenAIInput","Promise","AzureOpenAIChatInput","ChatOpenAIResponseFormatJSONSchema","Omit","ChatOpenAIReasoningSummary","ResponseReasoningItem","Summary","ChatOpenAIResponseFormat","ResponseFormatConfiguration"],"sources":["../src/types.d.ts"],"sourcesContent":["import type { OpenAI as OpenAIClient, ClientOptions } from \"openai\";\nimport type { ResponseFormatText, ResponseFormatJSONObject, ResponseFormatJSONSchema, ResponseFormatTextPython, ResponseFormatTextGrammar } from \"openai/resources/shared\";\nimport { TiktokenModel } from \"js-tiktoken/lite\";\nimport type { BaseLanguageModelCallOptions } from \"@langchain/core/language_models/base\";\nimport { InteropZodObject } from \"@langchain/core/utils/types\";\n// reexport this type from the included package so we can easily override and extend it if needed in the future\n// also makes it easier for folks to import this type without digging around into the dependent packages\nexport type { TiktokenModel };\n/**\n * @see https://platform.openai.com/docs/models\n */\nexport type OpenAIChatModelId = OpenAIClient.ChatModel | (string & NonNullable<unknown>);\nexport type OpenAIVerbosityParam = \"low\" | \"medium\" | \"high\" | null;\nexport type OpenAIApiKey = ClientOptions[\"apiKey\"];\nexport declare interface OpenAIBaseInput {\n /** Sampling temperature to use */\n temperature: number;\n /**\n * Maximum number of tokens to generate in the completion. -1 returns as many\n * tokens as possible given the prompt and the model's maximum context size.\n */\n maxTokens?: number;\n /**\n * Maximum number of tokens to generate in the completion. -1 returns as many\n * tokens as possible given the prompt and the model's maximum context size.\n * Alias for `maxTokens` for reasoning models.\n */\n maxCompletionTokens?: number;\n /** Total probability mass of tokens to consider at each step */\n topP: number;\n /** Penalizes repeated tokens according to frequency */\n frequencyPenalty: number;\n /** Penalizes repeated tokens */\n presencePenalty: number;\n /** Number of completions to generate for each prompt */\n n: number;\n /** Dictionary used to adjust the probability of specific tokens being generated */\n logitBias?: Record<string, number>;\n /** Unique string identifier representing your end-user, which can help OpenAI to monitor and detect abuse. */\n user?: string;\n /** Whether to stream the results or not. Enabling disables tokenUsage reporting */\n streaming: boolean;\n /**\n * Whether or not to include token usage data in streamed chunks.\n * @default true\n */\n streamUsage?: boolean;\n /**\n * Model name to use\n * Alias for `model`\n * @deprecated Use \"model\" instead.\n */\n modelName: string;\n /** Model name to use */\n model: OpenAIChatModelId;\n /** Holds any additional parameters that are valid to pass to {@link\n * https://platform.openai.com/docs/api-reference/completions/create |\n * `openai.createCompletion`} that are not explicitly specified on this class.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n modelKwargs?: Record<string, any>;\n /**\n * List of stop words to use when generating\n * Alias for `stopSequences`\n */\n stop?: string[];\n /** List of stop words to use when generating */\n stopSequences?: string[];\n /**\n * Timeout to use when making requests to OpenAI.\n */\n timeout?: number;\n /**\n * API key to use when making requests to OpenAI. Defaults to the value of\n * `OPENAI_API_KEY` environment variable.\n * Alias for `apiKey`\n */\n openAIApiKey?: OpenAIApiKey;\n /**\n * API key to use when making requests to OpenAI. Defaults to the value of\n * `OPENAI_API_KEY` environment variable.\n */\n apiKey?: OpenAIApiKey;\n /**\n * The verbosity of the model's response.\n */\n verbosity?: OpenAIVerbosityParam;\n}\nexport type OpenAICoreRequestOptions = OpenAIClient.RequestOptions;\nexport interface OpenAICallOptions extends BaseLanguageModelCallOptions {\n /**\n * Additional options to pass to the underlying axios request.\n */\n options?: OpenAICoreRequestOptions;\n}\n/**\n * Input to OpenAI class.\n */\nexport declare interface OpenAIInput extends OpenAIBaseInput {\n /** Generates `bestOf` completions server side and returns the \"best\" */\n bestOf?: number;\n /** Batch size to use when passing multiple documents to generate */\n batchSize: number;\n}\nexport interface OpenAIChatInput extends OpenAIBaseInput {\n /**\n * Whether to return log probabilities of the output tokens or not.\n * If true, returns the log probabilities of each output token returned in the content of message.\n */\n logprobs?: boolean;\n /**\n * An integer between 0 and 5 specifying the number of most likely tokens to return at each token position,\n * each with an associated log probability. logprobs must be set to true if this parameter is used.\n */\n topLogprobs?: number;\n /** ChatGPT messages to pass as a prefix to the prompt */\n prefixMessages?: OpenAIClient.Chat.ChatCompletionMessageParam[];\n /**\n * Whether to include the raw OpenAI response in the output message's \"additional_kwargs\" field.\n * Currently in experimental beta.\n */\n __includeRawResponse?: boolean;\n /**\n * Whether the model supports the `strict` argument when passing in tools.\n * If `undefined` the `strict` argument will not be passed to OpenAI.\n */\n supportsStrictToolCalling?: boolean;\n /**\n * Output types that you would like the model to generate for this request. Most\n * models are capable of generating text, which is the default:\n *\n * `[\"text\"]`\n *\n * The `gpt-4o-audio-preview` model can also be used to\n * [generate audio](https://platform.openai.com/docs/guides/audio). To request that\n * this model generate both text and audio responses, you can use:\n *\n * `[\"text\", \"audio\"]`\n */\n modalities?: Array<OpenAIClient.Chat.ChatCompletionModality>;\n /**\n * Parameters for audio output. Required when audio output is requested with\n * `modalities: [\"audio\"]`.\n * [Learn more](https://platform.openai.com/docs/guides/audio).\n */\n audio?: OpenAIClient.Chat.ChatCompletionAudioParam;\n /**\n * Options for reasoning models.\n *\n * Note that some options, like reasoning summaries, are only available when using the responses\n * API. This option is ignored when not using a reasoning model.\n */\n reasoning?: OpenAIClient.Reasoning;\n /**\n * Should be set to `true` in tenancies with Zero Data Retention\n * @see https://platform.openai.com/docs/guides/your-data\n *\n * @default false\n */\n zdrEnabled?: boolean;\n /**\n * Service tier to use for this request. Can be \"auto\", \"default\", or \"flex\" or \"priority\".\n * Specifies the service tier for prioritization and latency optimization.\n */\n service_tier?: OpenAIClient.Responses.ResponseCreateParams[\"service_tier\"];\n /**\n * Used by OpenAI to cache responses for similar requests to optimize your cache\n * hit rates. Replaces the `user` field.\n * [Learn more](https://platform.openai.com/docs/guides/prompt-caching).\n */\n promptCacheKey?: string;\n}\nexport interface AzureOpenAIInput {\n /**\n * API version to use when making requests to Azure OpenAI.\n */\n azureOpenAIApiVersion?: string;\n /**\n * API key to use when making requests to Azure OpenAI.\n */\n azureOpenAIApiKey?: string;\n /**\n * Azure OpenAI API instance name to use when making requests to Azure OpenAI.\n * this is the name of the instance you created in the Azure portal.\n * e.g. \"my-openai-instance\"\n * this will be used in the endpoint URL: https://my-openai-instance.openai.azure.com/openai/deployments/{DeploymentName}/\n */\n azureOpenAIApiInstanceName?: string;\n /**\n * Azure OpenAI API deployment name to use for completions when making requests to Azure OpenAI.\n * This is the name of the deployment you created in the Azure portal.\n * e.g. \"my-openai-deployment\"\n * this will be used in the endpoint URL: https://{InstanceName}.openai.azure.com/openai/deployments/my-openai-deployment/\n */\n azureOpenAIApiDeploymentName?: string;\n /**\n * Azure OpenAI API deployment name to use for embedding when making requests to Azure OpenAI.\n * This is the name of the deployment you created in the Azure portal.\n * This will fallback to azureOpenAIApiDeploymentName if not provided.\n * e.g. \"my-openai-deployment\"\n * this will be used in the endpoint URL: https://{InstanceName}.openai.azure.com/openai/deployments/my-openai-deployment/\n */\n azureOpenAIApiEmbeddingsDeploymentName?: string;\n /**\n * Azure OpenAI API deployment name to use for completions when making requests to Azure OpenAI.\n * Completions are only available for gpt-3.5-turbo and text-davinci-003 deployments.\n * This is the name of the deployment you created in the Azure portal.\n * This will fallback to azureOpenAIApiDeploymentName if not provided.\n * e.g. \"my-openai-deployment\"\n * this will be used in the endpoint URL: https://{InstanceName}.openai.azure.com/openai/deployments/my-openai-deployment/\n */\n azureOpenAIApiCompletionsDeploymentName?: string;\n /**\n * Custom base url for Azure OpenAI API. This is useful in case you have a deployment in another region.\n * e.g. setting this value to \"https://westeurope.api.cognitive.microsoft.com/openai/deployments\"\n * will be result in the endpoint URL: https://westeurope.api.cognitive.microsoft.com/openai/deployments/{DeploymentName}/\n */\n azureOpenAIBasePath?: string;\n /**\n * Custom endpoint for Azure OpenAI API. This is useful in case you have a deployment in another region.\n * e.g. setting this value to \"https://westeurope.api.cognitive.microsoft.com/\"\n * will be result in the endpoint URL: https://westeurope.api.cognitive.microsoft.com/openai/deployments/{DeploymentName}/\n */\n azureOpenAIEndpoint?: string;\n /**\n * A function that returns an access token for Microsoft Entra (formerly known as Azure Active Directory),\n * which will be invoked on every request.\n */\n azureADTokenProvider?: () => Promise<string>;\n}\nexport interface AzureOpenAIChatInput extends OpenAIChatInput, AzureOpenAIInput {\n openAIApiVersion?: string;\n openAIBasePath?: string;\n deploymentName?: string;\n}\ntype ChatOpenAIResponseFormatJSONSchema = Omit<ResponseFormatJSONSchema, \"json_schema\"> & {\n json_schema: Omit<ResponseFormatJSONSchema[\"json_schema\"], \"schema\"> & {\n /**\n * The schema for the response format, described as a JSON Schema object\n * or a Zod object.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema: Record<string, any> | InteropZodObject;\n };\n};\n/**\n * The summary of a model's reasoning step.\n */\nexport type ChatOpenAIReasoningSummary = Omit<OpenAIClient.Responses.ResponseReasoningItem, \"summary\"> & {\n /**\n * The summary of the reasoning step. The index field will be populated if the response was\n * streamed. This allows LangChain to recompose the reasoning summary output correctly when the\n * AIMessage is used as an input for future generation requests.\n */\n summary: Array<OpenAIClient.Responses.ResponseReasoningItem.Summary & {\n index?: number;\n }>;\n};\nexport type ChatOpenAIResponseFormat = ResponseFormatText | ResponseFormatJSONObject | ResponseFormatTextGrammar | ResponseFormatTextPython | ChatOpenAIResponseFormatJSONSchema;\nexport type ResponseFormatConfiguration = ResponseFormatText | ResponseFormatJSONObject | ResponseFormatJSONSchema;\n"],"mappings":";;;;;;;;;;;AAW8E,KAAlEW,iBAAAA,GAAoBV,QAAAA,CAAaW,SAAiC,GAAA,CAAA,MAAA,GAAXC,WAAW,CAAA,OAAA,CAAA,CAAA;AAClEC,KAAAA,oBAAAA,GAAoB,KAAA,GAAA,QAAA,GAAA,MAAA,GAAA,IAAA;AACpBC,KAAAA,YAAAA,GAAeb,aAAAA,CAAAA,QAAa,CAAA;AACfc,kBAAAA,eAAAA,CAAe;EAAA;EAAA,WAuBxBC,EAAAA,MAAAA;EAAM;;;;EA6CG,SAITH,CAAAA,EAAAA,MAAAA;EAAoB;AAEpC;AACA;;;EAIsC,mBAJKL,CAAAA,EAAAA,MAAAA;EAA4B;EAS9CY,IAAAA,EAAAA,MAAAA;EAMRC;EAAe,gBAAA,EAAA,MAAA;EAAA;EAYiC,eAuB7BC,EAAKE,MAAAA;EAAsB;EAAzC,CAAA,EAMVxB,MAAAA;EAA0C;EAOhB,SAYnBA,CAAAA,EA/HHgB,MA+HgBY,CAAAA,MAAUC,EAAAA,MAAAA,CAAAA;EAAoB;EA5DN,IAAA,CAAA,EAAA,MAAA;EAoEvCC;EA0DAE,SAAAA,EAAAA,OAAAA;EAAoB;;;AAA0C;EAK1EC,WAAAA,CAAAA,EAAAA,OAAAA;EAAkC;;;;;EAClB,SAMLjB,EAAAA,MAAAA;EAAM;EAAgC,KAAA,EA5L3CN,iBA4L2C;EAM1CyB;;;;EAAiC;EAM0B,WAA1DV,CAAAA,EAlMKT,MAkMLS,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA;EAAK;AAIlB;;;EAAyD,IAAGtB,CAAAA,EAAAA,MAAAA,EAAAA;EAAwB;EAA4B,aAAGE,CAAAA,EAAAA,MAAAA,EAAAA;EAAwB;AAAqC;AAChL;EAAuC,OAAA,CAAA,EAAA,MAAA;EAAA;;;AAA2E;;iBAtL/FS;;;;;WAKNA;;;;cAIGD;;KAEJI,wBAAAA,GAA2BjB,QAAAA,CAAakB;UACnCC,iBAAAA,SAA0BX;;;;YAI7BS;;;;;kBAKWG,WAAAA,SAAoBL;;;;;;UAM5BM,eAAAA,SAAwBN;;;;;;;;;;;;mBAYpBf,QAAAA,CAAasB,IAAAA,CAAKC;;;;;;;;;;;;;;;;;;;;;;;eAuBtBE,MAAMzB,QAAAA,CAAasB,IAAAA,CAAKE;;;;;;UAM7BxB,QAAAA,CAAasB,IAAAA,CAAKI;;;;;;;cAOd1B,QAAAA,CAAa2B;;;;;;;;;;;;iBAYV3B,QAAAA,CAAa4B,SAAAA,CAAUC;;;;;;;;UAQzBC,gBAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAwDgBC;;UAEhBC,oBAAAA,SAA6BX,iBAAiBS;;;;;KAK1DG,kCAAAA,GAAqCC,KAAK9B;eAC9B8B,KAAK9B;;;;;;YAMNY,sBAAsBP;;;;;;KAM1B0B,0BAAAA,GAA6BD,KAAKlC,QAAAA,CAAa4B,SAAAA,CAAUQ;;;;;;WAMxDX,MAAMzB,QAAAA,CAAa4B,SAAAA,CAAUQ,qBAAAA,CAAsBC;;;;KAIpDC,wBAAAA,GAA2BpC,qBAAqBC,2BAA2BG,4BAA4BD,2BAA2B4B;KAClIM,2BAAAA,GAA8BrC,qBAAqBC,2BAA2BC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":["OpenAI","OpenAIClient","ClientOptions","ResponseFormatText","ResponseFormatJSONObject","ResponseFormatJSONSchema","ResponseFormatTextPython","ResponseFormatTextGrammar","TiktokenModel","BaseLanguageModelCallOptions","InteropZodObject","OpenAIChatModelId","ChatModel","NonNullable","OpenAIVerbosityParam","OpenAIApiKey","OpenAIBaseInput","Record","OpenAICoreRequestOptions","RequestOptions","OpenAICallOptions","OpenAIInput","OpenAIChatInput","Chat","ChatCompletionMessageParam","ChatCompletionModality","Array","ChatCompletionAudioParam","Reasoning","Responses","ResponseCreateParams","AzureOpenAIInput","Promise","AzureOpenAIChatInput","ChatOpenAIResponseFormatJSONSchema","Omit","ChatOpenAIReasoningSummary","ResponseReasoningItem","Summary","ChatOpenAIResponseFormat","ResponseFormatConfiguration"],"sources":["../src/types.d.ts"],"sourcesContent":["import type { OpenAI as OpenAIClient, ClientOptions } from \"openai\";\nimport type { ResponseFormatText, ResponseFormatJSONObject, ResponseFormatJSONSchema, ResponseFormatTextPython, ResponseFormatTextGrammar } from \"openai/resources/shared\";\nimport { TiktokenModel } from \"js-tiktoken/lite\";\nimport type { BaseLanguageModelCallOptions } from \"@langchain/core/language_models/base\";\nimport { InteropZodObject } from \"@langchain/core/utils/types\";\nexport type { TiktokenModel };\n/**\n * @see https://platform.openai.com/docs/models\n */\nexport type OpenAIChatModelId = OpenAIClient.ChatModel | (string & NonNullable<unknown>);\nexport type OpenAIVerbosityParam = \"low\" | \"medium\" | \"high\" | null;\nexport type OpenAIApiKey = ClientOptions[\"apiKey\"];\nexport declare interface OpenAIBaseInput {\n /** Sampling temperature to use */\n temperature: number;\n /**\n * Maximum number of tokens to generate in the completion. -1 returns as many\n * tokens as possible given the prompt and the model's maximum context size.\n */\n maxTokens?: number;\n /**\n * Maximum number of tokens to generate in the completion. -1 returns as many\n * tokens as possible given the prompt and the model's maximum context size.\n * Alias for `maxTokens` for reasoning models.\n */\n maxCompletionTokens?: number;\n /** Total probability mass of tokens to consider at each step */\n topP: number;\n /** Penalizes repeated tokens according to frequency */\n frequencyPenalty: number;\n /** Penalizes repeated tokens */\n presencePenalty: number;\n /** Number of completions to generate for each prompt */\n n: number;\n /** Dictionary used to adjust the probability of specific tokens being generated */\n logitBias?: Record<string, number>;\n /** Unique string identifier representing your end-user, which can help OpenAI to monitor and detect abuse. */\n user?: string;\n /** Whether to stream the results or not. Enabling disables tokenUsage reporting */\n streaming: boolean;\n /**\n * Whether or not to include token usage data in streamed chunks.\n * @default true\n */\n streamUsage?: boolean;\n /**\n * Model name to use\n * Alias for `model`\n * @deprecated Use \"model\" instead.\n */\n modelName: string;\n /** Model name to use */\n model: OpenAIChatModelId;\n /** Holds any additional parameters that are valid to pass to {@link\n * https://platform.openai.com/docs/api-reference/completions/create |\n * `openai.createCompletion`} that are not explicitly specified on this class.\n */\n modelKwargs?: Record<string, any>;\n /**\n * List of stop words to use when generating\n * Alias for `stopSequences`\n */\n stop?: string[];\n /** List of stop words to use when generating */\n stopSequences?: string[];\n /**\n * Timeout to use when making requests to OpenAI.\n */\n timeout?: number;\n /**\n * API key to use when making requests to OpenAI. Defaults to the value of\n * `OPENAI_API_KEY` environment variable.\n * Alias for `apiKey`\n */\n openAIApiKey?: OpenAIApiKey;\n /**\n * API key to use when making requests to OpenAI. Defaults to the value of\n * `OPENAI_API_KEY` environment variable.\n */\n apiKey?: OpenAIApiKey;\n /**\n * The verbosity of the model's response.\n */\n verbosity?: OpenAIVerbosityParam;\n}\nexport type OpenAICoreRequestOptions = OpenAIClient.RequestOptions;\nexport interface OpenAICallOptions extends BaseLanguageModelCallOptions {\n /**\n * Additional options to pass to the underlying axios request.\n */\n options?: OpenAICoreRequestOptions;\n}\n/**\n * Input to OpenAI class.\n */\nexport declare interface OpenAIInput extends OpenAIBaseInput {\n /** Generates `bestOf` completions server side and returns the \"best\" */\n bestOf?: number;\n /** Batch size to use when passing multiple documents to generate */\n batchSize: number;\n}\nexport interface OpenAIChatInput extends OpenAIBaseInput {\n /**\n * Whether to return log probabilities of the output tokens or not.\n * If true, returns the log probabilities of each output token returned in the content of message.\n */\n logprobs?: boolean;\n /**\n * An integer between 0 and 5 specifying the number of most likely tokens to return at each token position,\n * each with an associated log probability. logprobs must be set to true if this parameter is used.\n */\n topLogprobs?: number;\n /** ChatGPT messages to pass as a prefix to the prompt */\n prefixMessages?: OpenAIClient.Chat.ChatCompletionMessageParam[];\n /**\n * Whether to include the raw OpenAI response in the output message's \"additional_kwargs\" field.\n * Currently in experimental beta.\n */\n __includeRawResponse?: boolean;\n /**\n * Whether the model supports the `strict` argument when passing in tools.\n * If `undefined` the `strict` argument will not be passed to OpenAI.\n */\n supportsStrictToolCalling?: boolean;\n /**\n * Output types that you would like the model to generate for this request. Most\n * models are capable of generating text, which is the default:\n *\n * `[\"text\"]`\n *\n * The `gpt-4o-audio-preview` model can also be used to\n * [generate audio](https://platform.openai.com/docs/guides/audio). To request that\n * this model generate both text and audio responses, you can use:\n *\n * `[\"text\", \"audio\"]`\n */\n modalities?: Array<OpenAIClient.Chat.ChatCompletionModality>;\n /**\n * Parameters for audio output. Required when audio output is requested with\n * `modalities: [\"audio\"]`.\n * [Learn more](https://platform.openai.com/docs/guides/audio).\n */\n audio?: OpenAIClient.Chat.ChatCompletionAudioParam;\n /**\n * Options for reasoning models.\n *\n * Note that some options, like reasoning summaries, are only available when using the responses\n * API. This option is ignored when not using a reasoning model.\n */\n reasoning?: OpenAIClient.Reasoning;\n /**\n * Should be set to `true` in tenancies with Zero Data Retention\n * @see https://platform.openai.com/docs/guides/your-data\n *\n * @default false\n */\n zdrEnabled?: boolean;\n /**\n * Service tier to use for this request. Can be \"auto\", \"default\", or \"flex\" or \"priority\".\n * Specifies the service tier for prioritization and latency optimization.\n */\n service_tier?: OpenAIClient.Responses.ResponseCreateParams[\"service_tier\"];\n /**\n * Used by OpenAI to cache responses for similar requests to optimize your cache\n * hit rates. Replaces the `user` field.\n * [Learn more](https://platform.openai.com/docs/guides/prompt-caching).\n */\n promptCacheKey?: string;\n}\nexport interface AzureOpenAIInput {\n /**\n * API version to use when making requests to Azure OpenAI.\n */\n azureOpenAIApiVersion?: string;\n /**\n * API key to use when making requests to Azure OpenAI.\n */\n azureOpenAIApiKey?: string;\n /**\n * Azure OpenAI API instance name to use when making requests to Azure OpenAI.\n * this is the name of the instance you created in the Azure portal.\n * e.g. \"my-openai-instance\"\n * this will be used in the endpoint URL: https://my-openai-instance.openai.azure.com/openai/deployments/{DeploymentName}/\n */\n azureOpenAIApiInstanceName?: string;\n /**\n * Azure OpenAI API deployment name to use for completions when making requests to Azure OpenAI.\n * This is the name of the deployment you created in the Azure portal.\n * e.g. \"my-openai-deployment\"\n * this will be used in the endpoint URL: https://{InstanceName}.openai.azure.com/openai/deployments/my-openai-deployment/\n */\n azureOpenAIApiDeploymentName?: string;\n /**\n * Azure OpenAI API deployment name to use for embedding when making requests to Azure OpenAI.\n * This is the name of the deployment you created in the Azure portal.\n * This will fallback to azureOpenAIApiDeploymentName if not provided.\n * e.g. \"my-openai-deployment\"\n * this will be used in the endpoint URL: https://{InstanceName}.openai.azure.com/openai/deployments/my-openai-deployment/\n */\n azureOpenAIApiEmbeddingsDeploymentName?: string;\n /**\n * Azure OpenAI API deployment name to use for completions when making requests to Azure OpenAI.\n * Completions are only available for gpt-3.5-turbo and text-davinci-003 deployments.\n * This is the name of the deployment you created in the Azure portal.\n * This will fallback to azureOpenAIApiDeploymentName if not provided.\n * e.g. \"my-openai-deployment\"\n * this will be used in the endpoint URL: https://{InstanceName}.openai.azure.com/openai/deployments/my-openai-deployment/\n */\n azureOpenAIApiCompletionsDeploymentName?: string;\n /**\n * Custom base url for Azure OpenAI API. This is useful in case you have a deployment in another region.\n * e.g. setting this value to \"https://westeurope.api.cognitive.microsoft.com/openai/deployments\"\n * will be result in the endpoint URL: https://westeurope.api.cognitive.microsoft.com/openai/deployments/{DeploymentName}/\n */\n azureOpenAIBasePath?: string;\n /**\n * Custom endpoint for Azure OpenAI API. This is useful in case you have a deployment in another region.\n * e.g. setting this value to \"https://westeurope.api.cognitive.microsoft.com/\"\n * will be result in the endpoint URL: https://westeurope.api.cognitive.microsoft.com/openai/deployments/{DeploymentName}/\n */\n azureOpenAIEndpoint?: string;\n /**\n * A function that returns an access token for Microsoft Entra (formerly known as Azure Active Directory),\n * which will be invoked on every request.\n */\n azureADTokenProvider?: () => Promise<string>;\n}\nexport interface AzureOpenAIChatInput extends OpenAIChatInput, AzureOpenAIInput {\n openAIApiVersion?: string;\n openAIBasePath?: string;\n deploymentName?: string;\n}\ntype ChatOpenAIResponseFormatJSONSchema = Omit<ResponseFormatJSONSchema, \"json_schema\"> & {\n json_schema: Omit<ResponseFormatJSONSchema[\"json_schema\"], \"schema\"> & {\n /**\n * The schema for the response format, described as a JSON Schema object\n * or a Zod object.\n */\n schema: Record<string, any> | InteropZodObject;\n };\n};\n/**\n * The summary of a model's reasoning step.\n */\nexport type ChatOpenAIReasoningSummary = Omit<OpenAIClient.Responses.ResponseReasoningItem, \"summary\"> & {\n /**\n * The summary of the reasoning step. The index field will be populated if the response was\n * streamed. This allows LangChain to recompose the reasoning summary output correctly when the\n * AIMessage is used as an input for future generation requests.\n */\n summary: Array<OpenAIClient.Responses.ResponseReasoningItem.Summary & {\n index?: number;\n }>;\n};\nexport type ChatOpenAIResponseFormat = ResponseFormatText | ResponseFormatJSONObject | ResponseFormatTextGrammar | ResponseFormatTextPython | ChatOpenAIResponseFormatJSONSchema;\nexport type ResponseFormatConfiguration = ResponseFormatText | ResponseFormatJSONObject | ResponseFormatJSONSchema;\n//# sourceMappingURL=types.d.ts.map"],"mappings":";;;;;;;;;AASA;AACA;AACYe,KAFAJ,iBAAAA,GAAoBV,QAAAA,CAAaW,SAEL,GAAA,CAAA,MAAA,GAF2BC,WAE3B,CAAA,OAAA,CAAA,CAAA;AACfG,KAFbF,oBAAAA,GAE4B,KAAA,GAAA,QAAA,GAAA,MAAA,GAAA,IAAA;AAuBxBG,KAxBJF,YAAAA,GAAeb,aAwBXe,CAAAA,QAAAA,CAAAA;AAiBLN,kBAxCcK,eAAAA,CAwCdL;EAKOM;EAiBCF,WAAAA,EAAAA,MAAAA;EAKNA;;AAIuB;AAEpC;EACiBK,SAAAA,CAAAA,EAAAA,MAAAA;EASQC;AAMzB;;;;EAyCYpB,mBAAkB0B,CAAAA,EAAAA,MAAAA;EAOd1B;EAYGA,IAAAA,EAAa4B,MAAAA;EA5DSb;EAAe,gBAAA,EAAA,MAAA;EAoEvCe;EA0DAE,eAAAA,EAAAA,MAAoB;EAKhCC;EAA0C7B,CAAAA,EAAAA,MAAAA;EAAL8B;EACpB9B,SAAAA,CAAAA,EAtMNY,MAsMMZ,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA;EAAL8B;EAKDlB,IAAAA,CAAAA,EAAAA,MAAAA;EAAsBP;EAAgB,SAAA,EAAA,OAAA;EAM1C0B;;;;EAMCV,WAAAA,CAAAA,EAAAA,OAAAA;EAAK;AAIlB;;;;EAAmHpB,SAAAA,EAAAA,MAAAA;EAA2B4B;EAAkC,KAAA,EA1MrKvB,iBA0MqK;EACpK6B;;;;EAAsG,WAAA,CAAA,EAtMhGvB,MAsMgG,CAAA,MAAA,EAAA,GAAA,CAAA;;;;;;;;;;;;;;;;;iBArL/FF;;;;;WAKNA;;;;cAIGD;;KAEJI,wBAAAA,GAA2BjB,QAAAA,CAAakB;UACnCC,iBAAAA,SAA0BX;;;;YAI7BS;;;;;kBAKWG,WAAAA,SAAoBL;;;;;;UAM5BM,eAAAA,SAAwBN;;;;;;;;;;;;mBAYpBf,QAAAA,CAAasB,IAAAA,CAAKC;;;;;;;;;;;;;;;;;;;;;;;eAuBtBE,MAAMzB,QAAAA,CAAasB,IAAAA,CAAKE;;;;;;UAM7BxB,QAAAA,CAAasB,IAAAA,CAAKI;;;;;;;cAOd1B,QAAAA,CAAa2B;;;;;;;;;;;;iBAYV3B,QAAAA,CAAa4B,SAAAA,CAAUC;;;;;;;;UAQzBC,gBAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAwDgBC;;UAEhBC,oBAAAA,SAA6BX,iBAAiBS;;;;;KAK1DG,kCAAAA,GAAqCC,KAAK9B;eAC9B8B,KAAK9B;;;;;YAKNY,sBAAsBP;;;;;;KAM1B0B,0BAAAA,GAA6BD,KAAKlC,QAAAA,CAAa4B,SAAAA,CAAUQ;;;;;;WAMxDX,MAAMzB,QAAAA,CAAa4B,SAAAA,CAAUQ,qBAAAA,CAAsBC;;;;KAIpDC,wBAAAA,GAA2BpC,qBAAqBC,2BAA2BG,4BAA4BD,2BAA2B4B;KAClIM,2BAAAA,GAA8BrC,qBAAqBC,2BAA2BC"}
|
package/dist/utils/azure.d.cts
CHANGED
|
@@ -34,9 +34,7 @@ interface OpenAIEndpointConfig {
|
|
|
34
34
|
*/
|
|
35
35
|
declare function getEndpoint(config: OpenAIEndpointConfig): string | null | undefined;
|
|
36
36
|
type HeaderValue = string | undefined | null;
|
|
37
|
-
type HeadersLike = Headers | readonly HeaderValue[][] | Record<string, HeaderValue | readonly HeaderValue[]> | undefined | null
|
|
38
|
-
// NullableHeaders
|
|
39
|
-
| {
|
|
37
|
+
type HeadersLike = Headers | readonly HeaderValue[][] | Record<string, HeaderValue | readonly HeaderValue[]> | undefined | null | {
|
|
40
38
|
values: Headers;
|
|
41
39
|
[key: string]: unknown;
|
|
42
40
|
};
|
|
@@ -72,8 +70,6 @@ declare function isHeaders(headers: unknown): headers is Headers;
|
|
|
72
70
|
*/
|
|
73
71
|
declare function normalizeHeaders(headers: HeadersLike): Record<string, HeaderValue | readonly HeaderValue[]>;
|
|
74
72
|
declare function getFormattedEnv(): string;
|
|
75
|
-
// Note: ideally version would be imported from package.json, but there's
|
|
76
|
-
// currently no good way to do that for all supported environments (Node, Deno, Browser).
|
|
77
73
|
declare function getHeadersWithUserAgent(headers: HeadersLike, isAzure?: boolean, version?: string): Record<string, string>;
|
|
78
74
|
//#endregion
|
|
79
75
|
export { HeadersLike, OpenAIEndpointConfig, getEndpoint, getFormattedEnv, getHeadersWithUserAgent, isHeaders, normalizeHeaders };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"azure.d.cts","names":["OpenAIEndpointConfig","Promise","getEndpoint","HeaderValue","HeadersLike","Headers","Record","isHeaders","normalizeHeaders","getFormattedEnv","getHeadersWithUserAgent"],"sources":["../../src/utils/azure.d.ts"],"sourcesContent":["export interface OpenAIEndpointConfig {\n azureOpenAIApiDeploymentName?: string;\n azureOpenAIApiInstanceName?: string;\n azureOpenAIApiKey?: string;\n azureADTokenProvider?: () => Promise<string>;\n azureOpenAIBasePath?: string;\n baseURL?: string | null;\n azureOpenAIEndpoint?: string;\n}\n/**\n * This function generates an endpoint URL for (Azure) OpenAI\n * based on the configuration parameters provided.\n *\n * @param {OpenAIEndpointConfig} config - The configuration object for the (Azure) endpoint.\n *\n * @property {string} config.azureOpenAIApiDeploymentName - The deployment name of Azure OpenAI.\n * @property {string} config.azureOpenAIApiInstanceName - The instance name of Azure OpenAI, e.g. `example-resource`.\n * @property {string} config.azureOpenAIApiKey - The API Key for Azure OpenAI.\n * @property {string} config.azureOpenAIBasePath - The base path for Azure OpenAI, e.g. `https://example-resource.azure.openai.com/openai/deployments/`.\n * @property {string} config.baseURL - Some other custom base path URL.\n * @property {string} config.azureOpenAIEndpoint - The endpoint for the Azure OpenAI instance, e.g. `https://example-resource.azure.openai.com/`.\n *\n * The function operates as follows:\n * - If both `azureOpenAIBasePath` and `azureOpenAIApiDeploymentName` (plus `azureOpenAIApiKey`) are provided, it returns an URL combining these two parameters (`${azureOpenAIBasePath}/${azureOpenAIApiDeploymentName}`).\n * - If both `azureOpenAIEndpoint` and `azureOpenAIApiDeploymentName` (plus `azureOpenAIApiKey`) are provided, it returns an URL combining these two parameters (`${azureOpenAIEndpoint}/openai/deployments/${azureOpenAIApiDeploymentName}`).\n * - If `azureOpenAIApiKey` is provided, it checks for `azureOpenAIApiInstanceName` and `azureOpenAIApiDeploymentName` and throws an error if any of these is missing. If both are provided, it generates an URL incorporating these parameters.\n * - If none of the above conditions are met, return any custom `baseURL`.\n * - The function returns the generated URL as a string, or undefined if no custom paths are specified.\n *\n * @throws Will throw an error if the necessary parameters for generating the URL are missing.\n *\n * @returns {string | undefined} The generated (Azure) OpenAI endpoint URL.\n */\nexport declare function getEndpoint(config: OpenAIEndpointConfig): string | null | undefined;\ntype HeaderValue = string | undefined | null;\nexport type HeadersLike = Headers | readonly HeaderValue[][] | Record<string, HeaderValue | readonly HeaderValue[]> | undefined | null
|
|
1
|
+
{"version":3,"file":"azure.d.cts","names":["OpenAIEndpointConfig","Promise","getEndpoint","HeaderValue","HeadersLike","Headers","Record","isHeaders","normalizeHeaders","getFormattedEnv","getHeadersWithUserAgent"],"sources":["../../src/utils/azure.d.ts"],"sourcesContent":["export interface OpenAIEndpointConfig {\n azureOpenAIApiDeploymentName?: string;\n azureOpenAIApiInstanceName?: string;\n azureOpenAIApiKey?: string;\n azureADTokenProvider?: () => Promise<string>;\n azureOpenAIBasePath?: string;\n baseURL?: string | null;\n azureOpenAIEndpoint?: string;\n}\n/**\n * This function generates an endpoint URL for (Azure) OpenAI\n * based on the configuration parameters provided.\n *\n * @param {OpenAIEndpointConfig} config - The configuration object for the (Azure) endpoint.\n *\n * @property {string} config.azureOpenAIApiDeploymentName - The deployment name of Azure OpenAI.\n * @property {string} config.azureOpenAIApiInstanceName - The instance name of Azure OpenAI, e.g. `example-resource`.\n * @property {string} config.azureOpenAIApiKey - The API Key for Azure OpenAI.\n * @property {string} config.azureOpenAIBasePath - The base path for Azure OpenAI, e.g. `https://example-resource.azure.openai.com/openai/deployments/`.\n * @property {string} config.baseURL - Some other custom base path URL.\n * @property {string} config.azureOpenAIEndpoint - The endpoint for the Azure OpenAI instance, e.g. `https://example-resource.azure.openai.com/`.\n *\n * The function operates as follows:\n * - If both `azureOpenAIBasePath` and `azureOpenAIApiDeploymentName` (plus `azureOpenAIApiKey`) are provided, it returns an URL combining these two parameters (`${azureOpenAIBasePath}/${azureOpenAIApiDeploymentName}`).\n * - If both `azureOpenAIEndpoint` and `azureOpenAIApiDeploymentName` (plus `azureOpenAIApiKey`) are provided, it returns an URL combining these two parameters (`${azureOpenAIEndpoint}/openai/deployments/${azureOpenAIApiDeploymentName}`).\n * - If `azureOpenAIApiKey` is provided, it checks for `azureOpenAIApiInstanceName` and `azureOpenAIApiDeploymentName` and throws an error if any of these is missing. If both are provided, it generates an URL incorporating these parameters.\n * - If none of the above conditions are met, return any custom `baseURL`.\n * - The function returns the generated URL as a string, or undefined if no custom paths are specified.\n *\n * @throws Will throw an error if the necessary parameters for generating the URL are missing.\n *\n * @returns {string | undefined} The generated (Azure) OpenAI endpoint URL.\n */\nexport declare function getEndpoint(config: OpenAIEndpointConfig): string | null | undefined;\ntype HeaderValue = string | undefined | null;\nexport type HeadersLike = Headers | readonly HeaderValue[][] | Record<string, HeaderValue | readonly HeaderValue[]> | undefined | null | {\n values: Headers;\n [key: string]: unknown;\n};\nexport declare function isHeaders(headers: unknown): headers is Headers;\n/**\n * Normalizes various header formats into a consistent Record format.\n *\n * This function accepts headers in multiple formats and converts them to a\n * Record<string, HeaderValue | readonly HeaderValue[]> for consistent handling.\n *\n * @param headers - The headers to normalize. Can be:\n * - A Headers instance\n * - An array of [key, value] pairs\n * - A plain object with string keys\n * - A NullableHeaders-like object with a 'values' property containing Headers\n * - null or undefined\n * @returns A normalized Record containing the header key-value pairs\n *\n * @example\n * ```ts\n * // With Headers instance\n * const headers1 = new Headers([['content-type', 'application/json']]);\n * const normalized1 = normalizeHeaders(headers1);\n *\n * // With plain object\n * const headers2 = { 'content-type': 'application/json' };\n * const normalized2 = normalizeHeaders(headers2);\n *\n * // With array of pairs\n * const headers3 = [['content-type', 'application/json']];\n * const normalized3 = normalizeHeaders(headers3);\n * ```\n */\nexport declare function normalizeHeaders(headers: HeadersLike): Record<string, HeaderValue | readonly HeaderValue[]>;\nexport declare function getFormattedEnv(): string;\nexport declare function getHeadersWithUserAgent(headers: HeadersLike, isAzure?: boolean, version?: string): Record<string, string>;\nexport {};\n//# sourceMappingURL=azure.d.ts.map"],"mappings":";UAAiBA,oBAAAA;EAAAA,4BAAoB,CAAA,EAAA,MAIJC;EA6BTC,0BAAoBF,CAAAA,EAAAA,MAAAA;EACvCG,iBAAW,CAAA,EAAA,MAAA;EACJC,oBAAW,CAAA,EAAA,GAAA,GA/BUH,OA+BV,CAAA,MAAA,CAAA;EAAGI,mBAAAA,CAAAA,EAAAA,MAAAA;EAAmBF,OAAAA,CAAAA,EAAAA,MAAAA,GAAAA,IAAAA;EAAiCA,mBAAAA,CAAAA,EAAAA,MAAAA;;;;AAC3D;AAGnB;AA8BA;;;;;AAAsE;AACtE;AACA;;;;;;;;;;;;;iBAtCwBD,WAAAA,SAAoBF;KACvCG,WAAAA;KACOC,WAAAA,GAAcC,mBAAmBF,kBAAkBG,eAAeH,uBAAuBA;UACzFE;;;iBAGYE,SAAAA,+BAAwCF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8BxCG,gBAAAA,UAA0BJ,cAAcE,eAAeH,uBAAuBA;iBAC9EM,eAAAA,CAAAA;iBACAC,uBAAAA,UAAiCN,mDAAmDE"}
|
package/dist/utils/azure.d.ts
CHANGED
|
@@ -34,9 +34,7 @@ interface OpenAIEndpointConfig {
|
|
|
34
34
|
*/
|
|
35
35
|
declare function getEndpoint(config: OpenAIEndpointConfig): string | null | undefined;
|
|
36
36
|
type HeaderValue = string | undefined | null;
|
|
37
|
-
type HeadersLike = Headers | readonly HeaderValue[][] | Record<string, HeaderValue | readonly HeaderValue[]> | undefined | null
|
|
38
|
-
// NullableHeaders
|
|
39
|
-
| {
|
|
37
|
+
type HeadersLike = Headers | readonly HeaderValue[][] | Record<string, HeaderValue | readonly HeaderValue[]> | undefined | null | {
|
|
40
38
|
values: Headers;
|
|
41
39
|
[key: string]: unknown;
|
|
42
40
|
};
|
|
@@ -72,8 +70,6 @@ declare function isHeaders(headers: unknown): headers is Headers;
|
|
|
72
70
|
*/
|
|
73
71
|
declare function normalizeHeaders(headers: HeadersLike): Record<string, HeaderValue | readonly HeaderValue[]>;
|
|
74
72
|
declare function getFormattedEnv(): string;
|
|
75
|
-
// Note: ideally version would be imported from package.json, but there's
|
|
76
|
-
// currently no good way to do that for all supported environments (Node, Deno, Browser).
|
|
77
73
|
declare function getHeadersWithUserAgent(headers: HeadersLike, isAzure?: boolean, version?: string): Record<string, string>;
|
|
78
74
|
//#endregion
|
|
79
75
|
export { HeadersLike, OpenAIEndpointConfig, getEndpoint, getFormattedEnv, getHeadersWithUserAgent, isHeaders, normalizeHeaders };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"azure.d.ts","names":["OpenAIEndpointConfig","Promise","getEndpoint","HeaderValue","HeadersLike","Headers","Record","isHeaders","normalizeHeaders","getFormattedEnv","getHeadersWithUserAgent"],"sources":["../../src/utils/azure.d.ts"],"sourcesContent":["export interface OpenAIEndpointConfig {\n azureOpenAIApiDeploymentName?: string;\n azureOpenAIApiInstanceName?: string;\n azureOpenAIApiKey?: string;\n azureADTokenProvider?: () => Promise<string>;\n azureOpenAIBasePath?: string;\n baseURL?: string | null;\n azureOpenAIEndpoint?: string;\n}\n/**\n * This function generates an endpoint URL for (Azure) OpenAI\n * based on the configuration parameters provided.\n *\n * @param {OpenAIEndpointConfig} config - The configuration object for the (Azure) endpoint.\n *\n * @property {string} config.azureOpenAIApiDeploymentName - The deployment name of Azure OpenAI.\n * @property {string} config.azureOpenAIApiInstanceName - The instance name of Azure OpenAI, e.g. `example-resource`.\n * @property {string} config.azureOpenAIApiKey - The API Key for Azure OpenAI.\n * @property {string} config.azureOpenAIBasePath - The base path for Azure OpenAI, e.g. `https://example-resource.azure.openai.com/openai/deployments/`.\n * @property {string} config.baseURL - Some other custom base path URL.\n * @property {string} config.azureOpenAIEndpoint - The endpoint for the Azure OpenAI instance, e.g. `https://example-resource.azure.openai.com/`.\n *\n * The function operates as follows:\n * - If both `azureOpenAIBasePath` and `azureOpenAIApiDeploymentName` (plus `azureOpenAIApiKey`) are provided, it returns an URL combining these two parameters (`${azureOpenAIBasePath}/${azureOpenAIApiDeploymentName}`).\n * - If both `azureOpenAIEndpoint` and `azureOpenAIApiDeploymentName` (plus `azureOpenAIApiKey`) are provided, it returns an URL combining these two parameters (`${azureOpenAIEndpoint}/openai/deployments/${azureOpenAIApiDeploymentName}`).\n * - If `azureOpenAIApiKey` is provided, it checks for `azureOpenAIApiInstanceName` and `azureOpenAIApiDeploymentName` and throws an error if any of these is missing. If both are provided, it generates an URL incorporating these parameters.\n * - If none of the above conditions are met, return any custom `baseURL`.\n * - The function returns the generated URL as a string, or undefined if no custom paths are specified.\n *\n * @throws Will throw an error if the necessary parameters for generating the URL are missing.\n *\n * @returns {string | undefined} The generated (Azure) OpenAI endpoint URL.\n */\nexport declare function getEndpoint(config: OpenAIEndpointConfig): string | null | undefined;\ntype HeaderValue = string | undefined | null;\nexport type HeadersLike = Headers | readonly HeaderValue[][] | Record<string, HeaderValue | readonly HeaderValue[]> | undefined | null
|
|
1
|
+
{"version":3,"file":"azure.d.ts","names":["OpenAIEndpointConfig","Promise","getEndpoint","HeaderValue","HeadersLike","Headers","Record","isHeaders","normalizeHeaders","getFormattedEnv","getHeadersWithUserAgent"],"sources":["../../src/utils/azure.d.ts"],"sourcesContent":["export interface OpenAIEndpointConfig {\n azureOpenAIApiDeploymentName?: string;\n azureOpenAIApiInstanceName?: string;\n azureOpenAIApiKey?: string;\n azureADTokenProvider?: () => Promise<string>;\n azureOpenAIBasePath?: string;\n baseURL?: string | null;\n azureOpenAIEndpoint?: string;\n}\n/**\n * This function generates an endpoint URL for (Azure) OpenAI\n * based on the configuration parameters provided.\n *\n * @param {OpenAIEndpointConfig} config - The configuration object for the (Azure) endpoint.\n *\n * @property {string} config.azureOpenAIApiDeploymentName - The deployment name of Azure OpenAI.\n * @property {string} config.azureOpenAIApiInstanceName - The instance name of Azure OpenAI, e.g. `example-resource`.\n * @property {string} config.azureOpenAIApiKey - The API Key for Azure OpenAI.\n * @property {string} config.azureOpenAIBasePath - The base path for Azure OpenAI, e.g. `https://example-resource.azure.openai.com/openai/deployments/`.\n * @property {string} config.baseURL - Some other custom base path URL.\n * @property {string} config.azureOpenAIEndpoint - The endpoint for the Azure OpenAI instance, e.g. `https://example-resource.azure.openai.com/`.\n *\n * The function operates as follows:\n * - If both `azureOpenAIBasePath` and `azureOpenAIApiDeploymentName` (plus `azureOpenAIApiKey`) are provided, it returns an URL combining these two parameters (`${azureOpenAIBasePath}/${azureOpenAIApiDeploymentName}`).\n * - If both `azureOpenAIEndpoint` and `azureOpenAIApiDeploymentName` (plus `azureOpenAIApiKey`) are provided, it returns an URL combining these two parameters (`${azureOpenAIEndpoint}/openai/deployments/${azureOpenAIApiDeploymentName}`).\n * - If `azureOpenAIApiKey` is provided, it checks for `azureOpenAIApiInstanceName` and `azureOpenAIApiDeploymentName` and throws an error if any of these is missing. If both are provided, it generates an URL incorporating these parameters.\n * - If none of the above conditions are met, return any custom `baseURL`.\n * - The function returns the generated URL as a string, or undefined if no custom paths are specified.\n *\n * @throws Will throw an error if the necessary parameters for generating the URL are missing.\n *\n * @returns {string | undefined} The generated (Azure) OpenAI endpoint URL.\n */\nexport declare function getEndpoint(config: OpenAIEndpointConfig): string | null | undefined;\ntype HeaderValue = string | undefined | null;\nexport type HeadersLike = Headers | readonly HeaderValue[][] | Record<string, HeaderValue | readonly HeaderValue[]> | undefined | null | {\n values: Headers;\n [key: string]: unknown;\n};\nexport declare function isHeaders(headers: unknown): headers is Headers;\n/**\n * Normalizes various header formats into a consistent Record format.\n *\n * This function accepts headers in multiple formats and converts them to a\n * Record<string, HeaderValue | readonly HeaderValue[]> for consistent handling.\n *\n * @param headers - The headers to normalize. Can be:\n * - A Headers instance\n * - An array of [key, value] pairs\n * - A plain object with string keys\n * - A NullableHeaders-like object with a 'values' property containing Headers\n * - null or undefined\n * @returns A normalized Record containing the header key-value pairs\n *\n * @example\n * ```ts\n * // With Headers instance\n * const headers1 = new Headers([['content-type', 'application/json']]);\n * const normalized1 = normalizeHeaders(headers1);\n *\n * // With plain object\n * const headers2 = { 'content-type': 'application/json' };\n * const normalized2 = normalizeHeaders(headers2);\n *\n * // With array of pairs\n * const headers3 = [['content-type', 'application/json']];\n * const normalized3 = normalizeHeaders(headers3);\n * ```\n */\nexport declare function normalizeHeaders(headers: HeadersLike): Record<string, HeaderValue | readonly HeaderValue[]>;\nexport declare function getFormattedEnv(): string;\nexport declare function getHeadersWithUserAgent(headers: HeadersLike, isAzure?: boolean, version?: string): Record<string, string>;\nexport {};\n//# sourceMappingURL=azure.d.ts.map"],"mappings":";UAAiBA,oBAAAA;EAAAA,4BAAoB,CAAA,EAAA,MAIJC;EA6BTC,0BAAoBF,CAAAA,EAAAA,MAAAA;EACvCG,iBAAW,CAAA,EAAA,MAAA;EACJC,oBAAW,CAAA,EAAA,GAAA,GA/BUH,OA+BV,CAAA,MAAA,CAAA;EAAGI,mBAAAA,CAAAA,EAAAA,MAAAA;EAAmBF,OAAAA,CAAAA,EAAAA,MAAAA,GAAAA,IAAAA;EAAiCA,mBAAAA,CAAAA,EAAAA,MAAAA;;;;AAC3D;AAGnB;AA8BA;;;;;AAAsE;AACtE;AACA;;;;;;;;;;;;;iBAtCwBD,WAAAA,SAAoBF;KACvCG,WAAAA;KACOC,WAAAA,GAAcC,mBAAmBF,kBAAkBG,eAAeH,uBAAuBA;UACzFE;;;iBAGYE,SAAAA,+BAAwCF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8BxCG,gBAAAA,UAA0BJ,cAAcE,eAAeH,uBAAuBA;iBAC9EM,eAAAA,CAAAA;iBACAC,uBAAAA,UAAiCN,mDAAmDE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.cts","names":["wrapOpenAIClientError"],"sources":["../../src/utils/client.d.ts"],"sourcesContent":["export declare function wrapOpenAIClientError(e: unknown): any;\n"],"mappings":";iBAAwBA,qBAAAA"}
|
|
1
|
+
{"version":3,"file":"client.d.cts","names":["wrapOpenAIClientError"],"sources":["../../src/utils/client.d.ts"],"sourcesContent":["export declare function wrapOpenAIClientError(e: unknown): any;\n//# sourceMappingURL=client.d.ts.map"],"mappings":";iBAAwBA,qBAAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","names":["wrapOpenAIClientError"],"sources":["../../src/utils/client.d.ts"],"sourcesContent":["export declare function wrapOpenAIClientError(e: unknown): any;\n"],"mappings":";iBAAwBA,qBAAAA"}
|
|
1
|
+
{"version":3,"file":"client.d.ts","names":["wrapOpenAIClientError"],"sources":["../../src/utils/client.d.ts"],"sourcesContent":["export declare function wrapOpenAIClientError(e: unknown): any;\n//# sourceMappingURL=client.d.ts.map"],"mappings":";iBAAwBA,qBAAAA"}
|
package/dist/utils/misc.cjs
CHANGED
|
@@ -13,6 +13,11 @@ function extractGenericMessageCustomRole(message) {
|
|
|
13
13
|
if (message.role !== "system" && message.role !== "developer" && message.role !== "assistant" && message.role !== "user" && message.role !== "function" && message.role !== "tool") console.warn(`Unknown message role: ${message.role}`);
|
|
14
14
|
return message.role;
|
|
15
15
|
}
|
|
16
|
+
function getRequiredFilenameFromMetadata(block) {
|
|
17
|
+
const filename = block.metadata?.filename ?? block.metadata?.name ?? block.metadata?.title;
|
|
18
|
+
if (!filename) throw new Error("a filename or name or title is needed via meta-data for OpenAI when working with multimodal blocks");
|
|
19
|
+
return filename;
|
|
20
|
+
}
|
|
16
21
|
function messageToOpenAIRole(message) {
|
|
17
22
|
const type = message._getType();
|
|
18
23
|
switch (type) {
|
|
@@ -29,6 +34,7 @@ function messageToOpenAIRole(message) {
|
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
//#endregion
|
|
37
|
+
exports.getRequiredFilenameFromMetadata = getRequiredFilenameFromMetadata;
|
|
32
38
|
exports.iife = iife;
|
|
33
39
|
exports.isReasoningModel = isReasoningModel;
|
|
34
40
|
exports.messageToOpenAIRole = messageToOpenAIRole;
|
package/dist/utils/misc.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"misc.cjs","names":["fn: () => T","model?: string","message: ChatMessage","message: BaseMessage","ChatMessage"],"sources":["../../src/utils/misc.ts"],"sourcesContent":["import type { OpenAI as OpenAIClient } from \"openai\";\nimport {
|
|
1
|
+
{"version":3,"file":"misc.cjs","names":["fn: () => T","model?: string","message: ChatMessage","block:\n | ContentBlock.Multimodal.File\n | ContentBlock.Multimodal.Video\n | Data.StandardFileBlock","message: BaseMessage","ChatMessage"],"sources":["../../src/utils/misc.ts"],"sourcesContent":["import type { OpenAI as OpenAIClient } from \"openai\";\nimport {\n BaseMessage,\n ChatMessage,\n ContentBlock,\n Data,\n} from \"@langchain/core/messages\";\n\nexport const iife = <T>(fn: () => T) => fn();\n\nexport function isReasoningModel(model?: string) {\n if (!model) return false;\n if (/^o\\d/.test(model ?? \"\")) return true;\n if (model.startsWith(\"gpt-5\") && !model.startsWith(\"gpt-5-chat\")) return true;\n return false;\n}\n\nexport function extractGenericMessageCustomRole(message: ChatMessage) {\n if (\n message.role !== \"system\" &&\n message.role !== \"developer\" &&\n message.role !== \"assistant\" &&\n message.role !== \"user\" &&\n message.role !== \"function\" &&\n message.role !== \"tool\"\n ) {\n console.warn(`Unknown message role: ${message.role}`);\n }\n\n return message.role as OpenAIClient.ChatCompletionRole;\n}\n\nexport function getRequiredFilenameFromMetadata(\n block:\n | ContentBlock.Multimodal.File\n | ContentBlock.Multimodal.Video\n | Data.StandardFileBlock\n): string {\n const filename = (block.metadata?.filename ??\n block.metadata?.name ??\n block.metadata?.title) as string;\n\n if (!filename) {\n throw new Error(\n \"a filename or name or title is needed via meta-data for OpenAI when working with multimodal blocks\"\n );\n }\n\n return filename;\n}\nexport function messageToOpenAIRole(\n message: BaseMessage\n): OpenAIClient.ChatCompletionRole {\n const type = message._getType();\n switch (type) {\n case \"system\":\n return \"system\";\n case \"ai\":\n return \"assistant\";\n case \"human\":\n return \"user\";\n case \"function\":\n return \"function\";\n case \"tool\":\n return \"tool\";\n case \"generic\": {\n if (!ChatMessage.isInstance(message))\n throw new Error(\"Invalid generic chat message\");\n return extractGenericMessageCustomRole(message);\n }\n default:\n throw new Error(`Unknown message type: ${type}`);\n }\n}\n"],"mappings":";;;;AAQA,MAAa,OAAO,CAAIA,OAAgB,IAAI;AAE5C,SAAgB,iBAAiBC,OAAgB;AAC/C,KAAI,CAAC,MAAO,QAAO;AACnB,KAAI,OAAO,KAAK,SAAS,GAAG,CAAE,QAAO;AACrC,KAAI,MAAM,WAAW,QAAQ,IAAI,CAAC,MAAM,WAAW,aAAa,CAAE,QAAO;AACzE,QAAO;AACR;AAED,SAAgB,gCAAgCC,SAAsB;AACpE,KACE,QAAQ,SAAS,YACjB,QAAQ,SAAS,eACjB,QAAQ,SAAS,eACjB,QAAQ,SAAS,UACjB,QAAQ,SAAS,cACjB,QAAQ,SAAS,QAEjB,QAAQ,KAAK,CAAC,sBAAsB,EAAE,QAAQ,MAAM,CAAC;AAGvD,QAAO,QAAQ;AAChB;AAED,SAAgB,gCACdC,OAIQ;CACR,MAAM,WAAY,MAAM,UAAU,YAChC,MAAM,UAAU,QAChB,MAAM,UAAU;AAElB,KAAI,CAAC,SACH,OAAM,IAAI,MACR;AAIJ,QAAO;AACR;AACD,SAAgB,oBACdC,SACiC;CACjC,MAAM,OAAO,QAAQ,UAAU;AAC/B,SAAQ,MAAR;EACE,KAAK,SACH,QAAO;EACT,KAAK,KACH,QAAO;EACT,KAAK,QACH,QAAO;EACT,KAAK,WACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK;AACH,OAAI,CAACC,sCAAY,WAAW,QAAQ,CAClC,OAAM,IAAI,MAAM;AAClB,UAAO,gCAAgC,QAAQ;EAEjD,QACE,OAAM,IAAI,MAAM,CAAC,sBAAsB,EAAE,MAAM;CAClD;AACF"}
|
package/dist/utils/misc.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"misc.d.cts","names":["OpenAI","OpenAIClient","BaseMessage","ChatMessage","iife","T","isReasoningModel","extractGenericMessageCustomRole","ChatCompletionRole","messageToOpenAIRole"],"sources":["../../src/utils/misc.d.ts"],"sourcesContent":["import type { OpenAI as OpenAIClient } from \"openai\";\nimport { BaseMessage, ChatMessage } from \"@langchain/core/messages\";\nexport declare const iife: <T>(fn: () => T) => T;\nexport declare function isReasoningModel(model?: string): boolean;\nexport declare function extractGenericMessageCustomRole(message: ChatMessage): OpenAIClient.ChatCompletionRole;\nexport declare function messageToOpenAIRole(message: BaseMessage): OpenAIClient.ChatCompletionRole;\n"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"misc.d.cts","names":["OpenAI","OpenAIClient","BaseMessage","ChatMessage","ContentBlock","Data","iife","T","isReasoningModel","extractGenericMessageCustomRole","ChatCompletionRole","getRequiredFilenameFromMetadata","Multimodal","File","Video","StandardFileBlock","messageToOpenAIRole"],"sources":["../../src/utils/misc.d.ts"],"sourcesContent":["import type { OpenAI as OpenAIClient } from \"openai\";\nimport { BaseMessage, ChatMessage, ContentBlock, Data } from \"@langchain/core/messages\";\nexport declare const iife: <T>(fn: () => T) => T;\nexport declare function isReasoningModel(model?: string): boolean;\nexport declare function extractGenericMessageCustomRole(message: ChatMessage): OpenAIClient.ChatCompletionRole;\nexport declare function getRequiredFilenameFromMetadata(block: ContentBlock.Multimodal.File | ContentBlock.Multimodal.Video | Data.StandardFileBlock): string;\nexport declare function messageToOpenAIRole(message: BaseMessage): OpenAIClient.ChatCompletionRole;\n//# sourceMappingURL=misc.d.ts.map"],"mappings":";;;;;iBAMwBgB,mBAAAA,UAA6Bd,cAAcD,QAAAA,CAAaS"}
|
package/dist/utils/misc.d.ts
CHANGED
package/dist/utils/misc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"misc.d.ts","names":["OpenAI","OpenAIClient","BaseMessage","ChatMessage","iife","T","isReasoningModel","extractGenericMessageCustomRole","ChatCompletionRole","messageToOpenAIRole"],"sources":["../../src/utils/misc.d.ts"],"sourcesContent":["import type { OpenAI as OpenAIClient } from \"openai\";\nimport { BaseMessage, ChatMessage } from \"@langchain/core/messages\";\nexport declare const iife: <T>(fn: () => T) => T;\nexport declare function isReasoningModel(model?: string): boolean;\nexport declare function extractGenericMessageCustomRole(message: ChatMessage): OpenAIClient.ChatCompletionRole;\nexport declare function messageToOpenAIRole(message: BaseMessage): OpenAIClient.ChatCompletionRole;\n"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"misc.d.ts","names":["OpenAI","OpenAIClient","BaseMessage","ChatMessage","ContentBlock","Data","iife","T","isReasoningModel","extractGenericMessageCustomRole","ChatCompletionRole","getRequiredFilenameFromMetadata","Multimodal","File","Video","StandardFileBlock","messageToOpenAIRole"],"sources":["../../src/utils/misc.d.ts"],"sourcesContent":["import type { OpenAI as OpenAIClient } from \"openai\";\nimport { BaseMessage, ChatMessage, ContentBlock, Data } from \"@langchain/core/messages\";\nexport declare const iife: <T>(fn: () => T) => T;\nexport declare function isReasoningModel(model?: string): boolean;\nexport declare function extractGenericMessageCustomRole(message: ChatMessage): OpenAIClient.ChatCompletionRole;\nexport declare function getRequiredFilenameFromMetadata(block: ContentBlock.Multimodal.File | ContentBlock.Multimodal.Video | Data.StandardFileBlock): string;\nexport declare function messageToOpenAIRole(message: BaseMessage): OpenAIClient.ChatCompletionRole;\n//# sourceMappingURL=misc.d.ts.map"],"mappings":";;;;;iBAMwBgB,mBAAAA,UAA6Bd,cAAcD,QAAAA,CAAaS"}
|
package/dist/utils/misc.js
CHANGED
|
@@ -12,6 +12,11 @@ function extractGenericMessageCustomRole(message) {
|
|
|
12
12
|
if (message.role !== "system" && message.role !== "developer" && message.role !== "assistant" && message.role !== "user" && message.role !== "function" && message.role !== "tool") console.warn(`Unknown message role: ${message.role}`);
|
|
13
13
|
return message.role;
|
|
14
14
|
}
|
|
15
|
+
function getRequiredFilenameFromMetadata(block) {
|
|
16
|
+
const filename = block.metadata?.filename ?? block.metadata?.name ?? block.metadata?.title;
|
|
17
|
+
if (!filename) throw new Error("a filename or name or title is needed via meta-data for OpenAI when working with multimodal blocks");
|
|
18
|
+
return filename;
|
|
19
|
+
}
|
|
15
20
|
function messageToOpenAIRole(message) {
|
|
16
21
|
const type = message._getType();
|
|
17
22
|
switch (type) {
|
|
@@ -28,5 +33,5 @@ function messageToOpenAIRole(message) {
|
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
//#endregion
|
|
31
|
-
export { iife$1 as iife, isReasoningModel, messageToOpenAIRole };
|
|
36
|
+
export { getRequiredFilenameFromMetadata, iife$1 as iife, isReasoningModel, messageToOpenAIRole };
|
|
32
37
|
//# sourceMappingURL=misc.js.map
|
package/dist/utils/misc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"misc.js","names":["iife","fn: () => T","model?: string","message: ChatMessage","message: BaseMessage"],"sources":["../../src/utils/misc.ts"],"sourcesContent":["import type { OpenAI as OpenAIClient } from \"openai\";\nimport {
|
|
1
|
+
{"version":3,"file":"misc.js","names":["iife","fn: () => T","model?: string","message: ChatMessage","block:\n | ContentBlock.Multimodal.File\n | ContentBlock.Multimodal.Video\n | Data.StandardFileBlock","message: BaseMessage"],"sources":["../../src/utils/misc.ts"],"sourcesContent":["import type { OpenAI as OpenAIClient } from \"openai\";\nimport {\n BaseMessage,\n ChatMessage,\n ContentBlock,\n Data,\n} from \"@langchain/core/messages\";\n\nexport const iife = <T>(fn: () => T) => fn();\n\nexport function isReasoningModel(model?: string) {\n if (!model) return false;\n if (/^o\\d/.test(model ?? \"\")) return true;\n if (model.startsWith(\"gpt-5\") && !model.startsWith(\"gpt-5-chat\")) return true;\n return false;\n}\n\nexport function extractGenericMessageCustomRole(message: ChatMessage) {\n if (\n message.role !== \"system\" &&\n message.role !== \"developer\" &&\n message.role !== \"assistant\" &&\n message.role !== \"user\" &&\n message.role !== \"function\" &&\n message.role !== \"tool\"\n ) {\n console.warn(`Unknown message role: ${message.role}`);\n }\n\n return message.role as OpenAIClient.ChatCompletionRole;\n}\n\nexport function getRequiredFilenameFromMetadata(\n block:\n | ContentBlock.Multimodal.File\n | ContentBlock.Multimodal.Video\n | Data.StandardFileBlock\n): string {\n const filename = (block.metadata?.filename ??\n block.metadata?.name ??\n block.metadata?.title) as string;\n\n if (!filename) {\n throw new Error(\n \"a filename or name or title is needed via meta-data for OpenAI when working with multimodal blocks\"\n );\n }\n\n return filename;\n}\nexport function messageToOpenAIRole(\n message: BaseMessage\n): OpenAIClient.ChatCompletionRole {\n const type = message._getType();\n switch (type) {\n case \"system\":\n return \"system\";\n case \"ai\":\n return \"assistant\";\n case \"human\":\n return \"user\";\n case \"function\":\n return \"function\";\n case \"tool\":\n return \"tool\";\n case \"generic\": {\n if (!ChatMessage.isInstance(message))\n throw new Error(\"Invalid generic chat message\");\n return extractGenericMessageCustomRole(message);\n }\n default:\n throw new Error(`Unknown message type: ${type}`);\n }\n}\n"],"mappings":";;;AAQA,MAAaA,SAAO,CAAIC,OAAgB,IAAI;AAE5C,SAAgB,iBAAiBC,OAAgB;AAC/C,KAAI,CAAC,MAAO,QAAO;AACnB,KAAI,OAAO,KAAK,SAAS,GAAG,CAAE,QAAO;AACrC,KAAI,MAAM,WAAW,QAAQ,IAAI,CAAC,MAAM,WAAW,aAAa,CAAE,QAAO;AACzE,QAAO;AACR;AAED,SAAgB,gCAAgCC,SAAsB;AACpE,KACE,QAAQ,SAAS,YACjB,QAAQ,SAAS,eACjB,QAAQ,SAAS,eACjB,QAAQ,SAAS,UACjB,QAAQ,SAAS,cACjB,QAAQ,SAAS,QAEjB,QAAQ,KAAK,CAAC,sBAAsB,EAAE,QAAQ,MAAM,CAAC;AAGvD,QAAO,QAAQ;AAChB;AAED,SAAgB,gCACdC,OAIQ;CACR,MAAM,WAAY,MAAM,UAAU,YAChC,MAAM,UAAU,QAChB,MAAM,UAAU;AAElB,KAAI,CAAC,SACH,OAAM,IAAI,MACR;AAIJ,QAAO;AACR;AACD,SAAgB,oBACdC,SACiC;CACjC,MAAM,OAAO,QAAQ,UAAU;AAC/B,SAAQ,MAAR;EACE,KAAK,SACH,QAAO;EACT,KAAK,KACH,QAAO;EACT,KAAK,QACH,QAAO;EACT,KAAK,WACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK;AACH,OAAI,CAAC,YAAY,WAAW,QAAQ,CAClC,OAAM,IAAI,MAAM;AAClB,UAAO,gCAAgC,QAAQ;EAEjD,QACE,OAAM,IAAI,MAAM,CAAC,sBAAsB,EAAE,MAAM;CAClD;AACF"}
|
package/dist/utils/prompts.d.cts
CHANGED
|
@@ -34,7 +34,6 @@ import { BasePromptValue } from "@langchain/core/prompt_values";
|
|
|
34
34
|
* @param formattedPrompt
|
|
35
35
|
* @returns A partial OpenAI payload.
|
|
36
36
|
*/
|
|
37
|
-
// TODO: make this a converter
|
|
38
37
|
declare function convertPromptToOpenAI(formattedPrompt: BasePromptValue): {
|
|
39
38
|
messages: OpenAI$1.Chat.ChatCompletionMessageParam[];
|
|
40
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.cts","names":["BasePromptValue","OpenAI","convertPromptToOpenAI","Chat","ChatCompletionMessageParam"],"sources":["../../src/utils/prompts.d.ts"],"sourcesContent":["import type { BasePromptValue } from \"@langchain/core/prompt_values\";\nimport type { OpenAI } from \"openai\";\n/**\n * Convert a formatted LangChain prompt (e.g. pulled from the hub) into\n * a format expected by OpenAI's JS SDK.\n *\n * Requires the \"@langchain/openai\" package to be installed in addition\n * to the OpenAI SDK.\n *\n * @example\n * ```ts\n * import { convertPromptToOpenAI } from \"langsmith/utils/hub/openai\";\n * import { pull } from \"langchain/hub\";\n *\n * import OpenAI from 'openai';\n *\n * const prompt = await pull(\"jacob/joke-generator\");\n * const formattedPrompt = await prompt.invoke({\n * topic: \"cats\",\n * });\n *\n * const { messages } = convertPromptToOpenAI(formattedPrompt);\n *\n * const openAIClient = new OpenAI();\n *\n * const openaiResponse = await openAIClient.chat.completions.create({\n * model: \"gpt-4o-mini\",\n * messages,\n * });\n * ```\n * @param formattedPrompt\n * @returns A partial OpenAI payload.\n */\
|
|
1
|
+
{"version":3,"file":"prompts.d.cts","names":["BasePromptValue","OpenAI","convertPromptToOpenAI","Chat","ChatCompletionMessageParam"],"sources":["../../src/utils/prompts.d.ts"],"sourcesContent":["import type { BasePromptValue } from \"@langchain/core/prompt_values\";\nimport type { OpenAI } from \"openai\";\n/**\n * Convert a formatted LangChain prompt (e.g. pulled from the hub) into\n * a format expected by OpenAI's JS SDK.\n *\n * Requires the \"@langchain/openai\" package to be installed in addition\n * to the OpenAI SDK.\n *\n * @example\n * ```ts\n * import { convertPromptToOpenAI } from \"langsmith/utils/hub/openai\";\n * import { pull } from \"langchain/hub\";\n *\n * import OpenAI from 'openai';\n *\n * const prompt = await pull(\"jacob/joke-generator\");\n * const formattedPrompt = await prompt.invoke({\n * topic: \"cats\",\n * });\n *\n * const { messages } = convertPromptToOpenAI(formattedPrompt);\n *\n * const openAIClient = new OpenAI();\n *\n * const openaiResponse = await openAIClient.chat.completions.create({\n * model: \"gpt-4o-mini\",\n * messages,\n * });\n * ```\n * @param formattedPrompt\n * @returns A partial OpenAI payload.\n */\nexport declare function convertPromptToOpenAI(formattedPrompt: BasePromptValue): {\n messages: OpenAI.Chat.ChatCompletionMessageParam[];\n};\n//# sourceMappingURL=prompts.d.ts.map"],"mappings":";;;;;;;AAiCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAwBE,qBAAAA,kBAAuCF;YACjDC,QAAAA,CAAOE,IAAAA,CAAKC"}
|
package/dist/utils/prompts.d.ts
CHANGED
|
@@ -34,7 +34,6 @@ import { BasePromptValue } from "@langchain/core/prompt_values";
|
|
|
34
34
|
* @param formattedPrompt
|
|
35
35
|
* @returns A partial OpenAI payload.
|
|
36
36
|
*/
|
|
37
|
-
// TODO: make this a converter
|
|
38
37
|
declare function convertPromptToOpenAI(formattedPrompt: BasePromptValue): {
|
|
39
38
|
messages: OpenAI$1.Chat.ChatCompletionMessageParam[];
|
|
40
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.ts","names":["BasePromptValue","OpenAI","convertPromptToOpenAI","Chat","ChatCompletionMessageParam"],"sources":["../../src/utils/prompts.d.ts"],"sourcesContent":["import type { BasePromptValue } from \"@langchain/core/prompt_values\";\nimport type { OpenAI } from \"openai\";\n/**\n * Convert a formatted LangChain prompt (e.g. pulled from the hub) into\n * a format expected by OpenAI's JS SDK.\n *\n * Requires the \"@langchain/openai\" package to be installed in addition\n * to the OpenAI SDK.\n *\n * @example\n * ```ts\n * import { convertPromptToOpenAI } from \"langsmith/utils/hub/openai\";\n * import { pull } from \"langchain/hub\";\n *\n * import OpenAI from 'openai';\n *\n * const prompt = await pull(\"jacob/joke-generator\");\n * const formattedPrompt = await prompt.invoke({\n * topic: \"cats\",\n * });\n *\n * const { messages } = convertPromptToOpenAI(formattedPrompt);\n *\n * const openAIClient = new OpenAI();\n *\n * const openaiResponse = await openAIClient.chat.completions.create({\n * model: \"gpt-4o-mini\",\n * messages,\n * });\n * ```\n * @param formattedPrompt\n * @returns A partial OpenAI payload.\n */\
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","names":["BasePromptValue","OpenAI","convertPromptToOpenAI","Chat","ChatCompletionMessageParam"],"sources":["../../src/utils/prompts.d.ts"],"sourcesContent":["import type { BasePromptValue } from \"@langchain/core/prompt_values\";\nimport type { OpenAI } from \"openai\";\n/**\n * Convert a formatted LangChain prompt (e.g. pulled from the hub) into\n * a format expected by OpenAI's JS SDK.\n *\n * Requires the \"@langchain/openai\" package to be installed in addition\n * to the OpenAI SDK.\n *\n * @example\n * ```ts\n * import { convertPromptToOpenAI } from \"langsmith/utils/hub/openai\";\n * import { pull } from \"langchain/hub\";\n *\n * import OpenAI from 'openai';\n *\n * const prompt = await pull(\"jacob/joke-generator\");\n * const formattedPrompt = await prompt.invoke({\n * topic: \"cats\",\n * });\n *\n * const { messages } = convertPromptToOpenAI(formattedPrompt);\n *\n * const openAIClient = new OpenAI();\n *\n * const openaiResponse = await openAIClient.chat.completions.create({\n * model: \"gpt-4o-mini\",\n * messages,\n * });\n * ```\n * @param formattedPrompt\n * @returns A partial OpenAI payload.\n */\nexport declare function convertPromptToOpenAI(formattedPrompt: BasePromptValue): {\n messages: OpenAI.Chat.ChatCompletionMessageParam[];\n};\n//# sourceMappingURL=prompts.d.ts.map"],"mappings":";;;;;;;AAiCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAwBE,qBAAAA,kBAAuCF;YACjDC,QAAAA,CAAOE,IAAAA,CAAKC"}
|
package/dist/utils/tools.cjs
CHANGED
|
@@ -87,6 +87,14 @@ function formatToOpenAIToolChoice(toolChoice) {
|
|
|
87
87
|
function isBuiltInTool(tool) {
|
|
88
88
|
return "type" in tool && tool.type !== "function";
|
|
89
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Checks if a tool has a provider-specific tool definition in extras.providerToolDefinition.
|
|
92
|
+
* This is used for tools like localShell, shell, computerUse, and applyPatch
|
|
93
|
+
* that need to be sent as built-in tool types to the OpenAI API.
|
|
94
|
+
*/
|
|
95
|
+
function hasProviderToolDefinition(tool) {
|
|
96
|
+
return typeof tool === "object" && tool !== null && "extras" in tool && typeof tool.extras === "object" && tool.extras !== null && "providerToolDefinition" in tool.extras && typeof tool.extras.providerToolDefinition === "object" && tool.extras.providerToolDefinition !== null;
|
|
97
|
+
}
|
|
90
98
|
function isBuiltInToolChoice(tool_choice) {
|
|
91
99
|
return tool_choice != null && typeof tool_choice === "object" && "type" in tool_choice && tool_choice.type !== "function";
|
|
92
100
|
}
|
|
@@ -108,8 +116,35 @@ function parseCustomToolCall(rawToolCall) {
|
|
|
108
116
|
args: { input: rawToolCall.input }
|
|
109
117
|
};
|
|
110
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Parses a computer_call output item from the OpenAI Responses API
|
|
121
|
+
* into a ToolCall format that can be processed by the ToolNode.
|
|
122
|
+
*
|
|
123
|
+
* @param rawToolCall - The raw computer_call output item from the API
|
|
124
|
+
* @returns A ComputerToolCall object if valid, undefined otherwise
|
|
125
|
+
*/
|
|
126
|
+
function parseComputerCall(rawToolCall) {
|
|
127
|
+
if (rawToolCall.type !== "computer_call") return void 0;
|
|
128
|
+
return {
|
|
129
|
+
...rawToolCall,
|
|
130
|
+
type: "tool_call",
|
|
131
|
+
call_id: rawToolCall.id,
|
|
132
|
+
id: rawToolCall.call_id,
|
|
133
|
+
name: "computer_use",
|
|
134
|
+
isComputerTool: true,
|
|
135
|
+
args: { action: rawToolCall.action }
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Checks if a tool call is a computer tool call.
|
|
140
|
+
* @param toolCall - The tool call to check.
|
|
141
|
+
* @returns True if the tool call is a computer tool call, false otherwise.
|
|
142
|
+
*/
|
|
143
|
+
function isComputerToolCall(toolCall) {
|
|
144
|
+
return typeof toolCall === "object" && toolCall !== null && "type" in toolCall && toolCall.type === "tool_call" && "isComputerTool" in toolCall && toolCall.isComputerTool === true;
|
|
145
|
+
}
|
|
111
146
|
function isCustomToolCall(toolCall) {
|
|
112
|
-
return toolCall.type === "tool_call" && "isCustomTool" in toolCall && toolCall.isCustomTool === true;
|
|
147
|
+
return typeof toolCall === "object" && toolCall !== null && "type" in toolCall && toolCall.type === "tool_call" && "isCustomTool" in toolCall && toolCall.isCustomTool === true;
|
|
113
148
|
}
|
|
114
149
|
function convertCompletionsCustomTool(tool) {
|
|
115
150
|
const getFormat = () => {
|
|
@@ -158,10 +193,13 @@ exports.convertCompletionsCustomTool = convertCompletionsCustomTool;
|
|
|
158
193
|
exports.convertResponsesCustomTool = convertResponsesCustomTool;
|
|
159
194
|
exports.formatFunctionDefinitions = formatFunctionDefinitions;
|
|
160
195
|
exports.formatToOpenAIToolChoice = formatToOpenAIToolChoice;
|
|
196
|
+
exports.hasProviderToolDefinition = hasProviderToolDefinition;
|
|
161
197
|
exports.isBuiltInTool = isBuiltInTool;
|
|
162
198
|
exports.isBuiltInToolChoice = isBuiltInToolChoice;
|
|
199
|
+
exports.isComputerToolCall = isComputerToolCall;
|
|
163
200
|
exports.isCustomTool = isCustomTool;
|
|
164
201
|
exports.isCustomToolCall = isCustomToolCall;
|
|
165
202
|
exports.isOpenAICustomTool = isOpenAICustomTool;
|
|
203
|
+
exports.parseComputerCall = parseComputerCall;
|
|
166
204
|
exports.parseCustomToolCall = parseCustomToolCall;
|
|
167
205
|
//# sourceMappingURL=tools.cjs.map
|