| 60 | |
| 61 | export class QwenApi implements LLMApi { |
| 62 | path(path: string): string { |
| 63 | const accessStore = useAccessStore.getState(); |
| 64 | |
| 65 | let baseUrl = ""; |
| 66 | |
| 67 | if (accessStore.useCustomConfig) { |
| 68 | baseUrl = accessStore.alibabaUrl; |
| 69 | } |
| 70 | |
| 71 | if (baseUrl.length === 0) { |
| 72 | const isApp = !!getClientConfig()?.isApp; |
| 73 | baseUrl = isApp ? ALIBABA_BASE_URL : ApiPath.Alibaba; |
| 74 | } |
| 75 | |
| 76 | if (baseUrl.endsWith("/")) { |
| 77 | baseUrl = baseUrl.slice(0, baseUrl.length - 1); |
| 78 | } |
| 79 | if (!baseUrl.startsWith("http") && !baseUrl.startsWith(ApiPath.Alibaba)) { |
| 80 | baseUrl = "https://" + baseUrl; |
| 81 | } |
| 82 | |
| 83 | console.log("[Proxy Endpoint] ", baseUrl, path); |
| 84 | |
| 85 | return [baseUrl, path].join("/"); |
| 86 | } |
| 87 | |
| 88 | extractMessage(res: any) { |
| 89 | return res?.output?.choices?.at(0)?.message?.content ?? ""; |