fix: resolve golangci-lint issues — remove unused constants and functions, fix gofmt
- Remove unused claudeMax*Tokens constants (Claude Max feature not included) - Remove unused UsageMapHook type, SetUsageMapHook method, and usageToMap function - Fix gofmt formatting in channel_service.go, openai_model_mapping_test.go, chatcompletions_to_responses.go
This commit is contained in:
@@ -18,9 +18,6 @@ const (
|
|||||||
BlockTypeFunction
|
BlockTypeFunction
|
||||||
)
|
)
|
||||||
|
|
||||||
// UsageMapHook is a callback that can modify usage data before it's emitted in SSE events.
|
|
||||||
type UsageMapHook func(usageMap map[string]any)
|
|
||||||
|
|
||||||
// StreamingProcessor 流式响应处理器
|
// StreamingProcessor 流式响应处理器
|
||||||
type StreamingProcessor struct {
|
type StreamingProcessor struct {
|
||||||
blockType BlockType
|
blockType BlockType
|
||||||
@@ -33,7 +30,6 @@ type StreamingProcessor struct {
|
|||||||
originalModel string
|
originalModel string
|
||||||
webSearchQueries []string
|
webSearchQueries []string
|
||||||
groundingChunks []GeminiGroundingChunk
|
groundingChunks []GeminiGroundingChunk
|
||||||
usageMapHook UsageMapHook
|
|
||||||
|
|
||||||
// 累计 usage
|
// 累计 usage
|
||||||
inputTokens int
|
inputTokens int
|
||||||
@@ -50,28 +46,6 @@ func NewStreamingProcessor(originalModel string) *StreamingProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetUsageMapHook sets an optional hook that modifies usage maps before they are emitted.
|
|
||||||
func (p *StreamingProcessor) SetUsageMapHook(fn UsageMapHook) {
|
|
||||||
p.usageMapHook = fn
|
|
||||||
}
|
|
||||||
|
|
||||||
func usageToMap(u ClaudeUsage) map[string]any {
|
|
||||||
m := map[string]any{
|
|
||||||
"input_tokens": u.InputTokens,
|
|
||||||
"output_tokens": u.OutputTokens,
|
|
||||||
}
|
|
||||||
if u.CacheCreationInputTokens > 0 {
|
|
||||||
m["cache_creation_input_tokens"] = u.CacheCreationInputTokens
|
|
||||||
}
|
|
||||||
if u.CacheReadInputTokens > 0 {
|
|
||||||
m["cache_read_input_tokens"] = u.CacheReadInputTokens
|
|
||||||
}
|
|
||||||
if u.ImageOutputTokens > 0 {
|
|
||||||
m["image_output_tokens"] = u.ImageOutputTokens
|
|
||||||
}
|
|
||||||
return m
|
|
||||||
}
|
|
||||||
|
|
||||||
// ProcessLine 处理 SSE 行,返回 Claude SSE 事件
|
// ProcessLine 处理 SSE 行,返回 Claude SSE 事件
|
||||||
func (p *StreamingProcessor) ProcessLine(line string) []byte {
|
func (p *StreamingProcessor) ProcessLine(line string) []byte {
|
||||||
line = strings.TrimSpace(line)
|
line = strings.TrimSpace(line)
|
||||||
|
|||||||
@@ -67,12 +67,6 @@ const (
|
|||||||
MediaTypePrompt = "prompt"
|
MediaTypePrompt = "prompt"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
claudeMaxMessageOverheadTokens = 3
|
|
||||||
claudeMaxBlockOverheadTokens = 1
|
|
||||||
claudeMaxUnknownContentTokens = 4
|
|
||||||
)
|
|
||||||
|
|
||||||
// ForceCacheBillingContextKey 强制缓存计费上下文键
|
// ForceCacheBillingContextKey 强制缓存计费上下文键
|
||||||
// 用于粘性会话切换时,将 input_tokens 转为 cache_read_input_tokens 计费
|
// 用于粘性会话切换时,将 input_tokens 转为 cache_read_input_tokens 计费
|
||||||
type forceCacheBillingKeyType struct{}
|
type forceCacheBillingKeyType struct{}
|
||||||
|
|||||||
Reference in New Issue
Block a user