Skip to content

Commit 85d51e7

Browse files
committed
improved streaming with openai implementations (fetch node-type has been made more reliable.. dont know yet if its 100%)
1 parent 371529a commit 85d51e7

File tree

3 files changed

+469
-43
lines changed

3 files changed

+469
-43
lines changed
Lines changed: 293 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,293 @@
1+
{
2+
"schemaType": "flow",
3+
"schemaVersion": "0.0.1",
4+
"id": "1234",
5+
"flows": {
6+
"flow": {
7+
"flowType": "flow",
8+
"nodes": [
9+
{
10+
"id": "8f4ac174-5c8e-45da-8ad4-a81a40f4f666",
11+
"x": 3705.3357978745244,
12+
"y": 1054.0469793471455,
13+
"width": 200,
14+
"height": 155,
15+
"nodeType": "Shape",
16+
"nodeInfo": {
17+
"type": "fetch",
18+
"formValues": {
19+
"url": "https://api.openai.com/v1/chat/completions",
20+
"headers": "Authorization: Bearer [openai-key]",
21+
"http-method": "post"
22+
},
23+
"isSettingsPopup": true
24+
}
25+
},
26+
{
27+
"id": "3cf44538-9913-4aa2-aade-a7c619910f45",
28+
"x": 2870.5595746525687,
29+
"y": 1063.2936725366305,
30+
"width": 161.1015625,
31+
"height": 136,
32+
"nodeType": "Shape",
33+
"nodeInfo": {
34+
"type": "json-node",
35+
"formValues": {
36+
"json": "{\n \"messages\": [\n { \n \"role\": \"user\", \n \"content\": \"Tell me a joke about visual programming in a way that bret victor approves\" \n }\n ],\n \"temperature\": 0.6,\n \"model\": \"gpt-4-turbo\",\n \"max_tokens\": 30,\n \"stream\": true\n}"
37+
},
38+
"nodeCannotBeReplaced": true,
39+
"showFormOnlyInPopup": true,
40+
"useInCompositionOnly": false,
41+
"keepPopupOpenAfterUpdate": true,
42+
"isRunOnStart": true
43+
}
44+
},
45+
{
46+
"id": "d186a002-218b-47dc-aae8-07522a3da6ed",
47+
"x": 4086.2794839807348,
48+
"y": 1055.5511660082343,
49+
"width": 119.99967430518362,
50+
"height": 272.0000282539267,
51+
"nodeType": "Shape",
52+
"nodeInfo": {
53+
"type": "show-input",
54+
"formValues": {
55+
"name": "",
56+
"data-type": "default"
57+
},
58+
"initializeOnStartFlow": true,
59+
"isSettingsPopup": true
60+
}
61+
},
62+
{
63+
"id": "383eb9cf-3b45-489e-8281-720b702b9159",
64+
"x": 3302.6185234344857,
65+
"y": 529.4952359949934,
66+
"width": 239.99994717902953,
67+
"height": 95.99996378926551,
68+
"nodeType": "Shape",
69+
"nodeInfo": {
70+
"type": "scope-variable",
71+
"formValues": {
72+
"variableName": "result",
73+
"initialValue": "",
74+
"fieldType": "array",
75+
"fieldValueType": "string",
76+
"enumValues": [],
77+
"initialEnumValue": ""
78+
},
79+
"isVariable": true,
80+
"nodeCannotBeReplaced": true
81+
}
82+
},
83+
{
84+
"id": "4ffd9779-4d78-4122-9619-ee6dcf7ee81d",
85+
"x": 5438.958340008058,
86+
"y": 1063.8909510153799,
87+
"width": 280,
88+
"height": 40,
89+
"nodeType": "Shape",
90+
"nodeInfo": {
91+
"type": "push-value-to-array-variable",
92+
"formValues": {
93+
"variableName": "result"
94+
},
95+
"nodeCannotBeReplaced": false,
96+
"showFormOnlyInPopup": true,
97+
"useInCompositionOnly": false,
98+
"keepPopupOpenAfterUpdate": false
99+
}
100+
},
101+
{
102+
"id": "24b43a64-3ba7-4c90-af25-de0da725600b",
103+
"x": 4896.59899819287,
104+
"y": 1062.3441942393213,
105+
"width": 200,
106+
"height": 100,
107+
"nodeType": "Shape",
108+
"nodeInfo": {
109+
"type": "expression",
110+
"formValues": {
111+
"expression": "choices[0].delta.content",
112+
"inputType": "number"
113+
},
114+
"showFormOnlyInPopup": true,
115+
"isSettingsPopup": true
116+
}
117+
},
118+
{
119+
"id": "bfc480ee-0c81-4221-a725-252298402221",
120+
"x": 4363.497084971121,
121+
"y": 1061.016367383506,
122+
"width": 110,
123+
"height": 110,
124+
"nodeType": "Shape",
125+
"nodeInfo": {
126+
"type": "map",
127+
"formValues": {}
128+
}
129+
},
130+
{
131+
"id": "62d6f81d-08f3-4379-8c9f-f41f3452ea52",
132+
"x": 4625.62260857533,
133+
"y": 1063.1032901616265,
134+
"width": 150,
135+
"height": 150,
136+
"nodeType": "Shape",
137+
"nodeInfo": {
138+
"type": "if-condition",
139+
"formValues": {
140+
"Mode": "expression",
141+
"expression": "choices[0].delta.role != \"assistant\" && hasContent(choices[0].delta)",
142+
"inputType": "boolean"
143+
}
144+
}
145+
},
146+
{
147+
"id": "604d00b5-69c4-4beb-8aca-394674de0d61",
148+
"x": 3778.1806630979127,
149+
"y": 1568.646609133624,
150+
"width": 260.03125,
151+
"height": 136,
152+
"nodeType": "Shape",
153+
"nodeInfo": {
154+
"type": "register-expression-function-node",
155+
"formValues": {
156+
"customFunctionCode": "(a) => {\n return a.content !== undefined;\n};",
157+
"functionName": "hasContent"
158+
},
159+
"nodeCannotBeReplaced": true,
160+
"showFormOnlyInPopup": true,
161+
"useInCompositionOnly": false,
162+
"keepPopupOpenAfterUpdate": true,
163+
"isRunOnStart": true
164+
}
165+
},
166+
{
167+
"id": "2a227359-4016-4fa7-9788-948030bc0e90",
168+
"x": 3287.9477488867783,
169+
"y": 1054.0470154874329,
170+
"width": 200,
171+
"height": 128,
172+
"nodeType": "Shape",
173+
"nodeInfo": {
174+
"type": "reset-variable",
175+
"formValues": {
176+
"variableName": "result"
177+
},
178+
"nodeCannotBeReplaced": false,
179+
"showFormOnlyInPopup": false,
180+
"useInCompositionOnly": false,
181+
"keepPopupOpenAfterUpdate": false
182+
}
183+
},
184+
{
185+
"id": "1a35b609-3594-4529-bec1-2b50b205aa0d",
186+
"x": 3031.6611371525687,
187+
"y": 1131.2936725366305,
188+
"endX": 3287.9477488867783,
189+
"endY": 1118.0470154874329,
190+
"startNodeId": "3cf44538-9913-4aa2-aade-a7c619910f45",
191+
"endNodeId": "2a227359-4016-4fa7-9788-948030bc0e90",
192+
"startThumbName": "input",
193+
"endThumbName": "input",
194+
"lineType": "BezierCubic",
195+
"nodeType": "Connection",
196+
"layer": 1,
197+
"nodeInfo": {}
198+
},
199+
{
200+
"id": "a16c5c54-c867-41af-a922-9a014786c513",
201+
"x": 3905.3357978745244,
202+
"y": 1084.0469793471455,
203+
"endX": 4086.2794839807348,
204+
"endY": 1085.5511660082343,
205+
"startNodeId": "8f4ac174-5c8e-45da-8ad4-a81a40f4f666",
206+
"endNodeId": "d186a002-218b-47dc-aae8-07522a3da6ed",
207+
"startThumbName": "output",
208+
"endThumbName": "input",
209+
"lineType": "BezierCubic",
210+
"nodeType": "Connection",
211+
"layer": 1,
212+
"nodeInfo": {}
213+
},
214+
{
215+
"id": "9c9efadf-8473-439f-849b-1fa8cbc09ad5",
216+
"x": 4206.279158285918,
217+
"y": 1085.5511660082343,
218+
"endX": 4363.497084971121,
219+
"endY": 1116.016367383506,
220+
"startNodeId": "d186a002-218b-47dc-aae8-07522a3da6ed",
221+
"endNodeId": "bfc480ee-0c81-4221-a725-252298402221",
222+
"startThumbName": "output",
223+
"endThumbName": "input",
224+
"lineType": "BezierCubic",
225+
"nodeType": "Connection",
226+
"layer": 1,
227+
"nodeInfo": {}
228+
},
229+
{
230+
"id": "782908ad-a7fc-4086-b2d0-8491bb9bafa9",
231+
"x": 5096.59899819287,
232+
"y": 1112.3441942393213,
233+
"endX": 5438.958340008058,
234+
"endY": 1083.8909510153799,
235+
"startNodeId": "24b43a64-3ba7-4c90-af25-de0da725600b",
236+
"endNodeId": "4ffd9779-4d78-4122-9619-ee6dcf7ee81d",
237+
"startThumbName": "output",
238+
"endThumbName": "value",
239+
"lineType": "BezierCubic",
240+
"nodeType": "Connection",
241+
"layer": 1,
242+
"nodeInfo": {}
243+
},
244+
{
245+
"id": "441e2ae8-bb43-4d98-b5c2-73b5d33f1884",
246+
"x": 4473.497084971121,
247+
"y": 1141.016367383506,
248+
"endX": 4625.62260857533,
249+
"endY": 1138.1032901616265,
250+
"startNodeId": "bfc480ee-0c81-4221-a725-252298402221",
251+
"endNodeId": "62d6f81d-08f3-4379-8c9f-f41f3452ea52",
252+
"startThumbName": "output2",
253+
"endThumbName": "input",
254+
"lineType": "BezierCubic",
255+
"nodeType": "Connection",
256+
"layer": 1,
257+
"nodeInfo": {}
258+
},
259+
{
260+
"id": "3766e220-8955-4981-9ea5-94bd56926cc1",
261+
"x": 4700.62260857533,
262+
"y": 1063.1032901616265,
263+
"endX": 4896.59899819287,
264+
"endY": 1112.3441942393213,
265+
"startNodeId": "62d6f81d-08f3-4379-8c9f-f41f3452ea52",
266+
"endNodeId": "24b43a64-3ba7-4c90-af25-de0da725600b",
267+
"startThumbName": "success",
268+
"endThumbName": "input",
269+
"lineType": "BezierCubic",
270+
"nodeType": "Connection",
271+
"layer": 1,
272+
"nodeInfo": {}
273+
},
274+
{
275+
"id": "b58697e4-82bf-4d83-917a-03be6daedc12",
276+
"x": 3487.9477488867783,
277+
"y": 1118.0470154874329,
278+
"endX": 3705.3357978745244,
279+
"endY": 1131.5469793471455,
280+
"startNodeId": "2a227359-4016-4fa7-9788-948030bc0e90",
281+
"endNodeId": "8f4ac174-5c8e-45da-8ad4-a81a40f4f666",
282+
"startThumbName": "output",
283+
"endThumbName": "input",
284+
"lineType": "BezierCubic",
285+
"nodeType": "Connection",
286+
"layer": 1,
287+
"nodeInfo": {}
288+
}
289+
]
290+
}
291+
},
292+
"compositions": {}
293+
}

0 commit comments

Comments
 (0)