Spaces:
Runtime error
Runtime error
Download src/lib/updateSettings.ts from BetterAPI/BetterChat: direct link, hf CLI and curl.
- Browser
- Download file 749 Bytes
-
https://huggingface.co/spaces/BetterAPI/BetterChat/resolve/2dc7d8d3e6f756f3fcf4e68582f84d7e7efab73c/src/lib/updateSettings.ts
- Command line
-
hf download hf://spaces/BetterAPI/BetterChat@2dc7d8d3e6f756f3fcf4e68582f84d7e7efab73c/src/lib/updateSettings.ts
-
curl -L -o updateSettings.ts https://huggingface.co/spaces/BetterAPI/BetterChat/resolve/2dc7d8d3e6f756f3fcf4e68582f84d7e7efab73c/src/lib/updateSettings.ts
749 Bytes
| import { invalidate } from "$app/navigation"; | |
| import { base } from "$app/paths"; | |
| import { error } from "$lib/stores/errors"; | |
| import type { Settings } from "./types/Settings"; | |
| import { UrlDependency } from "./types/UrlDependency"; | |
| export async function updateSettings( | |
| settings: Partial<Omit<Settings, "sessionId">> | |
| ): Promise<boolean> { | |
| try { | |
| const res = await fetch(`${base}/settings`, { | |
| method: "PATCH", | |
| headers: { "Content-Type": "application/json" }, | |
| body: JSON.stringify(settings), | |
| }); | |
| if (!res.ok) { | |
| error.set("Error while updating settings, try again."); | |
| return false; | |
| } | |
| await invalidate(UrlDependency.Settings); | |
| return true; | |
| } catch (err) { | |
| console.error(err); | |
| error.set(String(err)); | |
| return false; | |
| } | |
| } | |