|
|
|
@ -13,7 +13,7 @@ import { LLM_MODELS } from "@/lib/llmModels"; |
|
|
|
import { useWorkflowStore } from "@/store/workflowStore"; |
|
|
|
import { SmartTextNodeData } from "@/types"; |
|
|
|
import { formatUserFacingError } from "@/utils/userFacingErrors"; |
|
|
|
import { getSmartTextInputHandles, SINGLE_INPUT_HANDLE_ID, SINGLE_OUTPUT_HANDLE_ID, type NodeInputHandleDescriptor } from "@/utils/nodeHandles"; |
|
|
|
import { SINGLE_INPUT_HANDLE_ID, SINGLE_OUTPUT_HANDLE_ID } from "@/utils/nodeHandles"; |
|
|
|
import { deriveSmartTextMode } from "@/utils/smartTextMode"; |
|
|
|
import { editorHtmlToMarkdown, insertEditorDivider, markdownToEditorHtml } from "@/utils/markdownEditor"; |
|
|
|
import { readTextDocumentFile } from "@/utils/textDocumentImport"; |
|
|
|
@ -30,8 +30,7 @@ function getSmartTextManualTitle(id: string, data: SmartTextNodeData, textInputL |
|
|
|
return match ? `${textInputLabel} ${match[1]}` : textInputLabel; |
|
|
|
} |
|
|
|
|
|
|
|
function SmartTextInputHandles({ handles, selected }: { handles: NodeInputHandleDescriptor[]; selected?: boolean }) { |
|
|
|
void handles; |
|
|
|
function SmartTextInputHandles({ selected }: { selected?: boolean }) { |
|
|
|
const showLabels = useShowHandleLabels(selected); |
|
|
|
|
|
|
|
return ( |
|
|
|
@ -212,12 +211,10 @@ function SmartTextNeutralView({ |
|
|
|
id, |
|
|
|
data, |
|
|
|
selected, |
|
|
|
inputHandles, |
|
|
|
}: { |
|
|
|
id: string; |
|
|
|
data: SmartTextNodeData; |
|
|
|
selected?: boolean; |
|
|
|
inputHandles: NodeInputHandleDescriptor[]; |
|
|
|
}) { |
|
|
|
const { t } = useI18n(); |
|
|
|
const updateNodeData = useWorkflowStore((state) => state.updateNodeData); |
|
|
|
@ -244,7 +241,7 @@ function SmartTextNeutralView({ |
|
|
|
minHeight={SMART_TEXT_MIN_DIMENSIONS.height} |
|
|
|
fullBleed |
|
|
|
> |
|
|
|
<SmartTextInputHandles handles={inputHandles} selected={selected} /> |
|
|
|
<SmartTextInputHandles selected={selected} /> |
|
|
|
<TextOutputHandle selected={selected} /> |
|
|
|
<div className="flex h-full w-full flex-col bg-neutral-900/25 px-6 py-9"> |
|
|
|
<div className="flex justify-center"> |
|
|
|
@ -481,12 +478,10 @@ function SmartTextLlmView({ |
|
|
|
id, |
|
|
|
data, |
|
|
|
selected, |
|
|
|
inputHandles, |
|
|
|
}: { |
|
|
|
id: string; |
|
|
|
data: SmartTextNodeData; |
|
|
|
selected?: boolean; |
|
|
|
inputHandles: NodeInputHandleDescriptor[]; |
|
|
|
}) { |
|
|
|
const { t } = useI18n(); |
|
|
|
const updateNodeData = useWorkflowStore((state) => state.updateNodeData); |
|
|
|
@ -504,7 +499,7 @@ function SmartTextLlmView({ |
|
|
|
minHeight={SMART_TEXT_MIN_DIMENSIONS.height} |
|
|
|
fullBleed |
|
|
|
> |
|
|
|
<SmartTextInputHandles handles={inputHandles} selected={selected} /> |
|
|
|
<SmartTextInputHandles selected={selected} /> |
|
|
|
<TextOutputHandle selected={selected} /> |
|
|
|
{data.status === "loading" ? ( |
|
|
|
<div |
|
|
|
@ -540,15 +535,14 @@ function SmartTextLlmView({ |
|
|
|
export function SmartTextNode({ id, data, selected }: NodeProps<SmartTextNodeType>) { |
|
|
|
const edges = useWorkflowStore((state) => state.edges); |
|
|
|
const mode = deriveSmartTextMode(id, data, edges); |
|
|
|
const inputHandles = getSmartTextInputHandles({ id, type: "smartText", data }, edges); |
|
|
|
|
|
|
|
if (mode === "manualText") { |
|
|
|
return <SmartTextManualView id={id} data={data} selected={selected} />; |
|
|
|
} |
|
|
|
|
|
|
|
if (mode === "llmGenerate") { |
|
|
|
return <SmartTextLlmView id={id} data={data} selected={selected} inputHandles={inputHandles} />; |
|
|
|
return <SmartTextLlmView id={id} data={data} selected={selected} />; |
|
|
|
} |
|
|
|
|
|
|
|
return <SmartTextNeutralView id={id} data={data} selected={selected} inputHandles={inputHandles} />; |
|
|
|
return <SmartTextNeutralView id={id} data={data} selected={selected} />; |
|
|
|
} |
|
|
|
|