Skip to content

Commit e2b263e

Browse files
committed
json mapper and improved fetch and openAI chat
1 parent ec43eac commit e2b263e

File tree

19 files changed

+1074
-118
lines changed

19 files changed

+1074
-118
lines changed

apps/vps-web/src/main.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,29 @@ if (url.pathname === '/run-flow') {
4747
container = document.getElementById(
4848
`${formId}_${formField.fieldName}__html`
4949
);
50-
if (!container) return;
50+
const popupContainer = document.getElementById('textAreaContainer');
51+
if (!container || !popupContainer) return;
5152

5253
const resizeObserver = new ResizeObserver((_entries) => {
54+
console.log('resizeObserver');
5355
if (editorInstance) {
5456
editorInstance.layout();
5557
}
5658
});
5759

58-
resizeObserver.observe(container);
60+
resizeObserver.observe(popupContainer);
61+
console.log('INIT MONACO EDITOR', popupContainer, container);
62+
// const containerObserver = new MutationObserver((_entries) => {
63+
// console.log('resizeObserver');
64+
// if (editorInstance) {
65+
// editorInstance.layout();
66+
// }
67+
// });
68+
// containerObserver.observe(popupContainer, {
69+
// childList: true,
70+
// subtree: true,
71+
// });
72+
5973
const editor = monaco.editor.create(container, {
6074
fixedOverflowWidgets: true,
6175
value: (formField.value ?? '').toString(),

apps/vps-web/src/styles.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,9 +728,13 @@ html:active-view-transition-type(normal) {
728728
.code-editor {
729729
width: 100%;
730730
height: 320px;
731+
min-height: 320px;
731732
transition: height var(--popup-fullscreen-duration)
732733
var(--popup-fullscreen-timing-function);
733734
/*height: 100%;*/
735+
736+
display: grid;
737+
grid-template-rows: auto 1fr;
734738
}
735739
.fullscreen .code-editor {
736740
height: calc(100vh - 110px);

archive/json-map-language.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"@map": {
3+
"@comment": "this maps input.messages to messages",
4+
"input": "@input",
5+
"property": "messages",
6+
"map": {
7+
"type": "object",
8+
"properties": {
9+
"@set:role": "@item.role",
10+
"@set:content": "@item.message"
11+
}
12+
}
13+
},
14+
"@comment": "this sets the name property to the value of payload['input-property-name']",
15+
"@set:name": "input-property-name",
16+
"@operation:object": {
17+
"@comment": "this creates an object testtest with properties abc, list",
18+
"input": "@input.test",
19+
"property": "testtest",
20+
"properties": {
21+
"abc": "def",
22+
"@set:something": "@item.something",
23+
"@operation:map": {
24+
"input": "@item",
25+
"property": "list",
26+
"map": {
27+
"type": "object",
28+
"properties": {
29+
"@set:name": "@item.name",
30+
"@set:description": "@item.description",
31+
"@set:combined": "@template:@item.name - @item.description"
32+
}
33+
}
34+
}
35+
}
36+
}
37+
}

archive/openai.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"@operation:map": {
3+
"input": "@input",
4+
"property": "messages",
5+
"map": {
6+
"type": "object",
7+
"properties": {
8+
"@set:role": "@item.role",
9+
"@set:content": "@item.message"
10+
}
11+
}
12+
},
13+
"messages": [
14+
{
15+
"role": "system",
16+
"content": "Hello! I'm a chatbot. How can I help you today?"
17+
},
18+
{
19+
"role": "user"
20+
},
21+
{
22+
"role": "assistant"
23+
},
24+
{
25+
"role": "user",
26+
"content": "{{input}}"
27+
}
28+
],
29+
"temperature": 0.6,
30+
"model": "gpt-4-turbo",
31+
"max_tokens": 30,
32+
"stream": true
33+
}

examples-test-flows/openai-fetch-completion-as-stream.json

Lines changed: 76 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"x": 3705.3356695038824,
1212
"y": 1054.0469817505104,
1313
"width": 200,
14-
"height": 155,
14+
"height": 205,
1515
"nodeType": "Shape",
1616
"nodeInfo": {
1717
"type": "fetch",
@@ -25,15 +25,15 @@
2525
},
2626
{
2727
"id": "3cf44538-9913-4aa2-aade-a7c619910f45",
28-
"x": 2870.237434699719,
29-
"y": 1063.2936656401973,
30-
"width": 161.1015625,
31-
"height": 136,
28+
"x": 2870.2376315349347,
29+
"y": 1063.2936853877577,
30+
"width": 178.5078125,
31+
"height": 80,
3232
"nodeType": "Shape",
3333
"nodeInfo": {
3434
"type": "json-node",
3535
"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}"
36+
"json": "{\n \"messages\": [\n { \n \"role\": \"user\", \n \"@set:content\": \"input\" \n }\n ],\n \"temperature\": 0.6,\n \"model\": \"gpt-4-turbo\",\n \"max_tokens\": 30,\n \"stream\": true\n}"
3737
},
3838
"nodeCannotBeReplaced": true,
3939
"showFormOnlyInPopup": true,
@@ -44,10 +44,10 @@
4444
},
4545
{
4646
"id": "d186a002-218b-47dc-aae8-07522a3da6ed",
47-
"x": 4086.2794839807348,
48-
"y": 1055.5511660082343,
49-
"width": 119.9999294340761,
50-
"height": 272.00006892594394,
47+
"x": 4086.27967757153,
48+
"y": 1055.5510998151515,
49+
"width": 119.99999053099201,
50+
"height": 272.00005831671666,
5151
"nodeType": "Shape",
5252
"nodeInfo": {
5353
"type": "show-input",
@@ -63,8 +63,8 @@
6363
"id": "383eb9cf-3b45-489e-8281-720b702b9159",
6464
"x": 3302.6185234344857,
6565
"y": 529.4952359949934,
66-
"width": 240.0000734388129,
67-
"height": 95.99998646139302,
66+
"width": 240.0001805114876,
67+
"height": 216.00002284568635,
6868
"nodeType": "Shape",
6969
"nodeInfo": {
7070
"type": "scope-variable",
@@ -183,10 +183,10 @@
183183
},
184184
{
185185
"id": "38a6cf26-b1c4-460d-92b0-86656e215a5a",
186-
"x": 4930.955909075822,
187-
"y": 626.8231157984133,
186+
"x": 4565.740576144995,
187+
"y": 1418.0005507561987,
188188
"width": 200,
189-
"height": 96,
189+
"height": 128,
190190
"nodeType": "Shape",
191191
"nodeInfo": {
192192
"type": "join-array",
@@ -201,10 +201,10 @@
201201
},
202202
{
203203
"id": "b936e1cd-134c-4476-b412-342c7d89c762",
204-
"x": 5483.973522524997,
205-
"y": 643.887255157914,
206-
"width": 119.9999294340761,
207-
"height": 56.00004574514444,
204+
"x": 5118.75836670038,
205+
"y": 1435.0647024699165,
206+
"width": 119.99999053099201,
207+
"height": 223.9999424346177,
208208
"nodeType": "Shape",
209209
"nodeInfo": {
210210
"type": "show-input",
@@ -218,8 +218,8 @@
218218
},
219219
{
220220
"id": "471f94ef-642e-4065-9b19-600e87184b0c",
221-
"x": 4578.4913247279355,
222-
"y": 654.9053277392578,
221+
"x": 4213.2760145580105,
222+
"y": 1446.0828093084283,
223223
"width": 200,
224224
"height": 64,
225225
"nodeType": "Shape",
@@ -234,10 +234,29 @@
234234
"keepPopupOpenAfterUpdate": false
235235
}
236236
},
237+
{
238+
"id": "6631fbab-1a06-4f8e-9abc-ee8ac2c3f923",
239+
"x": 2243.6771759113494,
240+
"y": 1047.0934728314523,
241+
"width": 434.54733649065247,
242+
"height": 185.8378093625031,
243+
"nodeType": "Shape",
244+
"nodeInfo": {
245+
"type": "user-text-input",
246+
"formValues": {
247+
"label": "chat message",
248+
"value": "",
249+
"name": "",
250+
"group": ""
251+
},
252+
"isSettingsPopup": true,
253+
"isUINode": true
254+
}
255+
},
237256
{
238257
"id": "1a35b609-3594-4529-bec1-2b50b205aa0d",
239-
"x": 3031.338997199719,
240-
"y": 1131.2936656401973,
258+
"x": 2870.2376315349347,
259+
"y": 1103.2936853877577,
241260
"endX": 3287.9477754176096,
242261
"endY": 1118.0469817505104,
243262
"startNodeId": "3cf44538-9913-4aa2-aade-a7c619910f45",
@@ -253,8 +272,8 @@
253272
"id": "a16c5c54-c867-41af-a922-9a014786c513",
254273
"x": 3905.3356695038824,
255274
"y": 1084.0469817505104,
256-
"endX": 4086.2794839807348,
257-
"endY": 1085.5511660082343,
275+
"endX": 4086.27967757153,
276+
"endY": 1085.5510998151515,
258277
"startNodeId": "8f4ac174-5c8e-45da-8ad4-a81a40f4f666",
259278
"endNodeId": "d186a002-218b-47dc-aae8-07522a3da6ed",
260279
"startThumbName": "output",
@@ -266,8 +285,8 @@
266285
},
267286
{
268287
"id": "9c9efadf-8473-439f-849b-1fa8cbc09ad5",
269-
"x": 4206.279413414811,
270-
"y": 1085.5511660082343,
288+
"x": 4206.279668102522,
289+
"y": 1085.5510998151515,
271290
"endX": 4363.497086195699,
272291
"endY": 1116.0164055112382,
273292
"startNodeId": "d186a002-218b-47dc-aae8-07522a3da6ed",
@@ -329,7 +348,7 @@
329348
"x": 3487.9477754176096,
330349
"y": 1118.0469817505104,
331350
"endX": 3705.3356695038824,
332-
"endY": 1131.5469817505104,
351+
"endY": 1156.5469817505104,
333352
"startNodeId": "2a227359-4016-4fa7-9788-948030bc0e90",
334353
"endNodeId": "8f4ac174-5c8e-45da-8ad4-a81a40f4f666",
335354
"startThumbName": "output",
@@ -341,13 +360,13 @@
341360
},
342361
{
343362
"id": "0dd730cc-1691-454f-868c-cb19da250699",
344-
"x": 4473.497086195699,
345-
"y": 1091.0164055112382,
346-
"endX": 4578.4913247279355,
347-
"endY": 686.9053277392578,
348-
"startNodeId": "bfc480ee-0c81-4221-a725-252298402221",
363+
"x": 3905.3356695038824,
364+
"y": 1234.0469817505104,
365+
"endX": 4213.2760145580105,
366+
"endY": 1478.0828093084283,
367+
"startNodeId": "8f4ac174-5c8e-45da-8ad4-a81a40f4f666",
349368
"endNodeId": "471f94ef-642e-4065-9b19-600e87184b0c",
350-
"startThumbName": "output1",
369+
"startThumbName": "end",
351370
"endThumbName": "input",
352371
"lineType": "BezierCubic",
353372
"nodeType": "Connection",
@@ -356,10 +375,10 @@
356375
},
357376
{
358377
"id": "e93c6ee9-f78f-40b0-94ef-d16b06126c68",
359-
"x": 5130.955909075822,
360-
"y": 674.8231157984133,
361-
"endX": 5483.973522524997,
362-
"endY": 673.887255157914,
378+
"x": 4765.740576144995,
379+
"y": 1482.0005507561987,
380+
"endX": 5118.75836670038,
381+
"endY": 1465.0647024699165,
363382
"startNodeId": "38a6cf26-b1c4-460d-92b0-86656e215a5a",
364383
"endNodeId": "b936e1cd-134c-4476-b412-342c7d89c762",
365384
"startThumbName": "output",
@@ -371,10 +390,10 @@
371390
},
372391
{
373392
"id": "31caf385-4ad3-4f88-8702-8feec6f30f4f",
374-
"x": 4778.4913247279355,
375-
"y": 686.9053277392578,
376-
"endX": 4930.955909075822,
377-
"endY": 674.8231157984133,
393+
"x": 4413.2760145580105,
394+
"y": 1478.0828093084283,
395+
"endX": 4565.740576144995,
396+
"endY": 1482.0005507561987,
378397
"startNodeId": "471f94ef-642e-4065-9b19-600e87184b0c",
379398
"endNodeId": "38a6cf26-b1c4-460d-92b0-86656e215a5a",
380399
"startThumbName": "output",
@@ -383,6 +402,21 @@
383402
"nodeType": "Connection",
384403
"layer": 1,
385404
"nodeInfo": {}
405+
},
406+
{
407+
"id": "3601f5bf-09f9-401d-b7de-28d1be639fb5",
408+
"x": 2678.224512402002,
409+
"y": 1126.0934728314523,
410+
"endX": 2870.2376315349347,
411+
"endY": 1103.2936853877577,
412+
"startNodeId": "6631fbab-1a06-4f8e-9abc-ee8ac2c3f923",
413+
"endNodeId": "3cf44538-9913-4aa2-aade-a7c619910f45",
414+
"startThumbName": "output",
415+
"endThumbName": "input",
416+
"lineType": "BezierCubic",
417+
"nodeType": "Connection",
418+
"layer": 1,
419+
"nodeInfo": {}
386420
}
387421
]
388422
}

libs/app-canvas/src/app/app.element.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ export class AppElement<T extends BaseNodeInfo> {
450450
['A', 'BUTTON', 'INPUT', 'SELECT', 'TEXTAREA'].indexOf(
451451
(event.target as HTMLElement)?.tagName
452452
) >= 0;
453-
if (key === 'backspace' || key === 'delete') {
453+
if (key === 'backspace' || key === 'delete' || key === 'enter') {
454454
if (inInputControle) {
455455
return;
456456
}

libs/visual-programming-system/src/forms/FormField.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export type FormField = (
2626
fieldType: 'Text';
2727
value: string;
2828
onKeyDown?: (event: KeyboardEvent) => void;
29+
onKeyUp?: (event: KeyboardEvent) => void;
2930
onChange?: (value: string, formComponent: IFormsComponent) => void;
3031
}
3132
| {

libs/visual-programming-system/src/forms/form-component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ export class FormsComponent
276276
setValue: this.setValue,
277277
onChange: (value) => this.onChange(formControl, value),
278278
onKeyDown: formControl.onKeyDown,
279+
onKeyUp: formControl.onKeyUp,
279280
isLast: index === this.props.formElements.length - 1,
280281
formsComponent: this,
281282
});

0 commit comments

Comments
 (0)