代理: 流式中断按已生成部分计费

- 新增 tokenizer 包(tiktoken-go)按模型估算 token, 未知模型回退 cl100k_base
- passthrough 提取请求输入文本 + SSE 已生成内容, 客户端断开时记 canceled
- usage 计费范围扩展: canceled(流式中断)按已生成部分收费

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Sakurasan
2026-08-16 09:04:18 +08:00
co-authored by Claude
parent 4b507d8064
commit 0ee92d78e7
5 changed files with 156 additions and 5 deletions
+3 -1
View File
@@ -1,6 +1,6 @@
module github.com/openteam/server
go 1.25.0
go 1.26
require (
github.com/gin-gonic/gin v1.12.0
@@ -8,6 +8,7 @@ require (
github.com/go-webauthn/webauthn v0.17.4
github.com/golang-jwt/jwt/v5 v5.3.1
github.com/spf13/viper v1.21.0
github.com/tiktoken-go/tokenizer v0.8.1
golang.org/x/crypto v0.55.0
gorm.io/driver/postgres v1.6.2
gorm.io/gorm v1.31.2
@@ -18,6 +19,7 @@ require (
github.com/bytedance/sonic v1.15.0 // indirect
github.com/bytedance/sonic/loader v0.5.0 // indirect
github.com/cloudwego/base64x v0.1.6 // indirect
github.com/dlclark/regexp2/v2 v2.5.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/fxamacker/cbor/v2 v2.9.2 // indirect