Merge branch 'refs/heads/develop' into fix/memory_bug_fix

This commit is contained in:
lixinyue
2026-01-14 14:47:15 +08:00
5 changed files with 61 additions and 45 deletions

View File

@@ -583,7 +583,7 @@ async def chat(
event_data = event.get("data", {}) event_data = event.get("data", {})
# 转换为标准 SSE 格式(字符串) # 转换为标准 SSE 格式(字符串)
sse_message = f"event: {event_type}\ndata: {json.dumps(event_data)}\n\n" sse_message = f"event: {event_type}\ndata: {json.dumps(event_data, default=str, ensure_ascii=False)}\n\n"
yield sse_message yield sse_message
return StreamingResponse( return StreamingResponse(

View File

@@ -226,6 +226,7 @@ class LLMNode(BaseNode):
Yields: Yields:
文本片段chunk或完成标记 文本片段chunk或完成标记
""" """
self.typed_config = LLMNodeConfig(**self.config)
from langgraph.config import get_stream_writer from langgraph.config import get_stream_writer
llm, prompt_or_messages = self._prepare_llm(state, True) llm, prompt_or_messages = self._prepare_llm(state, True)

View File

@@ -1416,11 +1416,10 @@ async def analytics_graph_data(
elementId(n) as id, elementId(n) as id,
labels(n)[0] as label, labels(n)[0] as label,
properties(n) as properties properties(n) as properties
LIMIT $limit
""" """
node_params = { node_params = {
"group_id": end_user_id, "group_id": end_user_id,
"limit": limit # "limit": limit
} }
# 执行节点查询 # 执行节点查询

View File

@@ -502,16 +502,44 @@ interface NodeConfig {
ports?: PortsConfig; ports?: PortsConfig;
} }
const portAttrs = { // 统一的端口 markup 配置
circle: { export const portMarkup = [
r: 4, magnet: true, stroke: '#155EEF', strokeWidth: 2, fill: '#155EEF', position: { top: 22 } {
tagName: 'circle',
selector: 'body',
}, },
{
tagName: 'text',
selector: 'label',
},
];
// 统一的端口属性配置
export const portAttrs = {
body: {
r: 6,
magnet: true,
stroke: '#155EEF',
strokeWidth: 2,
fill: '#155EEF',
},
label: {
text: '+',
fontSize: 12,
fontWeight: 'bold',
fill: '#FFFFFF',
textAnchor: 'middle',
textVerticalAnchor: 'middle',
pointerEvents: 'none',
}
} }
// 统一的端口组配置
const defaultPortGroups = { const defaultPortGroups = {
// top: { position: 'top', attrs: portAttrs }, // top: { position: 'top', markup: portMarkup, attrs: portAttrs },
right: { position: 'right', attrs: portAttrs }, right: { position: 'right', markup: portMarkup, attrs: portAttrs },
// bottom: { position: 'bottom', attrs: portAttrs }, // bottom: { position: 'bottom', markup: portMarkup, attrs: portAttrs },
left: { position: 'left', attrs: portAttrs }, left: { position: 'left', markup: portMarkup, attrs: portAttrs },
} }
const defaultPortItems = [ const defaultPortItems = [
// { group: 'top' }, // { group: 'top' },
@@ -569,7 +597,7 @@ export const graphNodeLibrary: Record<string, NodeConfig> = {
height: 64, height: 64,
shape: 'normal-node', shape: 'normal-node',
ports: { ports: {
groups: {right: { position: 'right', attrs: portAttrs }}, groups: {right: { position: 'right', markup: portMarkup, attrs: portAttrs }},
items: [{ group: 'right' }], items: [{ group: 'right' }],
}, },
}, },
@@ -578,7 +606,7 @@ export const graphNodeLibrary: Record<string, NodeConfig> = {
height: 64, height: 64,
shape: 'normal-node', shape: 'normal-node',
ports: { ports: {
groups: {left: { position: 'left', attrs: portAttrs }}, groups: {left: { position: 'left', markup: portMarkup, attrs: portAttrs }},
items: [{ group: 'left' }], items: [{ group: 'left' }],
}, },
}, },
@@ -587,7 +615,7 @@ export const graphNodeLibrary: Record<string, NodeConfig> = {
height: 44, height: 44,
shape: 'cycle-start', shape: 'cycle-start',
ports: { ports: {
groups: {right: { position: 'right', attrs: portAttrs }}, groups: {right: { position: 'right', markup: portMarkup, attrs: portAttrs }},
items: [{ group: 'right' }], items: [{ group: 'right' }],
}, },
}, },
@@ -596,7 +624,7 @@ export const graphNodeLibrary: Record<string, NodeConfig> = {
height: 44, height: 44,
shape: 'add-node', shape: 'add-node',
ports: { ports: {
groups: {left: { position: 'left', attrs: portAttrs }}, groups: {left: { position: 'left', markup: portMarkup, attrs: portAttrs }},
items: [{ group: 'left' }], items: [{ group: 'left' }],
}, },
}, },
@@ -614,7 +642,7 @@ export const graphNodeLibrary: Record<string, NodeConfig> = {
height: 44, height: 44,
shape: 'cycle-start', shape: 'cycle-start',
ports: { ports: {
groups: {right: { position: 'right', attrs: portAttrs }}, groups: {right: { position: 'right', markup: portMarkup, attrs: portAttrs }},
items: [{ group: 'right' }], items: [{ group: 'right' }],
}, },
}, },
@@ -623,7 +651,7 @@ export const graphNodeLibrary: Record<string, NodeConfig> = {
height: 44, height: 44,
shape: 'add-node', shape: 'add-node',
ports: { ports: {
groups: {left: { position: 'left', attrs: portAttrs }}, groups: {left: { position: 'left', markup: portMarkup, attrs: portAttrs }},
items: [{ group: 'left' }], items: [{ group: 'left' }],
}, },
} }

