Feat: conversation variable & variable assigner node (#7222)

Signed-off-by: -LAN- <laipz8200@outlook.com>
Co-authored-by: Joel <iamjoel007@gmail.com>
Co-authored-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
KVOJJJin
2024-08-13 14:44:10 +08:00
committed by GitHub
parent 8b55bd5828
commit 935e72d449
128 changed files with 3354 additions and 683 deletions

View File

@@ -11,6 +11,7 @@ import type {
} from './help-line/types'
import type { VariableAssignerNodeType } from './nodes/variable-assigner/types'
import type {
ConversationVariable,
Edge,
EnvironmentVariable,
HistoryWorkflowData,
@@ -21,6 +22,24 @@ import type {
} from './types'
import { WorkflowContext } from './context'
// #TODO chatVar#
// const MOCK_DATA = [
// {
// id: 'fjlaksdjflkjg-dfjlajfl0dnfkafjk-djfdkafj-djfak',
// name: 'chat_history',
// value_type: 'array[message]',
// value: [],
// description: 'The chat history of the conversation',
// },
// {
// id: 'fljdaklfjl-dfjlafj0-dklajglje-eknglh',
// name: 'order_id',
// value: '123456',
// value_type: 'string',
// description: '',
// },
// ]
type PreviewRunningData = WorkflowRunningData & {
resultTabActive?: boolean
resultText?: string
@@ -90,6 +109,10 @@ type Shape = {
setEnvironmentVariables: (environmentVariables: EnvironmentVariable[]) => void
envSecrets: Record<string, string>
setEnvSecrets: (envSecrets: Record<string, string>) => void
showChatVariablePanel: boolean
setShowChatVariablePanel: (showChatVariablePanel: boolean) => void
conversationVariables: ConversationVariable[]
setConversationVariables: (conversationVariables: ConversationVariable[]) => void
selection: null | { x1: number; y1: number; x2: number; y2: number }
setSelection: (selection: Shape['selection']) => void
bundleNodeSize: { width: number; height: number } | null
@@ -204,6 +227,10 @@ export const createWorkflowStore = () => {
setEnvironmentVariables: environmentVariables => set(() => ({ environmentVariables })),
envSecrets: {},
setEnvSecrets: envSecrets => set(() => ({ envSecrets })),
showChatVariablePanel: false,
setShowChatVariablePanel: showChatVariablePanel => set(() => ({ showChatVariablePanel })),
conversationVariables: [],
setConversationVariables: conversationVariables => set(() => ({ conversationVariables })),
selection: null,
setSelection: selection => set(() => ({ selection })),
bundleNodeSize: null,