LLM Task LLM 任务
LLM 任务工具用于直接与 LLM 交互。
功能特性
- 直接模型调用
- 系统提示词配置
- Few-shot 示例
- 输出格式控制
配置
yaml
tools:
llm_task:
enabled: true
provider: "openai"
model: "gpt-4"
options:
temperature: 0.7
max_tokens: 4000
top_p: 1.0
frequency_penalty: 0
presence_penalty: 0
system_prompt: "你是一个有用的助手。"使用示例
typescript
// 基本调用
const result = await tool.llm_task.call({
prompt: '解释量子计算的基本原理'
});
console.log(result.content);
// 带 Few-shot
const result = await tool.llm_task.call({
prompt: '翻译以下句子到中文',
few_shot: [
{ input: 'Hello', output: '你好' },
{ input: 'Goodbye', output: '再见' }
]
});输出格式控制
typescript
// JSON 输出
const result = await tool.llm_task.call({
prompt: '提取用户信息',
format: 'json',
schema: {
type: 'object',
properties: {
name: { type: 'string' },
email: { type: 'string' },
age: { type: 'number' }
}
}
});
// 列表输出
const result = await tool.llm_task.call({
prompt: '列出三个优点',
format: 'list'
});批量任务
typescript
// 并行调用
const results = await tool.llm_task.parallel({
prompts: [
'解释 A',
'解释 B',
'解释 C'
],
provider: 'anthropic'
});