Spaces:
Runtime error
Runtime error
Download src/lib/shareConversation.ts from BetterAPI/BetterChat: direct link, hf CLI and curl.
- Browser
- Download file 672 Bytes
-
https://huggingface.co/spaces/BetterAPI/BetterChat/resolve/2dc7d8d3e6f756f3fcf4e68582f84d7e7efab73c/src/lib/shareConversation.ts
- Command line
-
hf download hf://spaces/BetterAPI/BetterChat@2dc7d8d3e6f756f3fcf4e68582f84d7e7efab73c/src/lib/shareConversation.ts
-
curl -L -o shareConversation.ts https://huggingface.co/spaces/BetterAPI/BetterChat/resolve/2dc7d8d3e6f756f3fcf4e68582f84d7e7efab73c/src/lib/shareConversation.ts
672 Bytes
| import { base } from "$app/paths"; | |
| import { ERROR_MESSAGES, error } from "$lib/stores/errors"; | |
| import { share } from "./utils/share"; | |
| export async function shareConversation(id: string, title: string) { | |
| try { | |
| const res = await fetch(`${base}/conversation/${id}/share`, { | |
| method: "POST", | |
| headers: { | |
| "Content-Type": "application/json", | |
| }, | |
| }); | |
| if (!res.ok) { | |
| error.set("Error while sharing conversation, try again."); | |
| console.error("Error while sharing conversation: " + (await res.text())); | |
| return; | |
| } | |
| const { url } = await res.json(); | |
| share(url, title); | |
| } catch (err) { | |
| error.set(ERROR_MESSAGES.default); | |
| console.error(err); | |
| } | |
| } | |