feat: llm output and var type

This commit is contained in:
Joel
2024-03-13 14:37:45 +08:00
parent b718e66b26
commit f15dce9ee3
5 changed files with 120 additions and 12 deletions

View File

@ -1,4 +1,5 @@
import { BlockEnum } from './types'
import type { Var } from './types'
import { BlockEnum, VarType } from './types'
import StartNodeDefault from './nodes/start/default'
import DirectAnswerDefault from './nodes/direct-answer/default'
import LLMDefault from './nodes/llm/default'
@ -178,3 +179,73 @@ export const RETRIEVAL_OUTPUT_STRUCT = `{
"score": ""
}
}`
export const SUPPORT_OUTPUT_VARS_NODE = [
BlockEnum.Start, BlockEnum.LLM, BlockEnum.KnowledgeRetrieval, BlockEnum.Code, BlockEnum.TemplateTransform,
BlockEnum.QuestionClassifier, BlockEnum.HttpRequest, BlockEnum.Tool, BlockEnum.VariableAssigner,
]
export const LLM_OUTPUT_STRUCT: Var[] = [
{
variable: 'text',
type: VarType.string,
},
{
variable: 'usage',
type: VarType.object,
children: [
{
variable: 'prompt_tokens',
type: VarType.number,
},
{
variable: 'prompt_unit_price',
type: VarType.number,
},
{
variable: 'prompt_price_unit',
type: VarType.number,
},
{
variable: 'prompt_price',
type: VarType.number,
},
{
variable: 'completion_tokens',
type: VarType.number,
},
{
variable: 'completion_unit_price',
type: VarType.number,
},
{
variable: 'completion_price_unit',
type: VarType.number,
},
{
variable: 'completion_unit_price',
type: VarType.number,
},
{
variable: 'completion_price',
type: VarType.number,
},
{
variable: 'total_tokens',
type: VarType.number,
},
{
variable: 'total_price',
type: VarType.number,
},
{
variable: 'currency',
type: VarType.string,
},
{
variable: 'latency',
type: VarType.number,
},
],
},
]