Include chat, weather, image, travel, streaming ASR and text examples, shared model initialization, documentation, and existing tests. Co-authored-by: TRAE CLI <traecli@bytedance.com>
36 lines
1004 B
Go
36 lines
1004 B
Go
// Package cli 定义终端助手的文字与语音命令入口。
|
|
package cli
|
|
|
|
import (
|
|
"context"
|
|
|
|
"example.com/ueino/adk/internal/config"
|
|
"example.com/ueino/adk/internal/terminal"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func NewCommand() *cobra.Command {
|
|
return newCommand(terminal.Run)
|
|
}
|
|
|
|
func newCommand(run func(context.Context, config.Config, bool) error) *cobra.Command {
|
|
var cfg config.Config
|
|
root := &cobra.Command{
|
|
Use: "adk", Short: "Eino ADK 终端助手,默认使用文字聊天",
|
|
Args: cobra.NoArgs, SilenceUsage: true, SilenceErrors: true,
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
return run(cmd.Context(), cfg.Resolve(), false)
|
|
},
|
|
}
|
|
root.CompletionOptions.DisableDefaultCmd = true
|
|
cfg.BindFlags(root.PersistentFlags())
|
|
root.AddCommand(&cobra.Command{
|
|
Use: "voice", Short: "使用麦克风进行语音聊天",
|
|
Args: cobra.NoArgs,
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
return run(cmd.Context(), cfg.Resolve(), true)
|
|
},
|
|
})
|
|
return root
|
|
}
|