Skip to content

Commit 6f6b0f0

Browse files
authored
Merge pull request #150 from badaitech/feat/okx-llm-nodes
Fix stream port UI
2 parents ca2bacb + a083165 commit 6f6b0f0

19 files changed

Lines changed: 138 additions & 10 deletions

File tree

apps/chaingraph-backend/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# @badaitech/chaingraph-backend
22

3+
## 0.1.25
4+
5+
### Patch Changes
6+
7+
- Fix stream port UI
8+
- Updated dependencies
9+
- @badaitech/chaingraph-nodes@0.1.25
10+
- @badaitech/chaingraph-types@0.1.25
11+
- @badaitech/chaingraph-trpc@0.1.25
12+
313
## 0.1.24
414

515
### Patch Changes

apps/chaingraph-backend/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ RUN turbo prune "@badaitech/chaingraph-backend" --docker
1313
# Second stage: Install dependencies and build
1414
FROM base AS builder
1515

16+
ENV NODE_OPTIONS="--max-old-space-size=8192"
17+
1618
COPY --from=pruner /app/out/json/ .
1719
COPY --from=pruner /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
1820

apps/chaingraph-backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@badaitech/chaingraph-backend",
33
"type": "module",
4-
"version": "0.1.24",
4+
"version": "0.1.25",
55
"private": false,
66
"description": "Backend server for the Chaingraph project",
77
"license": "BUSL-1.1",

apps/chaingraph-frontend/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# @badaitech/chaingraph-frontend
22

3+
## 0.1.25
4+
5+
### Patch Changes
6+
7+
- Fix stream port UI
8+
- Updated dependencies
9+
- @badaitech/chaingraph-nodes@0.1.25
10+
- @badaitech/chaingraph-types@0.1.25
11+
- @badaitech/chaingraph-trpc@0.1.25
12+
- @badaitech/badai-api@0.1.25
13+
314
## 0.1.24
415

516
### Patch Changes

apps/chaingraph-frontend/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ RUN turbo prune "@badaitech/chaingraph-frontend" --docker
1414
FROM base AS builder
1515

1616
ARG NODE_ENV=production
17+
ENV NODE_OPTIONS="--max-old-space-size=8192"
1718

1819
COPY --from=pruner /app/out/json/ .
1920
COPY --from=pruner /app/out/pnpm-lock.yaml ./pnpm-lock.yaml

apps/chaingraph-frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@badaitech/chaingraph-frontend",
33
"type": "module",
4-
"version": "0.1.24",
4+
"version": "0.1.25",
55
"private": false,
66
"description": "Frontend application for the Chaingraph project",
77
"license": "BUSL-1.1",

apps/chaingraph-frontend/src/components/flow/nodes/ChaingraphNode/PortComponent.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,19 @@ import type {
1818
IPort,
1919
NumberPortConfig,
2020
ObjectPortConfig,
21+
StreamPortConfig,
2122
StringPortConfig,
2223
} from '@badaitech/chaingraph-types'
2324
import { BooleanPort } from '@/components/flow/nodes/ChaingraphNode/ports/BooleanPort/BooleanPort'
2425
import { NumberPort } from '@/components/flow/nodes/ChaingraphNode/ports/NumberPort/NumberPort'
2526
import { ObjectPort } from '@/components/flow/nodes/ChaingraphNode/ports/ObjectPort/ObjectPort'
2627

28+
import { StreamPort } from '@/components/flow/nodes/ChaingraphNode/ports/StreamPort/StreamPort'
2729
import { AnyPort } from 'components/flow/nodes/ChaingraphNode/ports/AnyPort/AnyPort'
2830
import { ArrayPort } from './ports/ArrayPort/ArrayPort'
2931
import { PortContext } from './ports/context/PortContext'
3032
import { EnumPort } from './ports/EnumPort/EnumPort'
3133
import { StringPort } from './ports/StringPort/StringPort'
32-
import { StubPort } from './ports/StubPort/StubPort'
3334

3435
/**
3536
* PortProps interface for all components rendered through PortComponent
@@ -103,7 +104,7 @@ export function PortComponent(props: PortProps) {
103104
}
104105

105106
case 'stream': {
106-
return <StubPort port={port} />
107+
return <StreamPort node={node} port={port as IPort<StreamPortConfig>} context={context} />
107108
}
108109

109110
default: {
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Copyright (c) 2025 BadLabs
3+
*
4+
* Use of this software is governed by the Business Source License 1.1 included in the file LICENSE.txt.
5+
*
6+
* As of the Change Date specified in that file, in accordance with the Business Source License, use of this software will be governed by the Apache License, version 2.0.
7+
*/
8+
9+
import type {
10+
PortContextValue,
11+
} from '@/components/flow/nodes/ChaingraphNode/ports/context/PortContext'
12+
/*
13+
* Copyright (c) 2025 BadLabs
14+
*
15+
* Use of this software is governed by the Business Source License 1.1 included in the file LICENSE.txt.
16+
*
17+
* As of the Change Date specified in that file, in accordance with the Business Source License, use of this software will be governed by the Apache License, version 2.0.
18+
*/
19+
import type { INode, IPort, StreamPortConfig } from '@badaitech/chaingraph-types'
20+
import { cn } from '@/lib/utils'
21+
import { memo } from 'react'
22+
import { PortHandle } from '../ui/PortHandle'
23+
import { PortTitle } from '../ui/PortTitle'
24+
25+
export interface StreamPortProps {
26+
node: INode
27+
port: IPort<StreamPortConfig>
28+
context: PortContextValue
29+
}
30+
31+
function StreamPortComponent(props: StreamPortProps) {
32+
const { port, context } = props
33+
34+
const config = port.getConfig()
35+
const ui = config.ui
36+
const title = config.title || config.key
37+
38+
if (ui?.hidden)
39+
return null
40+
41+
return (
42+
<div
43+
key={config.id}
44+
className={cn(
45+
'relative flex gap-2 group/port',
46+
config.direction === 'output' ? 'justify-end' : 'justify-start',
47+
)}
48+
>
49+
{config.direction === 'input' && <PortHandle port={port} />}
50+
51+
<div className={cn(
52+
'flex flex-col',
53+
config.direction === 'output' ? 'items-end' : 'items-start',
54+
'truncate',
55+
)}
56+
>
57+
<PortTitle>
58+
{title}
59+
</PortTitle>
60+
</div>
61+
62+
{config.direction === 'output' && <PortHandle port={port} />}
63+
</div>
64+
)
65+
}
66+
67+
// Export a memoized version of the component to prevent unnecessary re-renders
68+
export const StreamPort = memo(StreamPortComponent)

apps/chaingraph-frontend/src/components/flow/nodes/ChaingraphNode/ports/StubPort/StubPort.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ export function StubPort<C extends IPortConfig>(props: { port: IPort<C> }) {
2626
'relative flex items-center gap-2 group/port',
2727
config.direction === 'output' ? 'justify-end' : 'justify-start',
2828
'truncate',
29+
'h-20',
2930
)}
3031
>
3132
{config.direction === 'output' && (
32-
<PortTitle>{title}</PortTitle>
33+
<PortTitle>
34+
{title}
35+
</PortTitle>
3336
)}
3437

3538
<PortHandle port={port} />

packages/badai-api/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @badaitech/badai-api
22

3+
## 0.1.25
4+
5+
### Patch Changes
6+
7+
- Fix stream port UI
8+
39
## 0.1.24
410

511
### Patch Changes

0 commit comments

Comments
 (0)