Update logic and UI for MiniMax and POE specific formats

This commit is contained in:
Jannik committed 2026-08-28 15:25:28 +02:00
1 parent b3fd63b594
commit 0a2368e3e7
5 files changed
+48 -12

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
PORT=3000
# Database Configuration
DB_USER=postgres
DB_HOST=postgres
DB_NAME=tokenwatch
DB_PASSWORD=your_db_password
DB_PORT=5432
# ntfy Configuration
NTFY_URL=https://ntfy.orfel.de/Token-Watch
ALERT_THRESHOLD_PERCENT=80
# Provider API Keys
ANTIGRAVITY_API_KEY=your_antigravity_key
ANTIGRAVITY_ENDPOINT=https://api.antigravity.google/v1/quota
POE_API_KEY=sk-poe-4V66fvDHHGp8nx4ig2Mz5608HdTY0hk-AN-DiAV2axY
MINIMAX_API_KEY=sk-api-y831YokKIsrn8f8oo19ilogA1kzZJAEfKrRslw8wowvOfevxAAj7t8TZWH3G4rin4DxUIMfQRejs5y7jAnEB2i3r1zBp0z4aPU6w_kD8MEZqWYDlcHsHB9o
+10 -2
View File
@@ -37,8 +37,6 @@ function updateCard(providerId, quota) {
// Set color gradient position based on percentage
fill.style.backgroundPosition = `${100 - percentage}% 0`;
statusText.innerText = `${percentage.toFixed(1)}% Used (${quota.used} / ${quota.total})`;
// Meme reactions based on percentage
if (percentage > 90) {
meme.style.transform = 'scale(1.2) rotate(5deg)';
@@ -47,6 +45,16 @@ function updateCard(providerId, quota) {
statusText.style.color = 'var(--success)';
}
if (quota.provider.toLowerCase() === 'minimax' && quota.meta) {
const reset5h = new Date(quota.meta.intervalReset).toLocaleTimeString();
const resetWeekly = new Date(quota.meta.weeklyReset).toLocaleDateString();
statusText.innerHTML = `5h Limit: ${quota.meta.intervalUsed}% (Resets: ${reset5h})<br>Weekly: ${quota.meta.weeklyUsed}% (Resets: ${resetWeekly})`;
} else if (quota.provider.toLowerCase() === 'poe') {
statusText.innerText = `${percentage.toFixed(1)}% Used (${(quota.used).toLocaleString()} / ${(quota.total).toLocaleString()})`;
} else {
statusText.innerText = `${percentage.toFixed(1)}% Used (${quota.used} / ${quota.total})`;
}
if (percentage >= 100) {
confetti({
particleCount: 100,
+3 -2
View File
@@ -1,6 +1,7 @@
import express from 'express';
import path from 'path';
import { getLatestQuotas, getQuotaHistory } from './services/db';
import { getQuotaHistory } from './services/db';
import { fetchAllQuotas } from './services/providers';
import './cron'; // Start the cron jobs
const app = express();
@@ -11,7 +12,7 @@ app.use(express.json());
app.get('/api/quotas', async (req, res) => {
try {
const quotas = await getLatestQuotas();
const quotas = await fetchAllQuotas();
res.json(quotas);
} catch (error) {
console.error('Error fetching quotas:', error);
+1
View File
@@ -18,6 +18,7 @@ export interface QuotaEntry {
total: number;
percentage: number;
timestamp?: Date;
meta?: any;
}
export async function initDb() {
+16 -8
View File
@@ -28,24 +28,21 @@ export async function fetchAntigravityQuota(): Promise<QuotaEntry> {
export async function fetchPoeQuota(): Promise<QuotaEntry> {
try {
// According to docs, returns available point balance
const res = await axios.get('https://api.poe.com/usage/current_balance', {
headers: {
'Authorization': `Bearer ${process.env.POE_API_KEY}`
}
});
// POE logic: 75000 daily points is standard. We might need to adjust based on actual API payload.
// Assuming response has: { available: number }
const available = res.data.current_point_balance || 0;
const total = 2575000;
const total = 2500000;
const used = total - available > 0 ? total - available : 0;
const percentage = (used / total) * 100;
return { provider: 'POE', used, total, percentage };
} catch (error: any) {
console.error('Error fetching POE quota:', error.message);
return { provider: 'POE', used: 0, total: 75000, percentage: 0 };
return { provider: 'POE', used: 0, total: 2500000, percentage: 0 };
}
}
@@ -58,11 +55,22 @@ export async function fetchMinimaxQuota(): Promise<QuotaEntry> {
});
const remains = res.data.model_remains?.find((r: any) => r.model_name === 'general');
const total = 100;
const percentage = remains ? (100 - remains.current_weekly_remaining_percent) : 0;
const intervalUsed = remains ? (100 - remains.current_interval_remaining_percent) : 0;
const weeklyUsed = remains ? (100 - remains.current_weekly_remaining_percent) : 0;
// Use the highest percentage for the progress bar logic
const percentage = Math.max(intervalUsed, weeklyUsed);
const used = percentage;
const total = 100;
const meta = {
intervalUsed,
weeklyUsed,
intervalReset: remains ? remains.end_time : null,
weeklyReset: remains ? remains.weekly_end_time : null
};
return { provider: 'MiniMax', used, total, percentage };
return { provider: 'MiniMax', used, total, percentage, meta };
} catch (error: any) {
console.error('Error fetching MiniMax quota:', error.message);
return { provider: 'MiniMax', used: 0, total: 100, percentage: 0 };