- Express backend with Replicate API proxy (chat, models, account, search) - React + Vite + Tailwind frontend with custom Midnight Violet color scheme - @mention autocomplete to route messages to specific models - Parallel multi-model queries with model selection in sidebar - DuckDuckGo web search context injection - Model manager UI (add/edit/remove Replicate models) - Per-model system instructions per conversation - Replicate account info display in sidebar - Conversation history with local persistence (Zustand) - Full Docker deployment (backend + nginx-served frontend) - Montserrat + Poppins fonts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
import express from 'express';
|
|
|
|
const router = express.Router();
|
|
const REPLICATE_BASE = 'https://api.replicate.com/v1';
|
|
|
|
router.get('/', async (req, res) => {
|
|
const token = process.env.REPLICATE_API_TOKEN;
|
|
if (!token) return res.status(400).json({ error: 'REPLICATE_API_TOKEN not configured' });
|
|
|
|
try {
|
|
const response = await fetch(`${REPLICATE_BASE}/account`, {
|
|
headers: { 'Authorization': `Bearer ${token}` }
|
|
});
|
|
if (!response.ok) {
|
|
const err = await response.json().catch(() => ({}));
|
|
return res.status(response.status).json({ error: err.detail || 'Failed to fetch account' });
|
|
}
|
|
const account = await response.json();
|
|
|
|
// Try to get hardware/usage info
|
|
let hardware = null;
|
|
try {
|
|
const hwRes = await fetch(`${REPLICATE_BASE}/hardware`, {
|
|
headers: { 'Authorization': `Bearer ${token}` }
|
|
});
|
|
if (hwRes.ok) hardware = await hwRes.json();
|
|
} catch (_) {}
|
|
|
|
res.json({ account, hardware });
|
|
} catch (err) {
|
|
res.status(500).json({ error: err.message });
|
|
}
|
|
});
|
|
|
|
export { router as accountRouter };
|