跳至主要内容

cog run

运行 Cognitive Module。

命令名称

本文档使用 cog(npm 版本)。如果使用 pip 版本,请将 cog 替换为 cogn

语法

cog run <module> [input_file] [options]

参数

参数说明
module模块名称或路径
input_file输入 JSON 文件(可选,使用 --args 时可省略)

选项

选项简写说明
--output FILE-o输出文件路径
--args TEXT-a直接传入文本参数
--pretty格式化 JSON 输出
--no-validate跳过 Schema 验证
--subagent-s启用子代理模式
--model MODEL-m覆盖 LLM 模型

示例

使用 JSON 文件

cog run ui-spec-generator input.json -o output.json --pretty

使用 --args

cog run code-reviewer --args "def foo(): pass" --pretty

启用子代理

cog run product-analyzer --args "健康产品" --subagent --pretty

指定模型

cog run code-reviewer --args "代码" --model gpt-4-turbo

保存输出

cog run api-designer --args "用户 API" -o api-spec.json --pretty

输出

运行成功时:

→ Running module: code-reviewer
{
"issues": [...],
"confidence": 0.95
}
Confidence: 0.95

运行失败时:

→ Running module: code-reviewer
✗ Error: Output validation failed: [...]

环境变量

变量说明
LLM_PROVIDERLLM 后端(openai/anthropic/minimax/ollama/stub)
OPENAI_API_KEYOpenAI API 密钥
ANTHROPIC_API_KEYAnthropic API 密钥
MINIMAX_API_KEYMiniMax API 密钥
LLM_MODEL默认模型