no gemini
This commit is contained in:
@@ -7,8 +7,10 @@ import (
|
||||
"log/slog"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"g.fc.run/ai/byre/internal/antigravity"
|
||||
"g.fc.run/ai/byre/internal/api"
|
||||
)
|
||||
|
||||
type agySteps struct {
|
||||
@@ -151,6 +153,7 @@ func (m *Manager) agyTurnEnded(ctx context.Context, l *live, p antigravityProces
|
||||
m.mu.Lock()
|
||||
final := l.lastText
|
||||
m.mu.Unlock()
|
||||
go m.readAgyRateLimit()
|
||||
|
||||
success := res.Status == "SUCCESS"
|
||||
bounce := false
|
||||
@@ -194,6 +197,42 @@ func (m *Manager) agyTurnEnded(ctx context.Context, l *live, p antigravityProces
|
||||
return m.turnEnded(ctx, l, r)
|
||||
}
|
||||
|
||||
var agyWindowMins = map[string]int{"5h": 300, "weekly": 7 * 24 * 60}
|
||||
|
||||
func (m *Manager) readAgyRateLimit() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
groups, err := antigravity.ReadUsage(ctx)
|
||||
if err != nil {
|
||||
slog.Error("read antigravity rate limits", "err", err)
|
||||
return
|
||||
}
|
||||
m.mu.Lock()
|
||||
m.rateLimits[api.Antigravity] = agyRateLimit(groups)
|
||||
m.mu.Unlock()
|
||||
m.store.Broadcast(api.Event{Kind: "admin.health", Actor: "byre", Payload: map[string]any{}})
|
||||
}
|
||||
|
||||
func agyRateLimit(groups []antigravity.UsageGroup) map[string]any {
|
||||
info := map[string]any{"status": "allowed"}
|
||||
windows := map[string]any{}
|
||||
for _, g := range groups {
|
||||
for _, b := range g.Buckets {
|
||||
window := map[string]any{"utilization": 1 - b.RemainingFraction, "resetsAt": b.ResetTime.Unix()}
|
||||
if mins := agyWindowMins[b.Window]; mins != 0 {
|
||||
window["windowMins"] = mins
|
||||
}
|
||||
windows[b.ID] = window
|
||||
if b.RemainingFraction <= 0 {
|
||||
info["status"] = "rejected"
|
||||
info["rateLimitType"] = b.ID
|
||||
}
|
||||
}
|
||||
}
|
||||
info["unifiedWindows"] = windows
|
||||
return info
|
||||
}
|
||||
|
||||
func (m *Manager) agyBeforeModel(l *live) antigravity.HookFunc {
|
||||
return func(ctx context.Context, input json.RawMessage) (map[string]any, error) {
|
||||
in := struct {
|
||||
|
||||
Reference in New Issue
Block a user