Spaces:
Running
Running
Sync from felladrin/MiniSearch@ad583e0 (part 2)
Browse filesFiles changed (5)
44 unmodified lines4546474849505144 unmodified linesmaxBackoffMs: 5000,requestTimeoutMs: 30000,maxConcurrentRequests: 10,defaultMaxTokens: 2048,temperature: 0.7,topP: 0.9,});44 unmodified lines4546474849505144 unmodified linesmaxBackoffMs: 5000,requestTimeoutMs: 30000,maxConcurrentRequests: 10,defaultMaxTokens: 8192,temperature: 0.7,topP: 0.9,});
14 unmodified lines1516171819202114 unmodified linesmaxBackoffMs: 5000,requestTimeoutMs: 30000,maxConcurrentRequests: 10,defaultMaxTokens: 2048,temperature: 0.7,topP: 0.9,};14 unmodified lines1516171819202114 unmodified linesmaxBackoffMs: 5000,requestTimeoutMs: 30000,maxConcurrentRequests: 10,defaultMaxTokens: 8192,temperature: 0.7,topP: 0.9,};
27 unmodified lines28293031323335 unmodified lines6970717227 unmodified linesreturn JSON.parse(end.mock.calls[0][0] as string) as {accessKeysEnabled: boolean;parentWindowOrigins: string[];};}35 unmodified linesvi.stubEnv("PARENT_WINDOW_ORIGINS", "");expect((await requestConfig()).parentWindowOrigins).toEqual([]);});});27 unmodified lines2829303132333435 unmodified lines707172737475767778798081828384858687888990919293949527 unmodified linesreturn JSON.parse(end.mock.calls[0][0] as string) as {accessKeysEnabled: boolean;parentWindowOrigins: string[];internalApiContextLength: number;};}35 unmodified linesvi.stubEnv("PARENT_WINDOW_ORIGINS", "");expect((await requestConfig()).parentWindowOrigins).toEqual([]);});it("serves the configured internal API context length", async () => {vi.stubEnv("INTERNAL_OPENAI_COMPATIBLE_API_CONTEXT_LENGTH", "32768");expect((await requestConfig()).internalApiContextLength).toBe(32768);});it("serves a 128K internal API context length when the variable is unset", async () => {vi.stubEnv("INTERNAL_OPENAI_COMPATIBLE_API_CONTEXT_LENGTH", undefined);expect((await requestConfig()).internalApiContextLength).toBe(131072);});it("logs an internal API context length that is not a positive integer and serves 128K", async () => {const consoleError = vi.spyOn(console, "error").mockImplementation(() => {});vi.stubEnv("INTERNAL_OPENAI_COMPATIBLE_API_CONTEXT_LENGTH", "128k");expect((await requestConfig()).internalApiContextLength).toBe(131072);expect(consoleError).toHaveBeenCalledWith(expect.stringContaining('("128k")'),);consoleError.mockRestore();});});
1234563 unmodified lines10111213141522 unmodified lines383940414243import type { PreviewServer, ViteDevServer } from "vite";import {DEFAULT_INFERENCE_TYPE,DEFAULT_INTERNAL_API_NAME,DEFAULT_PARENT_WINDOW_ORIGINS,DEFAULT_WLLAMA_GPU_MODEL_ID,3 unmodified linesimport { parseCommaSeparatedList } from "./parseCommaSeparatedList.ts";import { getSearchToken } from "./searchToken.ts";/*** Serves the server config at /api/config at runtime rather than compiling it* in, so the published Docker image is configurable via environment variables.22 unmodified linesinternalApiName:process.env.INTERNAL_OPENAI_COMPATIBLE_API_NAME ||DEFAULT_INTERNAL_API_NAME,defaultInferenceType:process.env.DEFAULT_INFERENCE_TYPE || DEFAULT_INFERENCE_TYPE,// Served here rather than compiled into the bundle so a client always12345673 unmodified lines1112131415161718192021222324252627282922 unmodified lines52535455565758import type { PreviewServer, ViteDevServer } from "vite";import {DEFAULT_INFERENCE_TYPE,DEFAULT_INTERNAL_API_CONTEXT_LENGTH,DEFAULT_INTERNAL_API_NAME,DEFAULT_PARENT_WINDOW_ORIGINS,DEFAULT_WLLAMA_GPU_MODEL_ID,3 unmodified linesimport { parseCommaSeparatedList } from "./parseCommaSeparatedList.ts";import { getSearchToken } from "./searchToken.ts";function getInternalApiContextLength(): number {const value = process.env.INTERNAL_OPENAI_COMPATIBLE_API_CONTEXT_LENGTH;if (!value) return DEFAULT_INTERNAL_API_CONTEXT_LENGTH;const contextLength = Number(value);if (Number.isInteger(contextLength) && contextLength > 0) {return contextLength;}console.error(`INTERNAL_OPENAI_COMPATIBLE_API_CONTEXT_LENGTH is not a positive integer ("${value}"); using ${DEFAULT_INTERNAL_API_CONTEXT_LENGTH}.`,);return DEFAULT_INTERNAL_API_CONTEXT_LENGTH;}/*** Serves the server config at /api/config at runtime rather than compiling it* in, so the published Docker image is configurable via environment variables.22 unmodified linesinternalApiName:process.env.INTERNAL_OPENAI_COMPATIBLE_API_NAME ||DEFAULT_INTERNAL_API_NAME,internalApiContextLength: getInternalApiContextLength(),defaultInferenceType:process.env.DEFAULT_INFERENCE_TYPE || DEFAULT_INFERENCE_TYPE,// Served here rather than compiled into the bundle so a client always
6 unmodified lines78910111214 unmodified lines272829306 unmodified lineswllamaDefaultGpuModelId: string;internalApiEnabled: boolean;internalApiName: string;defaultInferenceType: string;/** The CSRF token to hash into the `?token=` of every request to this server. */searchToken: string;14 unmodified linesexport const DEFAULT_WLLAMA_GPU_MODEL_ID = "gemma-3-4b";export const DEFAULT_INFERENCE_TYPE = "browser";export const DEFAULT_INTERNAL_API_NAME = "Internal API";export const DEFAULT_PARENT_WINDOW_ORIGINS = ["https://huggingface.co"];6 unmodified lines789101112131414 unmodified lines29303132336 unmodified lineswllamaDefaultGpuModelId: string;internalApiEnabled: boolean;internalApiName: string;/** Context window, in tokens, of the internal API's models; the answer's token budgets are sized from it. */internalApiContextLength: number;defaultInferenceType: string;/** The CSRF token to hash into the `?token=` of every request to this server. */searchToken: string;14 unmodified linesexport const DEFAULT_WLLAMA_GPU_MODEL_ID = "gemma-3-4b";export const DEFAULT_INFERENCE_TYPE = "browser";export const DEFAULT_INTERNAL_API_NAME = "Internal API";export const DEFAULT_INTERNAL_API_CONTEXT_LENGTH = 131072;export const DEFAULT_PARENT_WINDOW_ORIGINS = ["https://huggingface.co"];
server/config/modelConfig.test.ts+1-1
server/config/modelConfig.ts+1-1
server/configEndpointServerHook.test.ts+23
server/configEndpointServerHook.ts+15
shared/serverConfig.ts+3