| 26 | private disableListModels = true; |
| 27 | |
| 28 | path(path: string): string { |
| 29 | const accessStore = useAccessStore.getState(); |
| 30 | |
| 31 | let baseUrl = ""; |
| 32 | |
| 33 | if (accessStore.useCustomConfig) { |
| 34 | baseUrl = accessStore.xaiUrl; |
| 35 | } |
| 36 | |
| 37 | if (baseUrl.length === 0) { |
| 38 | const isApp = !!getClientConfig()?.isApp; |
| 39 | const apiPath = ApiPath.XAI; |
| 40 | baseUrl = isApp ? XAI_BASE_URL : apiPath; |
| 41 | } |
| 42 | |
| 43 | if (baseUrl.endsWith("/")) { |
| 44 | baseUrl = baseUrl.slice(0, baseUrl.length - 1); |
| 45 | } |
| 46 | if (!baseUrl.startsWith("http") && !baseUrl.startsWith(ApiPath.XAI)) { |
| 47 | baseUrl = "https://" + baseUrl; |
| 48 | } |
| 49 | |
| 50 | console.log("[Proxy Endpoint] ", baseUrl, path); |
| 51 | |
| 52 | return [baseUrl, path].join("/"); |
| 53 | } |
| 54 | |
| 55 | extractMessage(res: any) { |
| 56 | return res.choices?.at(0)?.message?.content ?? ""; |