mirror of
https://github.com/jasonxu114514/opencode2api.git
synced 2026-12-06 08:03:47 +00:00
feat: 新增模型轮转、额度看板和密钥管理
This commit is contained in:
1 parent
e5f4e3a583
commit
3440273f43
32 files changed
+2918
-32
No files matched your search
+16
-15
@@ -12,19 +12,20 @@ import (
|
||||
)
|
||||
|
||||
type RequestMeta struct {
|
||||
Model string
|
||||
Tier string
|
||||
Protocol protocol.Protocol
|
||||
Request string
|
||||
KeyID string
|
||||
Channel string
|
||||
Anonymous bool
|
||||
Proxy string
|
||||
Attempts int
|
||||
Legs []string
|
||||
Stop string
|
||||
Tail string
|
||||
Stream bool
|
||||
ModelAlias string
|
||||
Model string
|
||||
Tier string
|
||||
Protocol protocol.Protocol
|
||||
Request string
|
||||
KeyID string
|
||||
Channel string
|
||||
Anonymous bool
|
||||
Proxy string
|
||||
Attempts int
|
||||
Legs []string
|
||||
Stop string
|
||||
Tail string
|
||||
Stream bool
|
||||
// Shaped marks a key-tier free-model request whose wire body was
|
||||
// normalized to agent shape (stream + core tools) like the anonymous
|
||||
// lane. Non-streaming responses for shaped requests arrive as SSE
|
||||
@@ -111,13 +112,13 @@ func Middleware(monitor *Monitor, logger *slog.Logger, next http.Handler) http.H
|
||||
if meta.Channel != "" {
|
||||
logger.Info("request routed", "component", "http", "event", "request_routed", "method", r.Method,
|
||||
"path", r.URL.Path, "status", status, "duration_ms", duration.Milliseconds(), "request_id", meta.Request,
|
||||
"model", meta.Model, "tier", meta.Tier, "key_id", meta.KeyID, "channel", meta.Channel,
|
||||
"model", meta.Model, "model_alias", meta.ModelAlias, "tier", meta.Tier, "key_id", meta.KeyID, "channel", meta.Channel,
|
||||
"anonymous", meta.Anonymous, "attempts", meta.Attempts, "legs", strings.Join(meta.Legs, " "), "stream", meta.Stream, "outcome", outcome,
|
||||
"stop", meta.Stop, "in", meta.Usage.Input, "out", meta.Usage.Output, "reasoning_tokens", meta.Usage.Reasoning, "cached", meta.Usage.Cached, "tail", meta.Tail)
|
||||
}
|
||||
logger.Debug("request completed", "component", "http", "event", "request_complete", "method", r.Method,
|
||||
"path", r.URL.Path, "status", status, "duration_ms", duration.Milliseconds(), "bytes", writer.bytes,
|
||||
"request_id", meta.Request, "model", meta.Model, "tier", meta.Tier, "key_id", meta.KeyID,
|
||||
"request_id", meta.Request, "model", meta.Model, "model_alias", meta.ModelAlias, "tier", meta.Tier, "key_id", meta.KeyID,
|
||||
"channel", meta.Channel, "anonymous", meta.Anonymous, "attempts", meta.Attempts, "stream", meta.Stream, "outcome", outcome)
|
||||
}()
|
||||
next.ServeHTTP(writer, r)
|
||||
|
||||
Reference in new issue
Block a user