UNPKG

@langchain/openai

Version:
1 lines 4.99 kB
{"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"}