Spaces:
Runtime error
Runtime error
Download frontend/src/api/chat.js from cuiconnect/backend: direct link, hf CLI and curl.
- Browser
- Download file 1.22 kB
-
https://huggingface.co/spaces/cuiconnect/backend/resolve/main/frontend/src/api/chat.js
- Command line
-
hf download hf://spaces/cuiconnect/backend/frontend/src/api/chat.js
-
curl -L -o chat.js https://huggingface.co/spaces/cuiconnect/backend/resolve/main/frontend/src/api/chat.js
1.22 kB
| import { apiJson } from './http' | |
| export function listChats({ skip = 0, limit = 30 } = {}) { | |
| const q = new URLSearchParams({ | |
| skip: String(skip), | |
| limit: String(limit), | |
| }) | |
| return apiJson(`/list_chats?${q}`, { auth: true }) | |
| } | |
| export function createChat() { | |
| return apiJson('/get_new_chat', { method: 'POST', auth: true }) | |
| } | |
| /** Latest page: omit beforeIndex. Older: pass next_before_index from prior response. */ | |
| export function fetchChatPage(chatId, { beforeIndex = null, limit = 20 } = {}) { | |
| const q = new URLSearchParams({ limit: String(limit) }) | |
| if (beforeIndex != null) q.set('before_index', String(beforeIndex)) | |
| return apiJson(`/get_chat/${encodeURIComponent(chatId)}?${q}`, { auth: true }) | |
| } | |
| export function removeChat(chatId) { | |
| return apiJson(`/delete_chat/${encodeURIComponent(chatId)}`, { | |
| method: 'DELETE', | |
| auth: true, | |
| }) | |
| } | |
| export function sendMessage( | |
| chatId, | |
| question, | |
| { | |
| allowAugmentation = true, | |
| useWebSearch = false, | |
| } = {}, | |
| ) { | |
| return apiJson('/response', { | |
| method: 'POST', | |
| body: JSON.stringify({ | |
| chat_id: chatId, | |
| question, | |
| allow_augmentation: allowAugmentation, | |
| use_web_search: useWebSearch, | |
| }), | |
| auth: true, | |
| }) | |
| } | |