diff --git a/package.json b/package.json index 4049a568..3054d823 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.0.1", "private": true, "scripts": { - "dev": "pnpm run update-ctx-length && vite dev", + "dev": "vite dev", "build": "pnpm run update-ctx-length && vite build", "preview": "vite preview", "prepare": "ts-patch install && svelte-kit sync || echo ''", @@ -12,9 +12,8 @@ "lint": "prettier . --check . && eslint src/", "format": "prettier . --write .", "clean": "rm -rf ./node_modules/ && rm -rf ./.svelte-kit/ && ni && echo 'Project cleaned!'", - "update-ctx-length": "jiti scripts/update-ctx-length.ts", - "test:unit": "vitest", - "test": "npm run test:unit -- --run && npm run test:e2e", + "test:unit": "vitest --browser.headless", + "test": "npm run test:unit", "test:e2e": "playwright test" }, "devDependencies": { diff --git a/scripts/update-ctx-length.ts b/scripts/update-ctx-length.ts deleted file mode 100644 index 7f5e8841..00000000 --- a/scripts/update-ctx-length.ts +++ /dev/null @@ -1,55 +0,0 @@ -import dotenv from "dotenv"; -dotenv.config(); // Load .env file into process.env - -import { fetchAllProviderData, type ApiKeys } from "../src/lib/server/providers/index.js"; // Import ApiKeys type -import fs from "fs/promises"; -import path from "path"; - -const CACHE_FILE_PATH = path.resolve("src/lib/data/context_length.json"); - -async function runUpdate() { - console.log("Starting context length cache update..."); - - // Gather API keys from process.env - const apiKeys: ApiKeys = { - COHERE_API_KEY: process.env.COHERE_API_KEY, - TOGETHER_API_KEY: process.env.TOGETHER_API_KEY, - FIREWORKS_API_KEY: process.env.FIREWORKS_API_KEY, - HYPERBOLIC_API_KEY: process.env.HYPERBOLIC_API_KEY, - REPLICATE_API_KEY: process.env.REPLICATE_API_KEY, - NEBIUS_API_KEY: process.env.NEBIUS_API_KEY, - NOVITA_API_KEY: process.env.NOVITA_API_KEY, - SAMBANOVA_API_KEY: process.env.SAMBANOVA_API_KEY, - }; - - try { - // Fetch data from all supported providers concurrently, passing keys - const fetchedData = await fetchAllProviderData(apiKeys); - - // Read existing manual/cached data - let existingData = {}; - try { - const currentCache = await fs.readFile(CACHE_FILE_PATH, "utf-8"); - existingData = JSON.parse(currentCache); - } catch { - // Remove unused variable name - console.log("No existing cache file found or error reading, creating new one."); - } - - // Merge fetched data with existing data (fetched data takes precedence) - const combinedData = { ...existingData, ...fetchedData }; - - // Write the combined data back to the file - const tempFilePath = CACHE_FILE_PATH + ".tmp"; - await fs.writeFile(tempFilePath, JSON.stringify(combinedData, null, "\t"), "utf-8"); - await fs.rename(tempFilePath, CACHE_FILE_PATH); - - console.log("Context length cache update complete."); - console.log(`Cache file written to: ${CACHE_FILE_PATH}`); - } catch (error) { - console.error("Error during context length cache update:", error); - process.exit(1); // Exit with error code - } -} - -runUpdate(); diff --git a/src/lib/components/inference-playground/playground.svelte b/src/lib/components/inference-playground/playground.svelte index 68b96fc5..7655dee3 100644 --- a/src/lib/components/inference-playground/playground.svelte +++ b/src/lib/components/inference-playground/playground.svelte @@ -28,6 +28,7 @@ import BillingIndicator from "../billing-indicator.svelte"; import { TEST_IDS } from "$lib/constants.js"; import MessageTextarea from "./message-textarea.svelte"; + import { atLeastNDecimals } from "$lib/utils/number.js"; let viewCode = $state(false); let viewSettings = $state(false); @@ -155,7 +156,7 @@