(path: string)
| 83 | private disableListModels = true; |
| 84 | |
| 85 | path(path: string): string { |
| 86 | const accessStore = useAccessStore.getState(); |
| 87 | |
| 88 | let baseUrl = ""; |
| 89 | |
| 90 | const isAzure = path.includes("deployments"); |
| 91 | if (accessStore.useCustomConfig) { |
| 92 | if (isAzure && !accessStore.isValidAzure()) { |
| 93 | throw Error( |
| 94 | "incomplete azure config, please check it in your settings page", |
| 95 | ); |
| 96 | } |
| 97 | |
| 98 | baseUrl = isAzure ? accessStore.azureUrl : accessStore.openaiUrl; |
| 99 | } |
| 100 | |
| 101 | if (baseUrl.length === 0) { |
| 102 | const isApp = !!getClientConfig()?.isApp; |
| 103 | const apiPath = isAzure ? ApiPath.Azure : ApiPath.OpenAI; |
| 104 | baseUrl = isApp ? OPENAI_BASE_URL : apiPath; |
| 105 | } |
| 106 | |
| 107 | if (baseUrl.endsWith("/")) { |
| 108 | baseUrl = baseUrl.slice(0, baseUrl.length - 1); |
| 109 | } |
| 110 | if ( |
| 111 | !baseUrl.startsWith("http") && |
| 112 | !isAzure && |
| 113 | !baseUrl.startsWith(ApiPath.OpenAI) |
| 114 | ) { |
| 115 | baseUrl = "https://" + baseUrl; |
| 116 | } |
| 117 | |
| 118 | console.log("[Proxy Endpoint] ", baseUrl, path); |
| 119 | |
| 120 | // try rebuild url, when using cloudflare ai gateway in client |
| 121 | return cloudflareAIGatewayUrl([baseUrl, path].join("/")); |
| 122 | } |
| 123 | |
| 124 | async extractMessage(res: any) { |
| 125 | if (res.error) { |
no test coverage detected