Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
ffe43f60
"...internal/server/git@web.lueluesay.top:chenxi/sub2api.git" did not exist on "ba7d2aecbb365934903ada2305847da90bcdd106"
Commit
ffe43f60
authored
Jan 27, 2026
by
cyhhao
Browse files
Merge branch 'main' of github.com:Wei-Shaw/sub2api
parents
a161fcc8
56a1e29c
Changes
2
Show whitespace changes
Inline
Side-by-side
.github/workflows/release.yml
View file @
ffe43f60
...
@@ -222,8 +222,9 @@ jobs:
...
@@ -222,8 +222,9 @@ jobs:
REPO="${{ github.repository }}"
REPO="${{ github.repository }}"
GHCR_IMAGE="ghcr.io/${REPO,,}" # ${,,} converts to lowercase
GHCR_IMAGE="ghcr.io/${REPO,,}" # ${,,} converts to lowercase
# 获取 tag message 内容
# 获取 tag message 内容
并转义 Markdown 特殊字符
TAG_MESSAGE='${{ steps.tag_message.outputs.message }}'
TAG_MESSAGE='${{ steps.tag_message.outputs.message }}'
TAG_MESSAGE=$(echo "$TAG_MESSAGE" | sed 's/\([_*`\[]\)/\\\1/g')
# 限制消息长度(Telegram 消息限制 4096 字符,预留空间给头尾固定内容)
# 限制消息长度(Telegram 消息限制 4096 字符,预留空间给头尾固定内容)
if [ ${#TAG_MESSAGE} -gt 3500 ]; then
if [ ${#TAG_MESSAGE} -gt 3500 ]; then
...
...
backend/internal/service/gateway_service.go
View file @
ffe43f60
...
@@ -4102,20 +4102,13 @@ func (s *GatewayService) parseSSEUsage(data string, usage *ClaudeUsage) {
...
@@ -4102,20 +4102,13 @@ func (s *GatewayService) parseSSEUsage(data string, usage *ClaudeUsage) {
}
`json:"usage"`
}
`json:"usage"`
}
}
if
json
.
Unmarshal
([]
byte
(
data
),
&
msgDelta
)
==
nil
&&
msgDelta
.
Type
==
"message_delta"
{
if
json
.
Unmarshal
([]
byte
(
data
),
&
msgDelta
)
==
nil
&&
msgDelta
.
Type
==
"message_delta"
{
// output_tokens 总是从 message_delta 获取
// message_delta 是推理结束后的最终统计,应完全覆盖 message_start 的数据
usage
.
OutputTokens
=
msgDelta
.
Usage
.
OutputTokens
// 这对于 Claude API 和 GLM 等兼容 API 都是正确的行为
// 如果 message_start 中没有值,则从 message_delta 获取(兼容GLM等API)
if
usage
.
InputTokens
==
0
{
usage
.
InputTokens
=
msgDelta
.
Usage
.
InputTokens
usage
.
InputTokens
=
msgDelta
.
Usage
.
InputTokens
}
usage
.
OutputTokens
=
msgDelta
.
Usage
.
OutputTokens
if
usage
.
CacheCreationInputTokens
==
0
{
usage
.
CacheCreationInputTokens
=
msgDelta
.
Usage
.
CacheCreationInputTokens
usage
.
CacheCreationInputTokens
=
msgDelta
.
Usage
.
CacheCreationInputTokens
}
if
usage
.
CacheReadInputTokens
==
0
{
usage
.
CacheReadInputTokens
=
msgDelta
.
Usage
.
CacheReadInputTokens
usage
.
CacheReadInputTokens
=
msgDelta
.
Usage
.
CacheReadInputTokens
}
}
}
}
}
func
(
s
*
GatewayService
)
handleNonStreamingResponse
(
ctx
context
.
Context
,
resp
*
http
.
Response
,
c
*
gin
.
Context
,
account
*
Account
,
originalModel
,
mappedModel
string
,
toolNameMap
map
[
string
]
string
,
mimicClaudeCode
bool
)
(
*
ClaudeUsage
,
error
)
{
func
(
s
*
GatewayService
)
handleNonStreamingResponse
(
ctx
context
.
Context
,
resp
*
http
.
Response
,
c
*
gin
.
Context
,
account
*
Account
,
originalModel
,
mappedModel
string
,
toolNameMap
map
[
string
]
string
,
mimicClaudeCode
bool
)
(
*
ClaudeUsage
,
error
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment