Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InterpretNL ¶
InterpretNL 是 kubectl-qyai 的核心入口函数: 将自然语言解析为“候选执行命令”(不执行)。
逻辑: 1) 从配置读取模型列表(按优先级) 2) 并行调用 InterpretMultiModel 3) 选取最佳结果 4) 做基础语义校验(看起来像 kubectl 或运维 shell)
func ScoreInterpretation ¶
ScoreInterpretation 对命令文本做非常轻量的质量评分。 分数范围不是严格的,只要可排序即可。
func ScoreInterpretationForPrompt ¶
func ScoreInterpretationForPrompt(prompt, cmd string, ad model.ModelAdapter) float64
ScoreInterpretationForPrompt 在 ScoreInterpretation 的基础上,增加“意图域匹配”的轻量评分。
设计动机: - 当前 ScoreInterpretation 会对 `kubectl get ...` 给很高分。 - 兜底 heuristic 又经常返回 `kubectl get pods -A`,会在很多非 K8s 问题里“错误胜出”。 - 因此需要用 prompt 来判断用户更像是在问 K8s 还是系统运维,再对不匹配的命令做惩罚。
Types ¶
type Interpretation ¶
Interpretation 表示某个模型对同一 prompt 的解析结果。
func InterpretMultiModel ¶
func InterpretMultiModel(ctx context.Context, prompt string, adapters []model.ModelAdapter) ([]Interpretation, error)
InterpretMultiModel 并行调用所有 adapter.Parse,并按“优先级 + 简单匹配评分”排序。
评分规则(可迭代): - 基础分:ScoreInterpretation(command) - 叠加分:adapter.Priority() * 0.01(让高优先级略微占优,但不压过质量)
Source Files
¶
- interpret.go
- nl.go