mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-11-28 05:00:26 +08:00
43 lines
923 B
Go
43 lines
923 B
Go
// Copyright 2025, Command Line Inc.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package aiusechat
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/wavetermdev/waveterm/pkg/aiusechat/uctypes"
|
|
"github.com/wavetermdev/waveterm/pkg/wconfig"
|
|
)
|
|
|
|
func resolveAIMode(requestedMode string, premium bool) (string, *wconfig.AIModeConfigType, error) {
|
|
mode := requestedMode
|
|
if mode == "" {
|
|
mode = uctypes.AIModeBalanced
|
|
}
|
|
|
|
config, err := getAIModeConfig(mode)
|
|
if err != nil {
|
|
return "", nil, err
|
|
}
|
|
|
|
if config.WaveAICloud && !premium {
|
|
mode = uctypes.AIModeQuick
|
|
config, err = getAIModeConfig(mode)
|
|
if err != nil {
|
|
return "", nil, err
|
|
}
|
|
}
|
|
|
|
return mode, config, nil
|
|
}
|
|
|
|
func getAIModeConfig(aiMode string) (*wconfig.AIModeConfigType, error) {
|
|
fullConfig := wconfig.GetWatcher().GetFullConfig()
|
|
config, ok := fullConfig.WaveAIModes[aiMode]
|
|
if !ok {
|
|
return nil, fmt.Errorf("invalid AI mode: %s", aiMode)
|
|
}
|
|
|
|
return &config, nil
|
|
}
|