import{O as f,a as n,r as u,i as p,b as m}from"./client-uV4QZMxS.js";import{d as N,e as O,c as R,A as T,f as U,g as S,B as x,C as D,I as K,j as V,N as q,P as C,h as L,R as Z,U as j,t as k}from"./client-uV4QZMxS.js";import"./PrefsViewStore-B9QxYjkz.js";import"./index-F0fMEJXd.js";import"./index-CZYymlJf.js";import"./sentry-common-2nFGZClv.js";import"./main-process-state-jW3BbbTQ.js";import"./index-jPDAJ20a.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};r.SENTRY_RELEASE={id:"4.2.860"}}catch{}})();try{(function(){var r=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new r.Error().stack;e&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[e]="bd019c7d-8ad5-4654-9d75-4072ac9521b1",r._sentryDebugIdIdentifier="sentry-dbid-bd019c7d-8ad5-4654-9d75-4072ac9521b1")})()}catch{}var E={};class g extends f{constructor({baseURL:e=u("OPENAI_BASE_URL"),apiKey:i=u("AZURE_OPENAI_API_KEY"),apiVersion:t=u("OPENAI_API_VERSION"),endpoint:a,deployment:l,azureADTokenProvider:o,dangerouslyAllowBrowser:s,...d}={}){if(!t)throw new n("The OPENAI_API_VERSION environment variable is missing or empty; either provide it, or instantiate the AzureOpenAI client with an apiVersion option, like new AzureOpenAI({ apiVersion: 'My API Version' }).");if(typeof o=="function"&&(s=!0),!o&&!i)throw new n("Missing credentials. Please pass one of `apiKey` and `azureADTokenProvider`, or set the `AZURE_OPENAI_API_KEY` environment variable.");if(o&&i)throw new n("The `apiKey` and `azureADTokenProvider` arguments are mutually exclusive; only one can be passed at a time.");if(d.defaultQuery={...d.defaultQuery,"api-version":t},e){if(a)throw new n("baseURL and endpoint are mutually exclusive")}else{if(a||(a=E.AZURE_OPENAI_ENDPOINT),!a)throw new n("Must provide one of the `baseURL` or `endpoint` arguments, or the `AZURE_OPENAI_ENDPOINT` environment variable");e=`${a}/openai`}super({apiKey:o??i,baseURL:e,...d,...s!==void 0?{dangerouslyAllowBrowser:s}:{}}),this.apiVersion="",this.apiVersion=t,this.deploymentName=l}async buildRequest(e,i={}){if(c.has(e.path)&&e.method==="post"&&e.body!==void 0){if(!p(e.body))throw new Error("Expected request body to be an object");const t=this.deploymentName||e.body.model||e.__metadata?.model;t!==void 0&&!this.baseURL.includes("/deployments")&&(e.path=`/deployments/${t}${e.path}`)}return super.buildRequest(e,i)}async authHeaders(e){return typeof this._options.apiKey=="string"?m([{"api-key":this.apiKey}]):super.authHeaders(e)}}const c=new Set(["/completions","/chat/completions","/embeddings","/audio/transcriptions","/audio/translations","/audio/speech","/images/generations","/batches","/images/edits"]);export{N as APIConnectionError,O as APIConnectionTimeoutError,R as APIError,T as APIPromise,U as APIUserAbortError,S as AuthenticationError,g as AzureOpenAI,x as BadRequestError,D as ConflictError,K as InternalServerError,V as InvalidWebhookSignatureError,q as NotFoundError,f as OpenAI,n as OpenAIError,C as PagePromise,L as PermissionDeniedError,Z as RateLimitError,j as UnprocessableEntityError,f as default,k as toFile};
//# sourceMappingURL=index-Cf_chfcV.js.map
