mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-18 04:10:51 +08:00
feat(registry, executor): add support for glm-4.6 model and enhance Gemini CLI token handling
- Added `glm-4.6` model to registry and documentation. - Updated Gemini CLI executor to pass configuration to `prepareGeminiCLITokenSource` for improved token management.
This commit is contained in:
@@ -258,6 +258,7 @@ console.log(await claudeResponse.json());
|
|||||||
- gemini-2.5-pro
|
- gemini-2.5-pro
|
||||||
- gemini-2.5-flash
|
- gemini-2.5-flash
|
||||||
- gemini-2.5-flash-lite
|
- gemini-2.5-flash-lite
|
||||||
|
- gemini-2.5-flash-image
|
||||||
- gemini-2.5-flash-image-preview
|
- gemini-2.5-flash-image-preview
|
||||||
- gpt-5
|
- gpt-5
|
||||||
- gpt-5-codex
|
- gpt-5-codex
|
||||||
@@ -277,6 +278,7 @@ console.log(await claudeResponse.json());
|
|||||||
- deepseek-v3
|
- deepseek-v3
|
||||||
- kimi-k2
|
- kimi-k2
|
||||||
- glm-4.5
|
- glm-4.5
|
||||||
|
- glm-4.6
|
||||||
- tstars2.0
|
- tstars2.0
|
||||||
- And other iFlow-supported models
|
- And other iFlow-supported models
|
||||||
- Gemini models auto-switch to preview variants when needed
|
- Gemini models auto-switch to preview variants when needed
|
||||||
|
|||||||
@@ -270,6 +270,7 @@ console.log(await claudeResponse.json());
|
|||||||
- gemini-2.5-pro
|
- gemini-2.5-pro
|
||||||
- gemini-2.5-flash
|
- gemini-2.5-flash
|
||||||
- gemini-2.5-flash-lite
|
- gemini-2.5-flash-lite
|
||||||
|
- gemini-2.5-flash-image
|
||||||
- gemini-2.5-flash-image-preview
|
- gemini-2.5-flash-image-preview
|
||||||
- gpt-5
|
- gpt-5
|
||||||
- gpt-5-codex
|
- gpt-5-codex
|
||||||
@@ -289,6 +290,7 @@ console.log(await claudeResponse.json());
|
|||||||
- deepseek-v3
|
- deepseek-v3
|
||||||
- kimi-k2
|
- kimi-k2
|
||||||
- glm-4.5
|
- glm-4.5
|
||||||
|
- glm-4.6
|
||||||
- tstars2.0
|
- tstars2.0
|
||||||
- 以及其他 iFlow 支持的模型
|
- 以及其他 iFlow 支持的模型
|
||||||
- Gemini 模型在需要时自动切换到对应的 preview 版本
|
- Gemini 模型在需要时自动切换到对应的 preview 版本
|
||||||
|
|||||||
@@ -368,6 +368,7 @@ func GetIFlowModels() []*ModelInfo {
|
|||||||
{ID: "qwen3-max-preview", DisplayName: "Qwen3-Max-Preview", Description: "Qwen3 Max preview build"},
|
{ID: "qwen3-max-preview", DisplayName: "Qwen3-Max-Preview", Description: "Qwen3 Max preview build"},
|
||||||
{ID: "kimi-k2-0905", DisplayName: "Kimi-K2-Instruct-0905", Description: "Moonshot Kimi K2 instruct 0905"},
|
{ID: "kimi-k2-0905", DisplayName: "Kimi-K2-Instruct-0905", Description: "Moonshot Kimi K2 instruct 0905"},
|
||||||
{ID: "glm-4.5", DisplayName: "GLM-4.5", Description: "Zhipu GLM 4.5 general model"},
|
{ID: "glm-4.5", DisplayName: "GLM-4.5", Description: "Zhipu GLM 4.5 general model"},
|
||||||
|
{ID: "glm-4.6", DisplayName: "GLM-4.6", Description: "Zhipu GLM 4.6 general model"},
|
||||||
{ID: "kimi-k2", DisplayName: "Kimi-K2", Description: "Moonshot Kimi K2 general model"},
|
{ID: "kimi-k2", DisplayName: "Kimi-K2", Description: "Moonshot Kimi K2 general model"},
|
||||||
{ID: "deepseek-v3.2", DisplayName: "DeepSeek-V3.2-Exp", Description: "DeepSeek V3.2 experimental"},
|
{ID: "deepseek-v3.2", DisplayName: "DeepSeek-V3.2-Exp", Description: "DeepSeek V3.2 experimental"},
|
||||||
{ID: "deepseek-v3.1", DisplayName: "DeepSeek-V3.1-Terminus", Description: "DeepSeek V3.1 Terminus"},
|
{ID: "deepseek-v3.1", DisplayName: "DeepSeek-V3.1-Terminus", Description: "DeepSeek V3.1 Terminus"},
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ func (e *GeminiCLIExecutor) Identifier() string { return "gemini-cli" }
|
|||||||
func (e *GeminiCLIExecutor) PrepareRequest(_ *http.Request, _ *cliproxyauth.Auth) error { return nil }
|
func (e *GeminiCLIExecutor) PrepareRequest(_ *http.Request, _ *cliproxyauth.Auth) error { return nil }
|
||||||
|
|
||||||
func (e *GeminiCLIExecutor) Execute(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (cliproxyexecutor.Response, error) {
|
func (e *GeminiCLIExecutor) Execute(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (cliproxyexecutor.Response, error) {
|
||||||
tokenSource, baseTokenData, err := prepareGeminiCLITokenSource(ctx, auth)
|
tokenSource, baseTokenData, err := prepareGeminiCLITokenSource(ctx, e.cfg, auth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cliproxyexecutor.Response{}, err
|
return cliproxyexecutor.Response{}, err
|
||||||
}
|
}
|
||||||
@@ -139,7 +139,7 @@ func (e *GeminiCLIExecutor) Execute(ctx context.Context, auth *cliproxyauth.Auth
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *GeminiCLIExecutor) ExecuteStream(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (<-chan cliproxyexecutor.StreamChunk, error) {
|
func (e *GeminiCLIExecutor) ExecuteStream(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (<-chan cliproxyexecutor.StreamChunk, error) {
|
||||||
tokenSource, baseTokenData, err := prepareGeminiCLITokenSource(ctx, auth)
|
tokenSource, baseTokenData, err := prepareGeminiCLITokenSource(ctx, e.cfg, auth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -270,7 +270,7 @@ func (e *GeminiCLIExecutor) ExecuteStream(ctx context.Context, auth *cliproxyaut
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *GeminiCLIExecutor) CountTokens(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (cliproxyexecutor.Response, error) {
|
func (e *GeminiCLIExecutor) CountTokens(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (cliproxyexecutor.Response, error) {
|
||||||
tokenSource, baseTokenData, err := prepareGeminiCLITokenSource(ctx, auth)
|
tokenSource, baseTokenData, err := prepareGeminiCLITokenSource(ctx, e.cfg, auth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cliproxyexecutor.Response{}, err
|
return cliproxyexecutor.Response{}, err
|
||||||
}
|
}
|
||||||
@@ -351,7 +351,7 @@ func (e *GeminiCLIExecutor) Refresh(ctx context.Context, auth *cliproxyauth.Auth
|
|||||||
return auth, nil
|
return auth, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func prepareGeminiCLITokenSource(ctx context.Context, auth *cliproxyauth.Auth) (oauth2.TokenSource, map[string]any, error) {
|
func prepareGeminiCLITokenSource(ctx context.Context, cfg *config.Config, auth *cliproxyauth.Auth) (oauth2.TokenSource, map[string]any, error) {
|
||||||
if auth == nil || auth.Metadata == nil {
|
if auth == nil || auth.Metadata == nil {
|
||||||
return nil, nil, fmt.Errorf("gemini-cli auth metadata missing")
|
return nil, nil, fmt.Errorf("gemini-cli auth metadata missing")
|
||||||
}
|
}
|
||||||
@@ -395,8 +395,8 @@ func prepareGeminiCLITokenSource(ctx context.Context, auth *cliproxyauth.Auth) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctxToken := ctx
|
ctxToken := ctx
|
||||||
if rt, ok := ctx.Value("cliproxy.roundtripper").(http.RoundTripper); ok && rt != nil {
|
if httpClient := newProxyAwareHTTPClient(ctx, cfg, auth, 0); httpClient != nil {
|
||||||
ctxToken = context.WithValue(ctxToken, oauth2.HTTPClient, &http.Client{Transport: rt})
|
ctxToken = context.WithValue(ctxToken, oauth2.HTTPClient, httpClient)
|
||||||
}
|
}
|
||||||
|
|
||||||
src := conf.TokenSource(ctxToken, &token)
|
src := conf.TokenSource(ctxToken, &token)
|
||||||
|
|||||||
Reference in New Issue
Block a user