Download web/src/api.js from kphani007/Aegis: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/spaces/kphani007/Aegis/resolve/main/web/src/api.js
- Command line
-
hf download hf://spaces/kphani007/Aegis/web/src/api.js
-
curl -L -o api.js https://huggingface.co/spaces/kphani007/Aegis/resolve/main/web/src/api.js
1.03 kB
| const BASE = '/api' | |
| async function request(path, options) { | |
| const response = await fetch(`${BASE}${path}`, { | |
| headers: { 'Content-Type': 'application/json' }, | |
| ...options, | |
| }) | |
| if (!response.ok) { | |
| const body = await response.json().catch(() => ({})) | |
| throw new Error(body.detail || `Request failed: ${response.status}`) | |
| } | |
| return response.json() | |
| } | |
| export function getCategories() { | |
| return request('/categories') | |
| } | |
| export function listConversations() { | |
| return request('/conversations') | |
| } | |
| export function createConversation(title) { | |
| return request('/conversations', { | |
| method: 'POST', | |
| body: JSON.stringify({ title: title || null }), | |
| }) | |
| } | |
| export function getConversation(id) { | |
| return request(`/conversations/${id}`) | |
| } | |
| export function deleteConversation(id) { | |
| return request(`/conversations/${id}`, { method: 'DELETE' }) | |
| } | |
| export function sendMessage(id, message) { | |
| return request(`/conversations/${id}/messages`, { | |
| method: 'POST', | |
| body: JSON.stringify({ message }), | |
| }) | |
| } | |