Files
ai-agent/flowgram-editor/src/nodes/llm/index.ts
T

98 lines
2.3 KiB
TypeScript
Raw Normal View History

2026-07-27 19:04:15 +08:00
/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
import { nanoid } from 'nanoid';
import { WorkflowNodeType } from '../constants';
import { FlowNodeRegistry } from '../../typings';
import iconLLM from '../../assets/icon-llm.jpg';
let index = 0;
export const LLMNodeRegistry: FlowNodeRegistry = {
type: WorkflowNodeType.LLM,
info: {
icon: iconLLM,
description:
'Call the large language model and use variables and prompt words to generate responses.',
},
meta: {
size: {
width: 360,
height: 390,
},
},
onAdd() {
return {
id: `llm_${nanoid(5)}`,
type: 'llm',
data: {
title: `LLM_${++index}`,
inputsValues: {
modelName: {
type: 'constant',
content: 'gpt-3.5-turbo',
},
apiKey: {
type: 'constant',
content: 'sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
},
apiHost: {
type: 'constant',
content: 'https://mock-ai-url/api/v3',
},
temperature: {
type: 'constant',
content: 0.5,
},
systemPrompt: {
type: 'template',
content: '# Role\nYou are an AI assistant.\n',
},
prompt: {
type: 'template',
content: '',
},
},
inputs: {
type: 'object',
required: ['modelName', 'apiKey', 'apiHost', 'temperature', 'prompt'],
properties: {
modelName: {
type: 'string',
},
apiKey: {
type: 'string',
},
apiHost: {
type: 'string',
},
temperature: {
type: 'number',
},
systemPrompt: {
type: 'string',
extra: {
formComponent: 'prompt-editor',
},
},
prompt: {
type: 'string',
extra: {
formComponent: 'prompt-editor',
},
},
},
},
outputs: {
type: 'object',
properties: {
result: { type: 'string' },
},
},
},
};
},
};