From d9868550e66fe8aaa7fff55a8e24b871ee51e3b1 Mon Sep 17 00:00:00 2001 From: blackhao <13851610112@163.com> Date: Fri, 5 Dec 2025 20:40:40 -0600 Subject: init: add project files and ignore secrets --- frontend/src/App.tsx | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 frontend/src/App.tsx (limited to 'frontend/src/App.tsx') diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx new file mode 100644 index 0000000..1eaafec --- /dev/null +++ b/frontend/src/App.tsx @@ -0,0 +1,138 @@ +import { useCallback, useRef } from 'react'; +import ReactFlow, { + Background, + Controls, + MiniMap, + ReactFlowProvider, + Panel, + useReactFlow +} from 'reactflow'; +import 'reactflow/dist/style.css'; +import useFlowStore from './store/flowStore'; +import LLMNode from './components/nodes/LLMNode'; +import Sidebar from './components/Sidebar'; +import { Plus } from 'lucide-react'; + +const nodeTypes = { + llmNode: LLMNode, +}; + +function Flow() { + const { + nodes, + edges, + onNodesChange, + onEdgesChange, + onConnect, + addNode, + setSelectedNode + } = useFlowStore(); + + const reactFlowWrapper = useRef(null); + const { project } = useReactFlow(); + + const handleAddNode = () => { + const id = `node_${Date.now()}`; + addNode({ + id, + type: 'llmNode', + position: { x: Math.random() * 400, y: Math.random() * 400 }, + data: { + label: 'New Question', + model: 'gpt-4o', + temperature: 0.7, + systemPrompt: '', + userPrompt: '', + mergeStrategy: 'smart', + messages: [], + traces: [], + outgoingTraces: [], + forkedTraces: [], + response: '', + status: 'idle', + inputs: 1 + }, + }); + }; + + const onNodeClick = (_: any, node: any) => { + setSelectedNode(node.id); + }; + + const onPaneClick = () => { + setSelectedNode(null); + }; + + const onPaneContextMenu = (event: React.MouseEvent) => { + event.preventDefault(); + const bounds = reactFlowWrapper.current?.getBoundingClientRect(); + if (!bounds) return; + + const position = project({ + x: event.clientX - bounds.left, + y: event.clientY - bounds.top + }); + + const id = `node_${Date.now()}`; + addNode({ + id, + type: 'llmNode', + position, + data: { + label: 'New Question', + model: 'gpt-4o', + temperature: 0.7, + systemPrompt: '', + userPrompt: '', + mergeStrategy: 'smart', + messages: [], + traces: [], + outgoingTraces: [], + forkedTraces: [], + response: '', + status: 'idle', + inputs: 1 + }, + }); + }; + + return ( +
+
+ + + + + + + + +
+ +
+ ); +} + +export default function App() { + return ( + + + + ); +} -- cgit v1.2.3