# 大模型节点
调用大语言模型,使用变量和提示词生成回复。
# 数据结构定义
export interface LLMNodeDef {
id: INodeIDValue;
type: WorkflowNodeTypeEnum.LLM;
data: {
title: string;
inputsValues: { // 业务数据(使用业务定义的类型)
model_name: IFlowConstantValue, // 模型名称
input_params: { // 输入参数
[key: string]:
IFlowConstantValue |
IFlowRefValue;
},
message: [ // 消息列表
{
role: IFlowConstantValue, // 角色, system 系统提示词,user 用户提示词
text: IFlowFreemarkerValue, // 提示词内容
}
],
temperature: IFlowConstantValue, // 温度
top_p: IFlowConstantValue, // 采样策略
frequency_penalty: IFlowConstantValue, // 频率惩罚
presence_penalty: IFlowConstantValue, // 存在惩罚
max_tokens: IFlowConstantValue, // 最大标记
max_retries: IFlowConstantValue, // 最大重试次数
retry_interval: IFlowConstantValue, // 重试间隔
};
inputs: IJsonSchema; // 节点输入数据类型
outputs: IJsonSchema; // 节点输出数据类型
}
}
# 范例
{
id: {random(6)},
type: 'llm',
data: {
title: `大模型`,
inputsValues: {
model_name: {
type: 'constant', // 模型名称
content: '',
},
message: [ // 消息列表
{
role: {
type: 'constant',
content: 'system',
},
text: {
type: 'freemarker',
content: '',
},
},
],
temperature: { // 温度
type: 'constant',
content: 0.7,
},
top_p: { // 采样策略
type: 'constant',
content: 1,
},
frequency_penalty: { // 频率惩罚
type: 'constant',
content: 0,
},
presence_penalty: { // 存在惩罚
type: 'constant',
content: 0,
},
max_tokens: { // 最大标记
type: 'constant',
content: 4096,
},
max_retries: { // 最大重试次数
type: 'constant',
content: 3,
},
retry_interval: { // 重试间隔
type: 'constant',
content: 1000,
},
},
inputs: {
type: 'object',
required: [],
properties: {
model_name: { type: 'string' };
input_params: { type: 'object' };
message: {
type: 'array',
items: {
type: 'object',
properties: {
role: { type: 'string' },
text: { type: 'string' },
},
},
};
temperature: { type: 'number' };
top_p: { type: 'number' };
frequency_penalty: { type: 'number' };
presence_penalty: { type: 'number' };
max_tokens: { type: 'number' };
max_retries: { type: 'number' };
retry_interval: { type: 'number' };
}
},
outputs: {
type: 'object',
properties: {
result: { type: 'string' },
},
},
},
};