View File

@@ -5,7 +5,7 @@ import { App } from 'antd'
import { Graph, Node, MiniMap, Snapline, Clipboard, Keyboard, type Edge } from '@antv/x6'; import { Graph, Node, MiniMap, Snapline, Clipboard, Keyboard, type Edge } from '@antv/x6';
import { register } from '@antv/x6-react-shape'; import { register } from '@antv/x6-react-shape';
import { nodeRegisterLibrary, graphNodeLibrary, nodeLibrary } from '../constant'; import { nodeRegisterLibrary, graphNodeLibrary, nodeLibrary, portMarkup, portAttrs } from '../constant';
import type { WorkflowConfig, NodeProperties } from '../types'; import type { WorkflowConfig, NodeProperties } from '../types';
import { getWorkflowConfig, saveWorkflowConfig } from '@/api/application' import { getWorkflowConfig, saveWorkflowConfig } from '@/api/application'
import type { PortMetadata } from '@antv/x6/lib/model/port'; import type { PortMetadata } from '@antv/x6/lib/model/port';
@@ -39,7 +39,6 @@ export interface UseWorkflowGraphReturn {
export const edge_color = '#155EEF'; export const edge_color = '#155EEF';
const edge_selected_color = '#4DA8FF' const edge_selected_color = '#4DA8FF'
export const useWorkflowGraph = ({ export const useWorkflowGraph = ({
containerRef, containerRef,
miniMapRef, miniMapRef,
@@ -128,12 +127,6 @@ export const useWorkflowGraph = ({
const baseHeight = 88; const baseHeight = 88;
const newHeight = baseHeight + (totalPorts - 2) * 30; const newHeight = baseHeight + (totalPorts - 2) * 30;
const portAttrs = {
circle: {
r: 4, magnet: true, stroke: '#155EEF', strokeWidth: 2, fill: '#155EEF', position: { top: 22 }
},
};
const portItems: PortMetadata[] = [ const portItems: PortMetadata[] = [
{ group: 'left' }, { group: 'left' },
{ group: 'right', id: 'CASE1', args: { dy: 24 }, attrs: { text: { text: 'IF', fontSize: 12, fill: '#5B6167' }} } { group: 'right', id: 'CASE1', args: { dy: 24 }, attrs: { text: { text: 'IF', fontSize: 12, fill: '#5B6167' }} }
@@ -157,8 +150,8 @@ export const useWorkflowGraph = ({
nodeConfig.ports = { nodeConfig.ports = {
groups: { groups: {
right: { position: 'right', attrs: portAttrs }, right: { position: 'right', markup: portMarkup, attrs: portAttrs },
left: { position: 'left', attrs: portAttrs }, left: { position: 'left', markup: portMarkup, attrs: portAttrs },
}, },
items: portItems items: portItems
}; };
@@ -172,12 +165,6 @@ export const useWorkflowGraph = ({
const baseHeight = 88; const baseHeight = 88;
const newHeight = baseHeight + (categoryCount - 1) * 30; const newHeight = baseHeight + (categoryCount - 1) * 30;
const portAttrs = {
circle: {
r: 4, magnet: true, stroke: '#155EEF', strokeWidth: 2, fill: '#155EEF', position: { top: 22 }
},
};
const portItems: PortMetadata[] = [ const portItems: PortMetadata[] = [
{ group: 'left' } { group: 'left' }
]; ];
@@ -194,8 +181,8 @@ export const useWorkflowGraph = ({
nodeConfig.ports = { nodeConfig.ports = {
groups: { groups: {
right: { position: 'right', attrs: portAttrs }, right: { position: 'right', markup: portMarkup, attrs: portAttrs },
left: { position: 'left', attrs: portAttrs }, left: { position: 'left', markup: portMarkup, attrs: portAttrs },
}, },
items: portItems items: portItems
}; };
@@ -205,16 +192,10 @@ export const useWorkflowGraph = ({
// 如果是http-request节点检查error_handle.method配置 // 如果是http-request节点检查error_handle.method配置
if (type === 'http-request' && (config as any).error_handle?.method === 'branch') { if (type === 'http-request' && (config as any).error_handle?.method === 'branch') {
const portAttrs = {
circle: {
r: 4, magnet: true, stroke: '#155EEF', strokeWidth: 2, fill: '#155EEF', position: { top: 22 }
},
};
nodeConfig.ports = { nodeConfig.ports = {
groups: { groups: {
right: { position: 'right', attrs: portAttrs }, right: { position: 'right', markup: portMarkup, attrs: portAttrs },
left: { position: 'left', attrs: portAttrs }, left: { position: 'left', markup: portMarkup, attrs: portAttrs },
}, },
items: [ items: [
{ group: 'left' }, { group: 'left' },
@@ -344,13 +325,15 @@ export const useWorkflowGraph = ({
cell: targetCell.id, cell: targetCell.id,
port: targetPorts.find((port: any) => port.group === 'left')?.id || 'left' port: targetPorts.find((port: any) => port.group === 'left')?.id || 'left'
}, },
connector: { name: 'smooth' },
attrs: { attrs: {
line: { line: {
stroke: edge_color, stroke: edge_color,
strokeWidth: 1, strokeWidth: 1,
targetMarker: { targetMarker: {
name: 'block', name: 'diamond',
size: 8, width: 4,
height: 4,
}, },
}, },
}, },
@@ -703,7 +686,7 @@ export const useWorkflowGraph = ({
// router: 'orth', // router: 'orth',
// router: 'manhattan', // router: 'manhattan',
connector: { connector: {
name: 'rounded', name: 'smooth',
args: { args: {
radius: 8, radius: 8,
}, },
@@ -723,6 +706,11 @@ export const useWorkflowGraph = ({
line: { line: {
stroke: edge_color, stroke: edge_color,
strokeWidth: 1, strokeWidth: 1,
targetMarker: {
name: 'diamond',
width: 4,
height: 4,
},
}, },
}, },
zIndex: 0, zIndex: 0,