diff --git a/app/lib/.server/llm/api-key.ts b/app/lib/.server/llm/api-key.ts index e7aaf59d1..e2764c1dc 100644 --- a/app/lib/.server/llm/api-key.ts +++ b/app/lib/.server/llm/api-key.ts @@ -35,7 +35,7 @@ export function getBaseURL(cloudflareEnv: Env, provider: string) { case 'OpenAILike': return env.OPENAI_LIKE_API_BASE_URL || cloudflareEnv.OPENAI_LIKE_API_BASE_URL; case 'Ollama': - return env.OLLAMA_API_BASE_URL || cloudflareEnv.OLLAMA_API_BASE_URL; + return env.OLLAMA_API_BASE_URL || cloudflareEnv.OLLAMA_API_BASE_URL || "http://localhost:11434"; default: return ""; } diff --git a/app/utils/constants.ts b/app/utils/constants.ts index cb638ba32..10642bdde 100644 --- a/app/utils/constants.ts +++ b/app/utils/constants.ts @@ -50,8 +50,7 @@ export let MODEL_LIST: ModelInfo[] = [...staticModels]; async function getOllamaModels(): Promise { try { const base_url = import.meta.env.OLLAMA_API_BASE_URL || "http://localhost:11434"; - const url = new URL(base_url).toString(); - const response = await fetch(`${url}/api/tags`); + const response = await fetch(`${base_url}/api/tags`); const data = await response.json() as OllamaApiResponse; return data.models.map((model: OllamaModel) => ({ @@ -65,20 +64,18 @@ async function getOllamaModels(): Promise { } async function getOpenAILikeModels(): Promise { - try { const base_url =import.meta.env.OPENAI_LIKE_API_BASE_URL || ""; if (!base_url) { return []; } - const url = new URL(base_url).toString(); const api_key = import.meta.env.OPENAI_LIKE_API_KEY ?? ""; - const response = await fetch(`${url}/models`, { + const response = await fetch(`${base_url}/models`, { headers: { Authorization: `Bearer ${api_key}`, } }); - const res = await response.json(); + const res = await response.json() as any; return res.data.map((model: any) => ({ name: model.id, label: model.id, @@ -92,8 +89,7 @@ async function getOpenAILikeModels(): Promise { async function initializeModelList(): Promise { const ollamaModels = await getOllamaModels(); const openAiLikeModels = await getOpenAILikeModels(); - console.log(openAiLikeModels); MODEL_LIST = [...ollamaModels,...openAiLikeModels, ...staticModels]; } initializeModelList().then(); -export { getOllamaModels, initializeModelList }; +export { getOllamaModels, getOpenAILikeModels, initializeModelList }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f3a842460..f56c5ca78 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -228,6 +228,9 @@ importers: prettier: specifier: ^3.3.2 version: 3.3.2 + sass-embedded: + specifier: ^1.80.3 + version: 1.80.4 typescript: specifier: ^5.5.2 version: 5.5.2 @@ -562,6 +565,9 @@ packages: resolution: {integrity: sha512-mGEAFWCI5AQ4nrePhjp2WzvRen+UWR+SF4MvH70icIBClR08Gm3dT9MRa2jszOpfY00NyIYfm7/1CFZ37GvW4g==} engines: {node: ^18.0.0 || ^20.0.0} + '@bufbuild/protobuf@2.2.0': + resolution: {integrity: sha512-+imAQkHf7U/Rwvu0wk1XWgsP3WnpCWmK7B48f0XqSNzgk64+grljTKC7pnO/xBiEMUziF7vKRfbBnOQhg126qQ==} + '@cloudflare/kv-asset-handler@0.1.3': resolution: {integrity: sha512-FNcunDuTmEfQTLRLtA6zz+buIXUHj1soPvSWzzQFBC+n2lsy+CGf/NIrR3SEPCmsVNQj70/Jx2lViCpq+09YpQ==} @@ -2352,6 +2358,9 @@ packages: engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true + buffer-builder@0.2.0: + resolution: {integrity: sha512-7VPMEPuYznPSoR21NE1zvd2Xna6c/CloiZCfcMXR1Jny6PjX0N4Nsa38zcBFo/FMK+BlA+FLKbJCQ0i2yxp+Xg==} + buffer-from@1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} @@ -2489,6 +2498,9 @@ packages: colorette@2.0.20: resolution: {integrity: sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==} + colorjs.io@0.5.2: + resolution: {integrity: sha512-twmVoizEW7ylZSN32OgKdXRmo1qg+wT5/6C3xu5b9QsWzSFAhHLn2xd8ro0diCsKfCj1RdaTP/nrcW+vAoQPIw==} + comma-separated-tokens@2.0.3: resolution: {integrity: sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==} @@ -4655,6 +4667,9 @@ packages: run-parallel@1.2.0: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} + rxjs@7.8.1: + resolution: {integrity: sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==} + sade@1.8.1: resolution: {integrity: sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==} engines: {node: '>=6'} @@ -4668,6 +4683,131 @@ packages: safer-buffer@2.1.2: resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} + sass-embedded-android-arm64@1.80.4: + resolution: {integrity: sha512-htAuBmRvvN2d4smrqxZ6WBw4+OOURaoHzq5oZKqS/E35zYl5FHmrJzp4S5e26a0tEBcjca014tfb/uu9cQgnqA==} + engines: {node: '>=14.0.0'} + cpu: [arm64] + os: [android] + + sass-embedded-android-arm@1.80.4: + resolution: {integrity: sha512-iAZ7AiKTLGxQGTkZ37c2/7YC4lkbP1o3eP/K74YaF8O+qhKTLyLOwV7OcmzIywac7dqLcNuGqhFCmFqTYpewZw==} + engines: {node: '>=14.0.0'} + cpu: [arm] + os: [android] + + sass-embedded-android-ia32@1.80.4: + resolution: {integrity: sha512-IIee89Jco8/ad2s/oRJTFqpLhBMzg0UXteJyZ5waZPZmkeSR/t9l67Ef1lLQVh9t9/fJ1ViTTiGYm/g/zu6UGw==} + engines: {node: '>=14.0.0'} + cpu: [ia32] + os: [android] + + sass-embedded-android-riscv64@1.80.4: + resolution: {integrity: sha512-iJM2kqmWrOeE1aUyTp3uMAG86hyAqbpbOEV7tv828fUsMRDM4uHsHtmyp2n8P2Y0Y2FnLzJpvIm3SwDXGDzT1Q==} + engines: {node: '>=14.0.0'} + cpu: [riscv64] + os: [android] + + sass-embedded-android-x64@1.80.4: + resolution: {integrity: sha512-vd8VrLvUoHeTcsDoIJesXLbQYZH26a8lAzXy6u4+vEuAwikF4WiXBDFrpqiv38QeD3faLeoPtksRsFbAdQqJAA==} + engines: {node: '>=14.0.0'} + cpu: [x64] + os: [android] + + sass-embedded-darwin-arm64@1.80.4: + resolution: {integrity: sha512-SJz7EM1i4NXa7CT/njIWMNYJ6CvbHljDIzUAZEe3V3u1KWl/eNO3pbWAnnDN62tBppwgWx/UdDUbAKowsT6Z8w==} + engines: {node: '>=14.0.0'} + cpu: [arm64] + os: [darwin] + + sass-embedded-darwin-x64@1.80.4: + resolution: {integrity: sha512-J/QlBVO66DLtgALgCmM8rZ5zG0dBCIYW1eXIAnnDwC7vGkbAXMtO60M0O/2WNrAfmFfJz1hvKDLjlsxB2XGBLg==} + engines: {node: '>=14.0.0'} + cpu: [x64] + os: [darwin] + + sass-embedded-linux-arm64@1.80.4: + resolution: {integrity: sha512-hI6zQyrR6qJbvyEHfj8UGXNB8VyUa72jel46406AuxUnViA0RyZDSqXUF8vwVw/Hjv1LkA5ihK9dBmWNbLz1zQ==} + engines: {node: '>=14.0.0'} + cpu: [arm64] + os: [linux] + + sass-embedded-linux-arm@1.80.4: + resolution: {integrity: sha512-vuaWhc4ebnaY1AgIWNvFv1snxmkWfvlCU7vnQf4qkn3R2Yyd2J+sjkO8o0NgMX8n5XRUSkAaYUJFCH+Nim6KgQ==} + engines: {node: '>=14.0.0'} + cpu: [arm] + os: [linux] + + sass-embedded-linux-ia32@1.80.4: + resolution: {integrity: sha512-wcPExI8UbYrrJvGvo4v2Q+RktbCp44i3qZQ18hglPcVZOC1IzT9NPqZn0XmrqD4hmNbgsYR+picODkvqGw7iDA==} + engines: {node: '>=14.0.0'} + cpu: [ia32] + os: [linux] + + sass-embedded-linux-musl-arm64@1.80.4: + resolution: {integrity: sha512-y8slzQ8Jjkl+53mUDkp3zxcDrTXVVxzpa+6nKh5Ue8l1YU2KdVZG1v2PoDXxE6o99B5I2TVBG8i02IsdYoL8jQ==} + engines: {node: '>=14.0.0'} + cpu: [arm64] + os: [linux] + + sass-embedded-linux-musl-arm@1.80.4: + resolution: {integrity: sha512-HWo0G/9tuhj/uSEwte9KiDK2Xezrfh7nhdEH69ZIfOAqP5byTXL7o08TYagbvMAoljR43Vfna6MelV7NUX4WCw==} + engines: {node: '>=14.0.0'} + cpu: [arm] + os: [linux] + + sass-embedded-linux-musl-ia32@1.80.4: + resolution: {integrity: sha512-A2WSwnomho491iCeHh3c0YRympfAoJOKr+IyxalTcRH/pjENOWZWZUt00WE2q0tTpEd2V+goWvgS5pmUGewgmg==} + engines: {node: '>=14.0.0'} + cpu: [ia32] + os: [linux] + + sass-embedded-linux-musl-riscv64@1.80.4: + resolution: {integrity: sha512-tYQsAHZLr2mnlJQBJ8Z/n/ySIFJ9JWpsUsoLe9fYgGDaBUfItdzUnj15CChRWld8vFe/I84hb7fbCtYXrI60Jg==} + engines: {node: '>=14.0.0'} + cpu: [riscv64] + os: [linux] + + sass-embedded-linux-musl-x64@1.80.4: + resolution: {integrity: sha512-NZnr+SYbWlmXx0IaSQ8oF0jYkOULp9qKWMmmZQ1mxuGQ3z7tJqFhpH3M+hYkrFNeOq+GaH+nhHGOD4ZNBxeRkg==} + engines: {node: '>=14.0.0'} + cpu: [x64] + os: [linux] + + sass-embedded-linux-riscv64@1.80.4: + resolution: {integrity: sha512-h/BmU7QONa7ScvQztFp4Th4aSo3X+Olu3I+RYsaH9s7P683WT3f2w5zr+wwP1V4roM5eyKDCRJBuefT3Fkkkgw==} + engines: {node: '>=14.0.0'} + cpu: [riscv64] + os: [linux] + + sass-embedded-linux-x64@1.80.4: + resolution: {integrity: sha512-aZbZFs/X9bEmzDiBEiV4IAsKEA0zrCM+s/u2OzvrX4GRvZFJ+/XRTTvf+RTm7mgvTFgfPwCkNGVECQZ1eHh+6A==} + engines: {node: '>=14.0.0'} + cpu: [x64] + os: [linux] + + sass-embedded-win32-arm64@1.80.4: + resolution: {integrity: sha512-8JiatFi2VVFqCdJzKNDteaPC4KPmh8/giaVh7TyMcDhKjnvRLeu3v5V1egTMiwwpnQHuwzU3uqBlm/llVNR2Pw==} + engines: {node: '>=14.0.0'} + cpu: [arm64] + os: [win32] + + sass-embedded-win32-ia32@1.80.4: + resolution: {integrity: sha512-SodmTD6mjxEgoq44jWMibmBQvWkCfENK/70zp4qsztcBSOggg3nYUzwG0YpraClAMXpB1xOvzrArWu9/9fguAg==} + engines: {node: '>=14.0.0'} + cpu: [ia32] + os: [win32] + + sass-embedded-win32-x64@1.80.4: + resolution: {integrity: sha512-7+oRRwCCcnOmw152qDiC7x7SphYBo1eLB4KdyThO+7+rYRO8AftXO+kqBPTVSkM8kGp4wxCMF9auPpYBZbjsow==} + engines: {node: '>=14.0.0'} + cpu: [x64] + os: [win32] + + sass-embedded@1.80.4: + resolution: {integrity: sha512-lPzKX5g79ZxohlPxh0pXTPFseWj9RfgYI0cPm14CH5ok77Ujuheq/DCp7RStvNDWS8RCQ8Ii6gJC/5WTkGyrhA==} + engines: {node: '>=16.0.0'} + hasBin: true + sass@1.77.6: resolution: {integrity: sha512-ByXE1oLD79GVq9Ht1PeHWCPMPB8XHpBuz1r85oByKHjZY6qV6rWnQovQzXJXuQ/XyE1Oj3iPk3lo28uzaRA2/Q==} engines: {node: '>=14.0.0'} @@ -4895,6 +5035,10 @@ packages: resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} engines: {node: '>=8'} + supports-color@8.1.1: + resolution: {integrity: sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==} + engines: {node: '>=10'} + supports-preserve-symlinks-flag@1.0.0: resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} engines: {node: '>= 0.4'} @@ -5202,6 +5346,9 @@ packages: resolution: {integrity: sha512-OljLrQ9SQdOUqTaQxqL5dEfZWrXExyyWsozYlAWFawPVNuD83igl7uJD2RTkNMbniIYgt8l81eCJGIdQF7avLQ==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + varint@6.0.0: + resolution: {integrity: sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg==} + vary@1.1.2: resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==} engines: {node: '>= 0.8'} @@ -5829,6 +5976,8 @@ snapshots: - supports-color - typescript + '@bufbuild/protobuf@2.2.0': {} + '@cloudflare/kv-asset-handler@0.1.3': dependencies: mime: 2.6.0 @@ -7796,6 +7945,8 @@ snapshots: node-releases: 2.0.14 update-browserslist-db: 1.0.16(browserslist@4.23.1) + buffer-builder@0.2.0: {} + buffer-from@1.1.2: {} buffer-xor@1.0.3: {} @@ -7940,6 +8091,8 @@ snapshots: colorette@2.0.20: {} + colorjs.io@0.5.2: {} + comma-separated-tokens@2.0.3: {} common-tags@1.8.2: {} @@ -8932,8 +9085,7 @@ snapshots: immediate@3.0.6: {} - immutable@4.3.7: - optional: true + immutable@4.3.7: {} import-fresh@3.3.0: dependencies: @@ -10727,6 +10879,10 @@ snapshots: dependencies: queue-microtask: 1.2.3 + rxjs@7.8.1: + dependencies: + tslib: 2.6.3 + sade@1.8.1: dependencies: mri: 1.2.0 @@ -10737,6 +10893,97 @@ snapshots: safer-buffer@2.1.2: {} + sass-embedded-android-arm64@1.80.4: + optional: true + + sass-embedded-android-arm@1.80.4: + optional: true + + sass-embedded-android-ia32@1.80.4: + optional: true + + sass-embedded-android-riscv64@1.80.4: + optional: true + + sass-embedded-android-x64@1.80.4: + optional: true + + sass-embedded-darwin-arm64@1.80.4: + optional: true + + sass-embedded-darwin-x64@1.80.4: + optional: true + + sass-embedded-linux-arm64@1.80.4: + optional: true + + sass-embedded-linux-arm@1.80.4: + optional: true + + sass-embedded-linux-ia32@1.80.4: + optional: true + + sass-embedded-linux-musl-arm64@1.80.4: + optional: true + + sass-embedded-linux-musl-arm@1.80.4: + optional: true + + sass-embedded-linux-musl-ia32@1.80.4: + optional: true + + sass-embedded-linux-musl-riscv64@1.80.4: + optional: true + + sass-embedded-linux-musl-x64@1.80.4: + optional: true + + sass-embedded-linux-riscv64@1.80.4: + optional: true + + sass-embedded-linux-x64@1.80.4: + optional: true + + sass-embedded-win32-arm64@1.80.4: + optional: true + + sass-embedded-win32-ia32@1.80.4: + optional: true + + sass-embedded-win32-x64@1.80.4: + optional: true + + sass-embedded@1.80.4: + dependencies: + '@bufbuild/protobuf': 2.2.0 + buffer-builder: 0.2.0 + colorjs.io: 0.5.2 + immutable: 4.3.7 + rxjs: 7.8.1 + supports-color: 8.1.1 + varint: 6.0.0 + optionalDependencies: + sass-embedded-android-arm: 1.80.4 + sass-embedded-android-arm64: 1.80.4 + sass-embedded-android-ia32: 1.80.4 + sass-embedded-android-riscv64: 1.80.4 + sass-embedded-android-x64: 1.80.4 + sass-embedded-darwin-arm64: 1.80.4 + sass-embedded-darwin-x64: 1.80.4 + sass-embedded-linux-arm: 1.80.4 + sass-embedded-linux-arm64: 1.80.4 + sass-embedded-linux-ia32: 1.80.4 + sass-embedded-linux-musl-arm: 1.80.4 + sass-embedded-linux-musl-arm64: 1.80.4 + sass-embedded-linux-musl-ia32: 1.80.4 + sass-embedded-linux-musl-riscv64: 1.80.4 + sass-embedded-linux-musl-x64: 1.80.4 + sass-embedded-linux-riscv64: 1.80.4 + sass-embedded-linux-x64: 1.80.4 + sass-embedded-win32-arm64: 1.80.4 + sass-embedded-win32-ia32: 1.80.4 + sass-embedded-win32-x64: 1.80.4 + sass@1.77.6: dependencies: chokidar: 3.6.0 @@ -10996,6 +11243,10 @@ snapshots: dependencies: has-flag: 4.0.0 + supports-color@8.1.1: + dependencies: + has-flag: 4.0.0 + supports-preserve-symlinks-flag@1.0.0: {} svelte@4.2.18: @@ -11354,6 +11605,8 @@ snapshots: validate-npm-package-name@5.0.1: {} + varint@6.0.0: {} + vary@1.1.2: {} version-range@4.14.0: {}