mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-02 12:30:50 +08:00
- Implemented `TokenCount` transform method across translators to calculate token usage. - Integrated token counting logic into executor pipelines for Claude, Gemini, and CLI translators. - Added corresponding API endpoints and handlers (`/messages/count_tokens`) for token usage retrieval. - Enhanced translation registry to support `TokenCount` functionality alongside existing response types.
21 lines
510 B
Go
21 lines
510 B
Go
package geminiCLI
|
|
|
|
import (
|
|
. "github.com/router-for-me/CLIProxyAPI/v6/internal/constant"
|
|
"github.com/router-for-me/CLIProxyAPI/v6/internal/interfaces"
|
|
"github.com/router-for-me/CLIProxyAPI/v6/internal/translator/translator"
|
|
)
|
|
|
|
func init() {
|
|
translator.Register(
|
|
GeminiCLI,
|
|
Gemini,
|
|
ConvertGeminiCLIRequestToGemini,
|
|
interfaces.TranslateResponse{
|
|
Stream: ConvertGeminiResponseToGeminiCLI,
|
|
NonStream: ConvertGeminiResponseToGeminiCLINonStream,
|
|
TokenCount: GeminiCLITokenCount,
|
|
},
|
|
)
|
|
}
|