omnigate-ai 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/package.json +1 -1
- package/public/app.js +34 -0
- package/public/index.html +8 -3
- package/server.js +6 -0
package/README.md
CHANGED
|
@@ -41,6 +41,30 @@ To route your AI coding assistant through OmniGate AI:
|
|
|
41
41
|
|
|
42
42
|
Now, start coding! OmniGate AI will silently intercept the requests, inject your real API key, forward it to the provider, and track your tokens on the dashboard.
|
|
43
43
|
|
|
44
|
+
## 🤖 Routing Your Custom AI Apps (Python & Node.js)
|
|
45
|
+
|
|
46
|
+
Are you building your own AI apps? You can easily route them through OmniGate AI to track their token usage too! Just change the base URL in your official OpenAI SDK to point to your local proxy.
|
|
47
|
+
|
|
48
|
+
**Python Example:**
|
|
49
|
+
```python
|
|
50
|
+
from openai import OpenAI
|
|
51
|
+
|
|
52
|
+
client = OpenAI(
|
|
53
|
+
base_url="http://localhost:8080/v1", # Point to your proxy
|
|
54
|
+
api_key="your-gateway-secret-key" # Use your local secret
|
|
55
|
+
)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Node.js Example:**
|
|
59
|
+
```javascript
|
|
60
|
+
import OpenAI from 'openai';
|
|
61
|
+
|
|
62
|
+
const openai = new OpenAI({
|
|
63
|
+
baseURL: "http://localhost:8080/v1", // Point to your proxy
|
|
64
|
+
apiKey: "your-gateway-secret-key" // Use your local secret
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
44
68
|
## ✨ Features
|
|
45
69
|
|
|
46
70
|
- **🔒 100% Local Privacy:** Your real API keys are saved locally. Cloud-based AI tools never see them.
|
package/package.json
CHANGED
package/public/app.js
CHANGED
|
@@ -151,6 +151,40 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
151
151
|
console.error("Stream parse error:", err);
|
|
152
152
|
}
|
|
153
153
|
};
|
|
154
|
+
|
|
155
|
+
evtSource.addEventListener('clear_telemetry', () => {
|
|
156
|
+
// Reset state
|
|
157
|
+
totalTokens = 0;
|
|
158
|
+
totalInputTokens = 0;
|
|
159
|
+
totalOutputTokens = 0;
|
|
160
|
+
totalCost = 0.0;
|
|
161
|
+
totalRequests = 0;
|
|
162
|
+
requestTimestamps.length = 0;
|
|
163
|
+
|
|
164
|
+
// Clear DOM
|
|
165
|
+
tbody.innerHTML = '';
|
|
166
|
+
elTotalTokens.textContent = '0';
|
|
167
|
+
elInputTokens.textContent = '0';
|
|
168
|
+
elOutputTokens.textContent = '0';
|
|
169
|
+
elTotalCost.textContent = '$0.000';
|
|
170
|
+
elAvgCost.textContent = '$0.000';
|
|
171
|
+
elTotalRequests.textContent = '0';
|
|
172
|
+
|
|
173
|
+
updateGauges();
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// ==========================================
|
|
178
|
+
// Reset Data Button
|
|
179
|
+
// ==========================================
|
|
180
|
+
const btnResetData = document.getElementById('btn-reset-data');
|
|
181
|
+
if (btnResetData) {
|
|
182
|
+
btnResetData.addEventListener('click', () => {
|
|
183
|
+
if (confirm('Are you sure you want to clear all telemetry history?')) {
|
|
184
|
+
fetch('/api/telemetry', { method: 'DELETE' })
|
|
185
|
+
.catch(err => console.error('Failed to clear telemetry:', err));
|
|
186
|
+
}
|
|
187
|
+
});
|
|
154
188
|
}
|
|
155
189
|
|
|
156
190
|
// ==========================================
|
package/public/index.html
CHANGED
|
@@ -27,9 +27,14 @@
|
|
|
27
27
|
<span style="font-size:0.7rem;color:var(--text-dim);font-weight:400;display:block;margin-top:0.1rem;">Privacy-First API Gateway · Token Cost Tracker</span>
|
|
28
28
|
</div>
|
|
29
29
|
</div>
|
|
30
|
-
<div class="
|
|
31
|
-
<
|
|
32
|
-
|
|
30
|
+
<div class="header-actions" style="display: flex; gap: 1rem; align-items: center;">
|
|
31
|
+
<button id="btn-reset-data" class="btn-secondary" style="padding: 0.4rem 0.8rem; font-size: 0.8rem; border-color: rgba(255,8,68,0.5); color: #ffb199; background: rgba(255,8,68,0.1); border-radius: 50px;">
|
|
32
|
+
⟲ Reset Data
|
|
33
|
+
</button>
|
|
34
|
+
<div class="status-indicator">
|
|
35
|
+
<span class="pulse-dot"></span>
|
|
36
|
+
<span>Gateway Connected</span>
|
|
37
|
+
</div>
|
|
33
38
|
</div>
|
|
34
39
|
</header>
|
|
35
40
|
|
package/server.js
CHANGED
|
@@ -84,6 +84,12 @@ app.get('/api/telemetry', (req, res) => {
|
|
|
84
84
|
res.json(telemetryHistory);
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
+
app.delete('/api/telemetry', (req, res) => {
|
|
88
|
+
telemetryHistory.length = 0;
|
|
89
|
+
telemetryEmitter.emit('clear_telemetry', { status: 'cleared' });
|
|
90
|
+
res.json({ status: 'success', message: 'Telemetry history cleared' });
|
|
91
|
+
});
|
|
92
|
+
|
|
87
93
|
app.get('/api/telemetry/stream', (req, res) => {
|
|
88
94
|
res.setHeader('Content-Type', 'text/event-stream');
|
|
89
95
|
res.setHeader('Cache-Control', 'no-cache');
|