6f8b825f5f
The `weknora` command-line client for the WeKnora RAG server. Full command surface: kb / doc / chunk / session / message / agent / model / search / chat / auth / profile / link / api / mcp / skills / config / doctor / schema / exit-codes. Agent-first wire contract: JSON envelope by default, typed error codes mapped to stable exit codes, error.retry_argv / retryable / partial-failure status, global --dry-run preview, the exit-10 confirmation protocol for writes, and control/ANSI/Bidi input hygiene. Stateless env-credential auth (WEKNORA_API_KEY / WEKNORA_TOKEN + WEKNORA_HOST) for headless/CI/agent use. A curated read-only MCP tool surface (`mcp serve`) and embedded Agent Skills (`skills install`). Extensive unit + contract-golden tests and CI.
43 lines
1.4 KiB
Go
43 lines
1.4 KiB
Go
// Package modelcmd holds the `weknora model` command tree: list / view.
|
|
//
|
|
// These are read-only discovery commands. The model id is a required input to
|
|
// `weknora agent create --model <id>` and to a knowledge base's embedding /
|
|
// summary model settings, so the CLI must offer a first-class way to find it
|
|
// rather than forcing callers down to the raw `weknora api` escape hatch.
|
|
//
|
|
// The directory is named `model/` to match the cobra subcommand; the Go
|
|
// package is `modelcmd` to avoid colliding with the SDK's Model type.
|
|
package modelcmd
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/Tencent/WeKnora/cli/internal/cmdutil"
|
|
sdk "github.com/Tencent/WeKnora/client"
|
|
)
|
|
|
|
// NewCmd builds the `weknora model` parent and registers leaves. Called from
|
|
// cli/cmd/root.go.
|
|
func NewCmd(f *cmdutil.Factory) *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "model",
|
|
Short: "Manage models (list / view / create / delete)",
|
|
Long: `List, inspect, register, and delete the models configured on the server. Use
|
|
the model id to back a knowledge base's embedding / summary config ('weknora kb
|
|
init') or an agent ('weknora agent create --model <id>').`,
|
|
}
|
|
cmd.AddCommand(NewCmdList(f))
|
|
cmd.AddCommand(NewCmdView(f))
|
|
cmd.AddCommand(NewCmdCreate(f))
|
|
cmd.AddCommand(NewCmdDelete(f))
|
|
return cmd
|
|
}
|
|
|
|
// modelLabel prefers display_name, falling back to the raw name.
|
|
func modelLabel(m sdk.Model) string {
|
|
if m.DisplayName != "" {
|
|
return m.DisplayName
|
|
}
|
|
return m.Name
|
|
}
|