mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-18 04:10:51 +08:00
feat(gemini-web): Replace code-mode with flexible gem-mode
This commit is contained in:
@@ -62,10 +62,19 @@ type GeminiWebConfig struct {
|
||||
// Defaults to true if not set in YAML (see LoadConfig).
|
||||
Context bool `yaml:"context" json:"context"`
|
||||
|
||||
// CodeMode, when true, enables coding mode behaviors for Gemini Web:
|
||||
// - Attach the predefined "Coding partner" Gem
|
||||
// - Enable XML wrapping hint for tool markup
|
||||
// - Merge <think> content into visible content for tool-friendly output
|
||||
// GemMode selects a predefined Gem to attach for Gemini Web requests.
|
||||
// Allowed values:
|
||||
// - "coding-partner"
|
||||
// - "writing-editor"
|
||||
// When empty, no Gem is attached by configuration.
|
||||
// This is independent from CodeMode below, which is kept for backwards compatibility.
|
||||
GemMode string `yaml:"gem-mode" json:"gem-mode"`
|
||||
|
||||
// CodeMode enables legacy coding-mode behaviors for Gemini Web.
|
||||
// Backwards compatibility: when true, the service behaves as before by
|
||||
// attaching the predefined "Coding partner" Gem and enabling extra
|
||||
// conveniences (e.g., XML wrapping hints). Prefer GemMode for selecting
|
||||
// a Gem going forward.
|
||||
CodeMode bool `yaml:"code-mode" json:"code-mode"`
|
||||
|
||||
// MaxCharsPerRequest caps the number of characters (runes) sent to
|
||||
|
||||
@@ -696,7 +696,22 @@ func (s *GeminiWebState) findReusableSession(modelName string, msgs []RoleText)
|
||||
}
|
||||
|
||||
func (s *GeminiWebState) getConfiguredGem() *Gem {
|
||||
if s.cfg != nil && s.cfg.GeminiWeb.CodeMode {
|
||||
if s.cfg == nil {
|
||||
return nil
|
||||
}
|
||||
// New behavior: attach Gem based on explicit GemMode selection.
|
||||
// Only attaches the Gem; does not toggle any other behavior.
|
||||
if gm := strings.ToLower(strings.TrimSpace(s.cfg.GeminiWeb.GemMode)); gm != "" {
|
||||
switch gm {
|
||||
case "coding-partner":
|
||||
return &Gem{ID: "coding-partner", Name: "Coding partner", Predefined: true}
|
||||
case "writing-editor":
|
||||
return &Gem{ID: "writing-editor", Name: "Writing editor", Predefined: true}
|
||||
}
|
||||
}
|
||||
// Backwards compatibility: legacy CodeMode still attaches Coding partner
|
||||
// and may enable extra behaviors elsewhere.
|
||||
if s.cfg.GeminiWeb.CodeMode {
|
||||
return &Gem{ID: "coding-partner", Name: "Coding partner", Predefined: true}
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -521,6 +521,9 @@ func (w *Watcher) reloadConfig() bool {
|
||||
if oldConfig.GeminiWeb.DisableContinuationHint != newConfig.GeminiWeb.DisableContinuationHint {
|
||||
log.Debugf(" gemini-web.disable-continuation-hint: %t -> %t", oldConfig.GeminiWeb.DisableContinuationHint, newConfig.GeminiWeb.DisableContinuationHint)
|
||||
}
|
||||
if oldConfig.GeminiWeb.GemMode != newConfig.GeminiWeb.GemMode {
|
||||
log.Debugf(" gemini-web.gem-mode: %s -> %s", oldConfig.GeminiWeb.GemMode, newConfig.GeminiWeb.GemMode)
|
||||
}
|
||||
if oldConfig.GeminiWeb.CodeMode != newConfig.GeminiWeb.CodeMode {
|
||||
log.Debugf(" gemini-web.code-mode: %t -> %t", oldConfig.GeminiWeb.CodeMode, newConfig.GeminiWeb.CodeMode)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user