@nyaruka/temba-components 0.129.10 → 0.130.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/demo/components/flow/example.html +5 -1
- package/demo/data/flows/sample-flow.json +217 -113
- package/dist/temba-components.js +310 -356
- package/dist/temba-components.js.map +1 -1
- package/out-tsc/src/events.js.map +1 -1
- package/out-tsc/src/flow/CanvasNode.js +3 -35
- package/out-tsc/src/flow/CanvasNode.js.map +1 -1
- package/out-tsc/src/flow/Editor.js +9 -6
- package/out-tsc/src/flow/Editor.js.map +1 -1
- package/out-tsc/src/flow/NodeEditor.js +44 -11
- package/out-tsc/src/flow/NodeEditor.js.map +1 -1
- package/out-tsc/src/flow/actions/add_contact_groups.js +1 -1
- package/out-tsc/src/flow/actions/add_contact_groups.js.map +1 -1
- package/out-tsc/src/flow/actions/add_contact_urn.js +1 -1
- package/out-tsc/src/flow/actions/add_contact_urn.js.map +1 -1
- package/out-tsc/src/flow/actions/add_input_labels.js +1 -1
- package/out-tsc/src/flow/actions/add_input_labels.js.map +1 -1
- package/out-tsc/src/flow/actions/remove_contact_groups.js +1 -1
- package/out-tsc/src/flow/actions/remove_contact_groups.js.map +1 -1
- package/out-tsc/src/flow/actions/send_email.js +9 -0
- package/out-tsc/src/flow/actions/send_email.js.map +1 -1
- package/out-tsc/src/flow/actions/send_msg.js +7 -8
- package/out-tsc/src/flow/actions/send_msg.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_channel.js +25 -4
- package/out-tsc/src/flow/actions/set_contact_channel.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_field.js +51 -1
- package/out-tsc/src/flow/actions/set_contact_field.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_language.js +70 -2
- package/out-tsc/src/flow/actions/set_contact_language.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_name.js +27 -2
- package/out-tsc/src/flow/actions/set_contact_name.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_status.js +32 -2
- package/out-tsc/src/flow/actions/set_contact_status.js.map +1 -1
- package/out-tsc/src/flow/actions/set_run_result.js +13 -11
- package/out-tsc/src/flow/actions/set_run_result.js.map +1 -1
- package/out-tsc/src/flow/actions/split_by_expression_example.js +4 -4
- package/out-tsc/src/flow/actions/split_by_expression_example.js.map +1 -1
- package/out-tsc/src/flow/config.js +2 -8
- package/out-tsc/src/flow/config.js.map +1 -1
- package/out-tsc/src/flow/forms/index.js +2 -0
- package/out-tsc/src/flow/forms/index.js.map +1 -0
- package/out-tsc/src/flow/nodes/split_by_llm.js +101 -0
- package/out-tsc/src/flow/nodes/split_by_llm.js.map +1 -0
- package/out-tsc/src/flow/nodes/split_by_llm_categorize.js +4 -89
- package/out-tsc/src/flow/nodes/split_by_llm_categorize.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_random.js +117 -0
- package/out-tsc/src/flow/nodes/split_by_random.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_subflow.js +123 -3
- package/out-tsc/src/flow/nodes/split_by_subflow.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_ticket.js +114 -13
- package/out-tsc/src/flow/nodes/split_by_ticket.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_webhook.js +158 -12
- package/out-tsc/src/flow/nodes/split_by_webhook.js.map +1 -1
- package/out-tsc/src/flow/types.js.map +1 -1
- package/out-tsc/src/form/ArrayEditor.js +9 -25
- package/out-tsc/src/form/ArrayEditor.js.map +1 -1
- package/out-tsc/src/form/FieldRenderer.js +6 -64
- package/out-tsc/src/form/FieldRenderer.js.map +1 -1
- package/out-tsc/src/form/select/Select.js +29 -58
- package/out-tsc/src/form/select/Select.js.map +1 -1
- package/out-tsc/src/live/ContactChat.js +48 -66
- package/out-tsc/src/live/ContactChat.js.map +1 -1
- package/out-tsc/src/utils.js +118 -0
- package/out-tsc/src/utils.js.map +1 -1
- package/out-tsc/test/nodes/split_by_llm.test.js +174 -0
- package/out-tsc/test/nodes/split_by_llm.test.js.map +1 -0
- package/out-tsc/test/nodes/split_by_random.test.js +0 -6
- package/out-tsc/test/nodes/split_by_random.test.js.map +1 -1
- package/out-tsc/test/temba-field-renderer.test.js +6 -3
- package/out-tsc/test/temba-field-renderer.test.js.map +1 -1
- package/out-tsc/test/utils.test.js +18 -0
- package/out-tsc/test/utils.test.js.map +1 -1
- package/package.json +1 -1
- package/screenshots/truth/actions/add_contact_groups/editor/descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/long-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/many-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/multiple-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/single-group.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/long-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/many-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/multiple-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/single-group.png +0 -0
- package/screenshots/truth/actions/call_llm/editor/information-extraction.png +0 -0
- package/screenshots/truth/actions/call_llm/editor/sentiment-analysis.png +0 -0
- package/screenshots/truth/actions/call_llm/editor/summarization.png +0 -0
- package/screenshots/truth/actions/call_llm/editor/translation-task.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/cleanup-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/long-descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/many-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/multiple-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/remove-from-all-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/single-group.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/cleanup-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/long-descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/many-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/multiple-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/remove-from-all-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/single-group.png +0 -0
- package/screenshots/truth/actions/send_email/editor/complex-business-email.png +0 -0
- package/screenshots/truth/actions/send_email/editor/empty-body.png +0 -0
- package/screenshots/truth/actions/send_email/editor/empty-subject.png +0 -0
- package/screenshots/truth/actions/send_email/editor/long-subject.png +0 -0
- package/screenshots/truth/actions/send_email/editor/multiline-body.png +0 -0
- package/screenshots/truth/actions/send_email/editor/multiple-recipients.png +0 -0
- package/screenshots/truth/actions/send_email/editor/simple-email.png +0 -0
- package/screenshots/truth/actions/send_email/editor/with-expressions.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/long-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/multiline-text-with-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/simple-text.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/text-with-linebreaks.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/text-with-many-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/text-with-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/text-without-quick-replies.png +0 -0
- package/screenshots/truth/checkbox/checkbox-label-background-hover.png +0 -0
- package/screenshots/truth/checkbox/checkbox-no-label-no-background-hover.png +0 -0
- package/screenshots/truth/checkbox/checkbox-whitespace-label-no-background-hover.png +0 -0
- package/screenshots/truth/checkbox/checkbox-with-help-text.png +0 -0
- package/screenshots/truth/checkbox/checked.png +0 -0
- package/screenshots/truth/checkbox/default.png +0 -0
- package/screenshots/truth/colorpicker/default.png +0 -0
- package/screenshots/truth/colorpicker/focused.png +0 -0
- package/screenshots/truth/colorpicker/initialized.png +0 -0
- package/screenshots/truth/colorpicker/selected.png +0 -0
- package/screenshots/truth/compose/attachments-tab.png +0 -0
- package/screenshots/truth/compose/attachments-with-files.png +0 -0
- package/screenshots/truth/compose/intial-text.png +0 -0
- package/screenshots/truth/compose/no-counter.png +0 -0
- package/screenshots/truth/compose/wraps-text-and-spaces.png +0 -0
- package/screenshots/truth/compose/wraps-text-and-url.png +0 -0
- package/screenshots/truth/compose/wraps-text-no-spaces.png +0 -0
- package/screenshots/truth/contacts/chat-failure.png +0 -0
- package/screenshots/truth/contacts/chat-for-active-contact.png +0 -0
- package/screenshots/truth/contacts/chat-sends-attachments-only.png +0 -0
- package/screenshots/truth/contacts/chat-sends-text-and-attachments.png +0 -0
- package/screenshots/truth/contacts/chat-sends-text-only.png +0 -0
- package/screenshots/truth/counter/summary.png +0 -0
- package/screenshots/truth/counter/text.png +0 -0
- package/screenshots/truth/counter/unicode-variables.png +0 -0
- package/screenshots/truth/counter/unicode.png +0 -0
- package/screenshots/truth/counter/variable.png +0 -0
- package/screenshots/truth/datepicker/date-truncated-time.png +0 -0
- package/screenshots/truth/datepicker/date.png +0 -0
- package/screenshots/truth/datepicker/initial-timezone.png +0 -0
- package/screenshots/truth/datepicker/range-picker-editing-start.png +0 -0
- package/screenshots/truth/datepicker/updated-keyboard-date.png +0 -0
- package/screenshots/truth/dialog/focused.png +0 -0
- package/screenshots/truth/dropdown/right-edge-collision.png +0 -0
- package/screenshots/truth/editor/router.png +0 -0
- package/screenshots/truth/editor/send_msg.png +0 -0
- package/screenshots/truth/editor/set_contact_language.png +0 -0
- package/screenshots/truth/editor/set_contact_name.png +0 -0
- package/screenshots/truth/editor/set_run_result.png +0 -0
- package/screenshots/truth/editor/wait.png +0 -0
- package/screenshots/truth/field-renderer/checkbox-checked.png +0 -0
- package/screenshots/truth/field-renderer/checkbox-unchecked.png +0 -0
- package/screenshots/truth/field-renderer/checkbox-with-errors.png +0 -0
- package/screenshots/truth/field-renderer/context-comparison.png +0 -0
- package/screenshots/truth/field-renderer/key-value-with-label.png +0 -0
- package/screenshots/truth/field-renderer/message-editor-with-label.png +0 -0
- package/screenshots/truth/field-renderer/select-multi.png +0 -0
- package/screenshots/truth/field-renderer/select-no-label.png +0 -0
- package/screenshots/truth/field-renderer/select-with-label.png +0 -0
- package/screenshots/truth/field-renderer/text-evaluated.png +0 -0
- package/screenshots/truth/field-renderer/text-no-label.png +0 -0
- package/screenshots/truth/field-renderer/text-with-errors.png +0 -0
- package/screenshots/truth/field-renderer/text-with-label.png +0 -0
- package/screenshots/truth/field-renderer/textarea-evaluated.png +0 -0
- package/screenshots/truth/field-renderer/textarea-with-label.png +0 -0
- package/screenshots/truth/integration/checkbox-markdown-errors.png +0 -0
- package/screenshots/truth/list/fields-dragging.png +0 -0
- package/screenshots/truth/list/fields-filtered.png +0 -0
- package/screenshots/truth/list/fields-hovered.png +0 -0
- package/screenshots/truth/list/fields.png +0 -0
- package/screenshots/truth/list/items-selected.png +0 -0
- package/screenshots/truth/list/items-updated.png +0 -0
- package/screenshots/truth/list/items.png +0 -0
- package/screenshots/truth/menu/menu-focused-with items.png +0 -0
- package/screenshots/truth/menu/menu-refresh-1.png +0 -0
- package/screenshots/truth/menu/menu-refresh-2.png +0 -0
- package/screenshots/truth/menu/menu-submenu.png +0 -0
- package/screenshots/truth/menu/menu-tasks-nextup.png +0 -0
- package/screenshots/truth/menu/menu-tasks.png +0 -0
- package/screenshots/truth/message-editor/autogrow-initial-content.png +0 -0
- package/screenshots/truth/message-editor/default.png +0 -0
- package/screenshots/truth/message-editor/drag-highlight.png +0 -0
- package/screenshots/truth/message-editor/filtered-attachments.png +0 -0
- package/screenshots/truth/message-editor/with-completion.png +0 -0
- package/screenshots/truth/message-editor/with-properties.png +0 -0
- package/screenshots/truth/modax/form.png +0 -0
- package/screenshots/truth/modax/simple.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/editor/information-extraction.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/editor/sentiment-analysis.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/editor/summarization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/editor/translation-task.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/render/information-extraction.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/render/sentiment-analysis.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/render/summarization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/render/translation-task.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/basic-categorization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/custom-input-and-result-name.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/feedback-categorization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/many-categories.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/minimal-categories.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/ab-test-multiple-variants.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/sampling-split.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/three-way-split.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/two-bucket-split.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/basic-digits-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/phone-number-collection.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/single-digit-with-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/verification-code.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/basic-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/custom-result-name.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/no-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/short-timeout.png +0 -0
- package/screenshots/truth/omnibox/selected.png +0 -0
- package/screenshots/truth/options/block.png +0 -0
- package/screenshots/truth/run-list/basic.png +0 -0
- package/screenshots/truth/select/disabled-multi-selection.png +0 -0
- package/screenshots/truth/select/disabled-selection.png +0 -0
- package/screenshots/truth/select/disabled.png +0 -0
- package/screenshots/truth/select/embedded.png +0 -0
- package/screenshots/truth/select/empty-options.png +0 -0
- package/screenshots/truth/select/expression-selected.png +0 -0
- package/screenshots/truth/select/expressions.png +0 -0
- package/screenshots/truth/select/functions.png +0 -0
- package/screenshots/truth/select/local-options.png +0 -0
- package/screenshots/truth/select/multi-with-endpoint.png +0 -0
- package/screenshots/truth/select/multiple-initial-values.png +0 -0
- package/screenshots/truth/select/remote-options.png +0 -0
- package/screenshots/truth/select/search-enabled.png +0 -0
- package/screenshots/truth/select/search-multi-no-matches.png +0 -0
- package/screenshots/truth/select/search-selected-focus.png +0 -0
- package/screenshots/truth/select/search-selected.png +0 -0
- package/screenshots/truth/select/search-with-selected.png +0 -0
- package/screenshots/truth/select/searching.png +0 -0
- package/screenshots/truth/select/selected-multi-maxitems-reached.png +0 -0
- package/screenshots/truth/select/selected-multi.png +0 -0
- package/screenshots/truth/select/selected-single.png +0 -0
- package/screenshots/truth/select/selection-clearable.png +0 -0
- package/screenshots/truth/select/static-initial-value.png +0 -0
- package/screenshots/truth/select/static-initial-via-selected.png +0 -0
- package/screenshots/truth/select/truncated-selection.png +0 -0
- package/screenshots/truth/select/with-placeholder.png +0 -0
- package/screenshots/truth/select/without-placeholder.png +0 -0
- package/screenshots/truth/slider/update-slider-on-circle-dragged.png +0 -0
- package/screenshots/truth/templates/default.png +0 -0
- package/screenshots/truth/templates/unapproved.png +0 -0
- package/screenshots/truth/textinput/autogrow-initial.png +0 -0
- package/screenshots/truth/textinput/input-disabled.png +0 -0
- package/screenshots/truth/textinput/input-focused.png +0 -0
- package/screenshots/truth/textinput/input-form.png +0 -0
- package/screenshots/truth/textinput/input-inserted.png +0 -0
- package/screenshots/truth/textinput/input-placeholder.png +0 -0
- package/screenshots/truth/textinput/input-updated.png +0 -0
- package/screenshots/truth/textinput/input.png +0 -0
- package/screenshots/truth/textinput/textarea-focused.png +0 -0
- package/screenshots/truth/textinput/textarea.png +0 -0
- package/src/events.ts +4 -2
- package/src/flow/CanvasNode.ts +2 -39
- package/src/flow/Editor.ts +6 -3
- package/src/flow/NodeEditor.ts +54 -13
- package/src/flow/actions/add_contact_groups.ts +1 -1
- package/src/flow/actions/add_contact_urn.ts +1 -1
- package/src/flow/actions/add_input_labels.ts +1 -1
- package/src/flow/actions/remove_contact_groups.ts +1 -1
- package/src/flow/actions/send_email.ts +11 -1
- package/src/flow/actions/send_msg.ts +20 -11
- package/src/flow/actions/set_contact_channel.ts +28 -5
- package/src/flow/actions/set_contact_field.ts +56 -2
- package/src/flow/actions/set_contact_language.ts +74 -3
- package/src/flow/actions/set_contact_name.ts +31 -3
- package/src/flow/actions/set_contact_status.ts +36 -3
- package/src/flow/actions/set_run_result.ts +13 -15
- package/src/flow/actions/split_by_expression_example.ts +4 -4
- package/src/flow/config.ts +2 -8
- package/src/flow/forms/index.ts +1 -0
- package/src/flow/nodes/split_by_llm.ts +119 -0
- package/src/flow/nodes/split_by_llm_categorize.ts +13 -116
- package/src/flow/nodes/split_by_random.ts +148 -0
- package/src/flow/nodes/split_by_subflow.ts +153 -3
- package/src/flow/nodes/split_by_ticket.ts +134 -12
- package/src/flow/nodes/split_by_webhook.ts +185 -12
- package/src/flow/types.ts +2 -1
- package/src/form/ArrayEditor.ts +6 -20
- package/src/form/FieldRenderer.ts +6 -65
- package/src/form/select/Select.ts +34 -66
- package/src/live/ContactChat.ts +56 -58
- package/src/store/flow-definition.d.ts +8 -2
- package/src/utils.ts +196 -0
- package/static/api/fields.json +93 -1208
- package/static/api/workspace.json +23 -0
- package/test/nodes/split_by_llm.test.ts +232 -0
- package/test/nodes/split_by_random.test.ts +0 -7
- package/test/temba-field-renderer.test.ts +26 -13
- package/test/utils.test.ts +20 -0
- package/test-assets/style.css +36 -234
- package/web-dev-server.config.mjs +28 -0
- package/web-test-runner.config.mjs +38 -1
- package/out-tsc/src/flow/actions/call_llm.js +0 -64
- package/out-tsc/src/flow/actions/call_llm.js.map +0 -1
- package/out-tsc/src/flow/actions/call_webhook.js +0 -131
- package/out-tsc/src/flow/actions/call_webhook.js.map +0 -1
- package/out-tsc/src/flow/actions/enter_flow.js +0 -14
- package/out-tsc/src/flow/actions/enter_flow.js.map +0 -1
- package/out-tsc/src/flow/actions/open_ticket.js +0 -73
- package/out-tsc/src/flow/actions/open_ticket.js.map +0 -1
- package/out-tsc/test/actions/call_llm.test.js +0 -103
- package/out-tsc/test/actions/call_llm.test.js.map +0 -1
- package/src/flow/actions/call_llm.ts +0 -66
- package/src/flow/actions/call_webhook.ts +0 -143
- package/src/flow/actions/enter_flow.ts +0 -15
- package/src/flow/actions/open_ticket.ts +0 -83
- package/test/actions/call_llm.test.ts +0 -137
|
@@ -322,6 +322,43 @@ export default {
|
|
|
322
322
|
preventAssignment: true,
|
|
323
323
|
'process.env.NODE_ENV': JSON.stringify('test'),
|
|
324
324
|
}),
|
|
325
|
+
{
|
|
326
|
+
name: 'api-mock-server',
|
|
327
|
+
serve(context) {
|
|
328
|
+
// Handle API endpoints by serving static files
|
|
329
|
+
if (context.request.method === 'GET' && context.path.startsWith('/api/')) {
|
|
330
|
+
// Map API endpoints to static files
|
|
331
|
+
const apiMappings = {
|
|
332
|
+
'/api/v2/groups.json': './static/api/groups.json',
|
|
333
|
+
'/api/v2/labels.json': './static/api/labels.json',
|
|
334
|
+
'/api/v2/fields.json': './static/api/fields.json',
|
|
335
|
+
'/api/v2/globals.json': './static/api/globals.json',
|
|
336
|
+
'/api/v2/completion.json': './static/mr/docs/en-us/editor.json',
|
|
337
|
+
'/api/v2/functions.json': './static/api/functions.json',
|
|
338
|
+
'/api/internal/templates.json': './static/api/templates.json',
|
|
339
|
+
'/api/v2/media.json': './static/api/media.json',
|
|
340
|
+
'/api/v2/users.json': './static/api/users.json',
|
|
341
|
+
'/api/v2/contacts.json': './static/api/contacts.json',
|
|
342
|
+
'/api/v2/optins.json': './static/api/optins.json',
|
|
343
|
+
'/api/v2/topics.json': './static/api/topics.json',
|
|
344
|
+
'/api/v2/languages.json': './static/api/languages.json',
|
|
345
|
+
'/api/v2/workspace.json': './static/api/workspace.json',
|
|
346
|
+
'/api/internal/locations.json': './static/api/locations.json',
|
|
347
|
+
'/api/internal/orgs.json': './static/api/orgs.json'
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
// Handle base path without query parameters
|
|
351
|
+
const basePath = context.path.split('?')[0];
|
|
352
|
+
const staticFile = apiMappings[basePath];
|
|
353
|
+
|
|
354
|
+
if (staticFile && fs.existsSync(path.resolve(staticFile))) {
|
|
355
|
+
context.contentType = 'application/json';
|
|
356
|
+
context.body = fs.readFileSync(path.resolve(staticFile), 'utf-8');
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
},
|
|
325
362
|
{
|
|
326
363
|
name: 'add-style',
|
|
327
364
|
transform(context) {
|
|
@@ -329,7 +366,7 @@ export default {
|
|
|
329
366
|
return {
|
|
330
367
|
body: context.body.replace(
|
|
331
368
|
/<head>/,
|
|
332
|
-
`<head><link rel="stylesheet" href="/test-assets/style.css"
|
|
369
|
+
`<head><link rel="stylesheet" href="/test-assets/temba-components.css"/><link rel="stylesheet" href="/test-assets/style.css"/>`
|
|
333
370
|
),
|
|
334
371
|
};
|
|
335
372
|
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { html } from 'lit-html';
|
|
2
|
-
import { COLORS } from '../types';
|
|
3
|
-
export const call_llm = {
|
|
4
|
-
name: 'Call AI',
|
|
5
|
-
color: COLORS.call,
|
|
6
|
-
render: (_node, action) => {
|
|
7
|
-
return html `<div
|
|
8
|
-
style="word-wrap: break-word; overflow-wrap: break-word; hyphens: auto; max-width: 180px; max-height: 100px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical;"
|
|
9
|
-
>
|
|
10
|
-
${action.instructions}
|
|
11
|
-
</div>`;
|
|
12
|
-
},
|
|
13
|
-
form: {
|
|
14
|
-
llm: {
|
|
15
|
-
type: 'select',
|
|
16
|
-
required: true,
|
|
17
|
-
options: [],
|
|
18
|
-
endpoint: '/test-assets/select/llms.json',
|
|
19
|
-
searchable: true,
|
|
20
|
-
valueKey: 'uuid',
|
|
21
|
-
nameKey: 'name'
|
|
22
|
-
},
|
|
23
|
-
input: {
|
|
24
|
-
type: 'text',
|
|
25
|
-
required: true,
|
|
26
|
-
label: 'The input the AI will process',
|
|
27
|
-
evaluated: true,
|
|
28
|
-
placeholder: '@input'
|
|
29
|
-
},
|
|
30
|
-
instructions: {
|
|
31
|
-
type: 'textarea',
|
|
32
|
-
required: true,
|
|
33
|
-
label: 'Tell the AI what to do with the input',
|
|
34
|
-
evaluated: true,
|
|
35
|
-
placeholder: 'Enter instructions for the AI model...',
|
|
36
|
-
minHeight: 130,
|
|
37
|
-
helpText: 'The result can be referenced as **`@locals._llm_output`**'
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
layout: ['llm', 'input', 'instructions'],
|
|
41
|
-
toFormData: (action) => {
|
|
42
|
-
return {
|
|
43
|
-
uuid: action.uuid,
|
|
44
|
-
llm: action.llm
|
|
45
|
-
? [{ value: action.llm.uuid, name: action.llm.name }]
|
|
46
|
-
: [],
|
|
47
|
-
input: action.input || '@input',
|
|
48
|
-
instructions: action.instructions || ''
|
|
49
|
-
};
|
|
50
|
-
},
|
|
51
|
-
fromFormData: (data) => {
|
|
52
|
-
const llmSelection = Array.isArray(data.llm) && data.llm.length > 0 ? data.llm[0] : null;
|
|
53
|
-
return {
|
|
54
|
-
uuid: data.uuid,
|
|
55
|
-
type: 'call_llm',
|
|
56
|
-
input: data.input || '@input',
|
|
57
|
-
llm: llmSelection
|
|
58
|
-
? { uuid: llmSelection.value, name: llmSelection.name }
|
|
59
|
-
: { uuid: '', name: '' },
|
|
60
|
-
instructions: data.instructions || ''
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
//# sourceMappingURL=call_llm.js.map
|
|
@@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CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;gBACrD,CAAC,CAAC,EAAE;YACN,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,QAAQ;YAC/B,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,EAAE;SACxC,CAAC;IACJ,CAAC;IACD,YAAY,EAAE,CAAC,IAAyB,EAAE,EAAE;QAC1C,MAAM,YAAY,GAChB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACtE,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,UAAU;YAChB,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,QAAQ;YAC7B,GAAG,EAAE,YAAY;gBACf,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,YAAY,CAAC,IAAI,EAAE;gBACvD,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;YAC1B,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,EAAE;SAC3B,CAAC;IACf,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit-html';\nimport { ActionConfig, COLORS } from '../types';\nimport { Node, CallLLM } from '../../store/flow-definition';\n\nexport const call_llm: ActionConfig = {\n name: 'Call AI',\n color: COLORS.call,\n render: (_node: Node, action: CallLLM) => {\n return html`<div\n style=\"word-wrap: break-word; overflow-wrap: break-word; hyphens: auto; max-width: 180px; max-height: 100px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical;\"\n >\n ${action.instructions}\n </div>`;\n },\n form: {\n llm: {\n type: 'select',\n required: true,\n options: [],\n endpoint: '/test-assets/select/llms.json',\n searchable: true,\n valueKey: 'uuid',\n nameKey: 'name'\n },\n input: {\n type: 'text',\n required: true,\n label: 'The input the AI will process',\n evaluated: true,\n placeholder: '@input'\n },\n instructions: {\n type: 'textarea',\n required: true,\n label: 'Tell the AI what to do with the input',\n evaluated: true,\n placeholder: 'Enter instructions for the AI model...',\n minHeight: 130,\n helpText: 'The result can be referenced as **`@locals._llm_output`**'\n }\n },\n layout: ['llm', 'input', 'instructions'],\n toFormData: (action: CallLLM) => {\n return {\n uuid: action.uuid,\n llm: action.llm\n ? [{ value: action.llm.uuid, name: action.llm.name }]\n : [],\n input: action.input || '@input',\n instructions: action.instructions || ''\n };\n },\n fromFormData: (data: Record<string, any>) => {\n const llmSelection =\n Array.isArray(data.llm) && data.llm.length > 0 ? data.llm[0] : null;\n return {\n uuid: data.uuid,\n type: 'call_llm',\n input: data.input || '@input',\n llm: llmSelection\n ? { uuid: llmSelection.value, name: llmSelection.name }\n : { uuid: '', name: '' },\n instructions: data.instructions || ''\n } as CallLLM;\n }\n};\n"]}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { html } from 'lit-html';
|
|
2
|
-
import { COLORS } from '../types';
|
|
3
|
-
const defaultPost = `@(json(object(
|
|
4
|
-
"contact", object(
|
|
5
|
-
"uuid", contact.uuid,
|
|
6
|
-
"name", contact.name,
|
|
7
|
-
"urn", contact.urn
|
|
8
|
-
),
|
|
9
|
-
"flow", object(
|
|
10
|
-
"uuid", run.flow.uuid,
|
|
11
|
-
"name", run.flow.name
|
|
12
|
-
),
|
|
13
|
-
"results", foreach_value(results, extract_object, "value", "category")
|
|
14
|
-
)))`;
|
|
15
|
-
export const call_webhook = {
|
|
16
|
-
name: 'Call Webhook',
|
|
17
|
-
color: COLORS.call,
|
|
18
|
-
render: (_node, action) => {
|
|
19
|
-
return html `<div
|
|
20
|
-
style="word-wrap: break-word; overflow-wrap: break-word; hyphens: auto;"
|
|
21
|
-
>
|
|
22
|
-
${action.url}
|
|
23
|
-
</div>`;
|
|
24
|
-
},
|
|
25
|
-
evaluated: ['url', 'headers', 'body'], // keep for backward compatibility
|
|
26
|
-
form: {
|
|
27
|
-
method: {
|
|
28
|
-
type: 'select',
|
|
29
|
-
required: true,
|
|
30
|
-
options: ['GET', 'POST', 'PUT', 'DELETE', 'HEAD', 'PATCH'],
|
|
31
|
-
maxWidth: '120px',
|
|
32
|
-
searchable: false
|
|
33
|
-
},
|
|
34
|
-
url: {
|
|
35
|
-
type: 'text',
|
|
36
|
-
required: true,
|
|
37
|
-
evaluated: true,
|
|
38
|
-
placeholder: 'https://example.com/webhook'
|
|
39
|
-
},
|
|
40
|
-
headers: {
|
|
41
|
-
type: 'key-value',
|
|
42
|
-
sortable: true,
|
|
43
|
-
keyPlaceholder: 'Header name',
|
|
44
|
-
valuePlaceholder: 'Header value',
|
|
45
|
-
minRows: 0
|
|
46
|
-
},
|
|
47
|
-
body: {
|
|
48
|
-
type: 'textarea',
|
|
49
|
-
evaluated: true,
|
|
50
|
-
placeholder: 'Request body content (JSON, XML, etc.)',
|
|
51
|
-
minHeight: 200,
|
|
52
|
-
dependsOn: ['method'],
|
|
53
|
-
computeValue: (values, currentValue, originalValues) => {
|
|
54
|
-
// Check if method is POST (handle both string and select object formats)
|
|
55
|
-
const method = Array.isArray(values.method) && values.method.length > 0
|
|
56
|
-
? values.method[0].value || values.method[0].name
|
|
57
|
-
: values.method;
|
|
58
|
-
if (method === 'POST') {
|
|
59
|
-
// For POST, provide the template if body is empty or was never set by user
|
|
60
|
-
if (!currentValue || currentValue.trim() === '') {
|
|
61
|
-
return defaultPost;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
// For non-POST methods, clear the body if it was auto-generated or empty
|
|
66
|
-
// Check if the original body was empty (user never specified a body)
|
|
67
|
-
const originalBody = (originalValues === null || originalValues === void 0 ? void 0 : originalValues.body) || '';
|
|
68
|
-
const isOriginallyEmpty = !originalBody || originalBody.trim() === '';
|
|
69
|
-
// Clear if: originally empty, contains default template, or is currently empty
|
|
70
|
-
if (isOriginallyEmpty ||
|
|
71
|
-
!currentValue ||
|
|
72
|
-
currentValue.trim() === '' ||
|
|
73
|
-
currentValue.trim() === defaultPost.trim()) {
|
|
74
|
-
return '';
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return currentValue; // Keep existing value if user has customized it
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
layout: [
|
|
82
|
-
// Row with method and URL side by side
|
|
83
|
-
{ type: 'row', items: ['method', 'url'] },
|
|
84
|
-
// Advanced group with nested layouts
|
|
85
|
-
{
|
|
86
|
-
type: 'group',
|
|
87
|
-
label: 'Headers',
|
|
88
|
-
items: ['headers'],
|
|
89
|
-
collapsible: true,
|
|
90
|
-
collapsed: true,
|
|
91
|
-
helpText: 'Configure authentication or custom headers',
|
|
92
|
-
getGroupValueCount: (formData) => {
|
|
93
|
-
var _a;
|
|
94
|
-
return ((_a = formData.headers) === null || _a === void 0 ? void 0 : _a.length) || 0;
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
type: 'group',
|
|
99
|
-
label: 'Body',
|
|
100
|
-
items: ['body'],
|
|
101
|
-
collapsible: true,
|
|
102
|
-
collapsed: true,
|
|
103
|
-
helpText: 'Configure the request payload',
|
|
104
|
-
getGroupValueCount: (formData) => {
|
|
105
|
-
return !!(formData.body &&
|
|
106
|
-
formData.body.trim() !== '' &&
|
|
107
|
-
formData.body !== defaultPost);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
],
|
|
111
|
-
toFormData: (action) => {
|
|
112
|
-
return {
|
|
113
|
-
uuid: action.uuid,
|
|
114
|
-
url: action.url || '',
|
|
115
|
-
method: [{ value: action.method, name: action.method }],
|
|
116
|
-
headers: action.headers || [],
|
|
117
|
-
body: action.body || ''
|
|
118
|
-
};
|
|
119
|
-
},
|
|
120
|
-
fromFormData: (data) => {
|
|
121
|
-
return {
|
|
122
|
-
uuid: data.uuid,
|
|
123
|
-
type: 'call_webhook',
|
|
124
|
-
url: data.url,
|
|
125
|
-
method: data.method[0].value,
|
|
126
|
-
headers: data.headers || [],
|
|
127
|
-
body: data.body || ''
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
//# sourceMappingURL=call_webhook.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"call_webhook.js","sourceRoot":"","sources":["../../../../src/flow/actions/call_webhook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAgB,MAAM,EAAE,MAAM,UAAU,CAAC;AAGhD,MAAM,WAAW,GAAG;;;;;;;;;;;IAWhB,CAAC;AAEL,MAAM,CAAC,MAAM,YAAY,GAAiB;IACxC,IAAI,EAAE,cAAc;IACpB,KAAK,EAAE,MAAM,CAAC,IAAI;IAClB,MAAM,EAAE,CAAC,KAAW,EAAE,MAAmB,EAAE,EAAE;QAC3C,OAAO,IAAI,CAAA;;;QAGP,MAAM,CAAC,GAAG;WACP,CAAC;IACV,CAAC;IACD,SAAS,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,kCAAkC;IACzE,IAAI,EAAE;QACJ,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC;YAC1D,QAAQ,EAAE,OAAO;YACjB,UAAU,EAAE,KAAK;SAClB;QACD,GAAG,EAAE;YACH,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,IAAI;YACf,WAAW,EAAE,6BAA6B;SAC3C;QACD,OAAO,EAAE;YACP,IAAI,EAAE,WAAW;YACjB,QAAQ,EAAE,IAAI;YACd,cAAc,EA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AC;IACD,YAAY,EAAE,CAAC,IAAyB,EAAE,EAAE;QAC1C,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,cAAc;YACpB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK;YAC5B,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE;YAC3B,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,EAAE;SACP,CAAC;IACnB,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit-html';\nimport { ActionConfig, COLORS } from '../types';\nimport { Node, CallWebhook } from '../../store/flow-definition';\n\nconst defaultPost = `@(json(object(\n \"contact\", object(\n \"uuid\", contact.uuid, \n \"name\", contact.name, \n \"urn\", contact.urn\n ),\n \"flow\", object(\n \"uuid\", run.flow.uuid, \n \"name\", run.flow.name\n ),\n \"results\", foreach_value(results, extract_object, \"value\", \"category\")\n)))`;\n\nexport const call_webhook: ActionConfig = {\n name: 'Call Webhook',\n color: COLORS.call,\n render: (_node: Node, action: CallWebhook) => {\n return html`<div\n style=\"word-wrap: break-word; overflow-wrap: break-word; hyphens: auto;\"\n >\n ${action.url}\n </div>`;\n },\n evaluated: ['url', 'headers', 'body'], // keep for backward compatibility\n form: {\n method: {\n type: 'select',\n required: true,\n options: ['GET', 'POST', 'PUT', 'DELETE', 'HEAD', 'PATCH'],\n maxWidth: '120px',\n searchable: false\n },\n url: {\n type: 'text',\n required: true,\n evaluated: true,\n placeholder: 'https://example.com/webhook'\n },\n headers: {\n type: 'key-value',\n sortable: true,\n keyPlaceholder: 'Header name',\n valuePlaceholder: 'Header value',\n minRows: 0\n },\n body: {\n type: 'textarea',\n evaluated: true,\n placeholder: 'Request body content (JSON, XML, etc.)',\n minHeight: 200,\n dependsOn: ['method'],\n computeValue: (\n values: Record<string, any>,\n currentValue: any,\n originalValues?: Record<string, any>\n ) => {\n // Check if method is POST (handle both string and select object formats)\n const method =\n Array.isArray(values.method) && values.method.length > 0\n ? values.method[0].value || values.method[0].name\n : values.method;\n\n if (method === 'POST') {\n // For POST, provide the template if body is empty or was never set by user\n if (!currentValue || currentValue.trim() === '') {\n return defaultPost;\n }\n } else {\n // For non-POST methods, clear the body if it was auto-generated or empty\n // Check if the original body was empty (user never specified a body)\n const originalBody = originalValues?.body || '';\n const isOriginallyEmpty = !originalBody || originalBody.trim() === '';\n\n // Clear if: originally empty, contains default template, or is currently empty\n if (\n isOriginallyEmpty ||\n !currentValue ||\n currentValue.trim() === '' ||\n currentValue.trim() === defaultPost.trim()\n ) {\n return '';\n }\n }\n\n return currentValue; // Keep existing value if user has customized it\n }\n }\n },\n layout: [\n // Row with method and URL side by side\n { type: 'row', items: ['method', 'url'] },\n // Advanced group with nested layouts\n {\n type: 'group',\n label: 'Headers',\n items: ['headers'],\n collapsible: true,\n collapsed: true,\n helpText: 'Configure authentication or custom headers',\n getGroupValueCount: (formData: any) => {\n return formData.headers?.length || 0;\n }\n },\n {\n type: 'group',\n label: 'Body',\n items: ['body'],\n collapsible: true,\n collapsed: true,\n helpText: 'Configure the request payload',\n getGroupValueCount: (formData: any) => {\n return !!(\n formData.body &&\n formData.body.trim() !== '' &&\n formData.body !== defaultPost\n );\n }\n }\n ],\n toFormData: (action: CallWebhook) => {\n return {\n uuid: action.uuid,\n url: action.url || '',\n method: [{ value: action.method, name: action.method }],\n headers: action.headers || [],\n body: action.body || ''\n };\n },\n fromFormData: (data: Record<string, any>) => {\n return {\n uuid: data.uuid,\n type: 'call_webhook',\n url: data.url,\n method: data.method[0].value,\n headers: data.headers || [],\n body: data.body || ''\n } as CallWebhook;\n }\n};\n"]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { html } from 'lit-html';
|
|
2
|
-
import { COLORS } from '../types';
|
|
3
|
-
export const enter_flow = {
|
|
4
|
-
name: 'Enter a Flow',
|
|
5
|
-
color: COLORS.execute,
|
|
6
|
-
render: (_node, action) => {
|
|
7
|
-
return html `<div
|
|
8
|
-
style="word-wrap: break-word; overflow-wrap: break-word; hyphens: auto;"
|
|
9
|
-
>
|
|
10
|
-
Enter <b>${action.flow.name}</b>
|
|
11
|
-
</div>`;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=enter_flow.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enter_flow.js","sourceRoot":"","sources":["../../../../src/flow/actions/enter_flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAgB,MAAM,EAAE,MAAM,UAAU,CAAC;AAGhD,MAAM,CAAC,MAAM,UAAU,GAAiB;IACtC,IAAI,EAAE,cAAc;IACpB,KAAK,EAAE,MAAM,CAAC,OAAO;IACrB,MAAM,EAAE,CAAC,KAAW,EAAE,MAAiB,EAAE,EAAE;QACzC,OAAO,IAAI,CAAA;;;iBAGE,MAAM,CAAC,IAAI,CAAC,IAAI;WACtB,CAAC;IACV,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit-html';\nimport { ActionConfig, COLORS } from '../types';\nimport { Node, EnterFlow } from '../../store/flow-definition';\n\nexport const enter_flow: ActionConfig = {\n name: 'Enter a Flow',\n color: COLORS.execute,\n render: (_node: Node, action: EnterFlow) => {\n return html`<div\n style=\"word-wrap: break-word; overflow-wrap: break-word; hyphens: auto;\"\n >\n Enter <b>${action.flow.name}</b>\n </div>`;\n }\n};\n"]}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { html } from 'lit-html';
|
|
2
|
-
import { COLORS } from '../types';
|
|
3
|
-
export const open_ticket = {
|
|
4
|
-
name: 'Open Ticket',
|
|
5
|
-
color: COLORS.create,
|
|
6
|
-
render: (_node, action) => {
|
|
7
|
-
return html `<div>${action.topic.name}</div>`;
|
|
8
|
-
},
|
|
9
|
-
form: {
|
|
10
|
-
topic: {
|
|
11
|
-
type: 'select',
|
|
12
|
-
required: true,
|
|
13
|
-
placeholder: 'Select a topic',
|
|
14
|
-
options: [],
|
|
15
|
-
endpoint: '/api/v2/topics.json',
|
|
16
|
-
valueKey: 'uuid',
|
|
17
|
-
nameKey: 'name',
|
|
18
|
-
maxWidth: '200px'
|
|
19
|
-
},
|
|
20
|
-
assignee: {
|
|
21
|
-
type: 'select',
|
|
22
|
-
required: false,
|
|
23
|
-
placeholder: 'Select an agent (optional)',
|
|
24
|
-
options: [],
|
|
25
|
-
endpoint: '/api/v2/users.json',
|
|
26
|
-
valueKey: 'uuid',
|
|
27
|
-
getName: (item) => {
|
|
28
|
-
return item.name || [item.first_name, item.last_name].join(' ');
|
|
29
|
-
},
|
|
30
|
-
clearable: true
|
|
31
|
-
},
|
|
32
|
-
note: {
|
|
33
|
-
type: 'textarea',
|
|
34
|
-
required: false,
|
|
35
|
-
placeholder: 'Enter a note for the ticket (optional)',
|
|
36
|
-
minHeight: 100
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
layout: [{ type: 'row', items: ['topic', 'assignee'] }, 'note'],
|
|
40
|
-
toFormData: (action) => {
|
|
41
|
-
return {
|
|
42
|
-
uuid: action.uuid,
|
|
43
|
-
topic: action.topic
|
|
44
|
-
? [{ uuid: action.topic.uuid, name: action.topic.name }]
|
|
45
|
-
: [],
|
|
46
|
-
assignee: action.assignee
|
|
47
|
-
? [{ uuid: action.assignee.uuid, name: action.assignee.name }]
|
|
48
|
-
: [],
|
|
49
|
-
note: action.note || ''
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
fromFormData: (data) => {
|
|
53
|
-
return {
|
|
54
|
-
uuid: data.uuid,
|
|
55
|
-
type: 'open_ticket',
|
|
56
|
-
topic: data.topic && data.topic.length > 0
|
|
57
|
-
? {
|
|
58
|
-
uuid: data.topic[0].uuid,
|
|
59
|
-
name: data.topic[0].name
|
|
60
|
-
}
|
|
61
|
-
: undefined,
|
|
62
|
-
assignee: data.assignee && data.assignee.length > 0
|
|
63
|
-
? {
|
|
64
|
-
uuid: data.assignee[0].uuid,
|
|
65
|
-
name: data.assignee[0].name ||
|
|
66
|
-
[data.assignee[0].first_name, data.assignee[0].last_name].join(' ')
|
|
67
|
-
}
|
|
68
|
-
: undefined,
|
|
69
|
-
note: data.note || ''
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
//# sourceMappingURL=open_ticket.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"open_ticket.js","sourceRoot":"","sources":["../../../../src/flow/actions/open_ticket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAgB,MAAM,EAAE,MAAM,UAAU,CAAC;AAGhD,MAAM,CAAC,MAAM,WAAW,GAAiB;IACvC,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM;IACpB,MAAM,EAAE,CAAC,KAAW,EAAE,MAAkB,EAAE,EAAE;QAC1C,OAAO,IAAI,CAAA,QAAQ,MAAM,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC;IAC/C,CAAC;IACD,IAAI,EAAE;QACJ,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,gBAAgB;YAC7B,OAAO,EAAE,EAAE;YACX,QAAQ,EAAE,qBAAqB;YAC/B,QAAQ,EAAE,MAAM;YAChB,OAAO,EAAE,MAAM;YACf,QAAQ,EAAE,OAAO;SAClB;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,4BAA4B;YACzC,OAAO,EAAE,EAAE;YACX,QAAQ,EAAE,oBAAoB;YAC9B,QAAQ,EAAE,MAAM;YAChB,OAAO,EAAE,CAAC,IAIT,EAAE,EAAE;gBACH,OAAO,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAA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AC,CAAC,IAAI;iBACzB;gBACH,CAAC,CAAC,SAAS;YACf,QAAQ,EACN,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;gBACvC,CAAC,CAAC;oBACE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI;oBAC3B,IAAI,EACF,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI;wBACrB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,CAC5D,GAAG,CACJ;iBACJ;gBACH,CAAC,CAAC,SAAS;YACf,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,EAAE;SACR,CAAC;IAClB,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit-html';\nimport { ActionConfig, COLORS } from '../types';\nimport { Node, OpenTicket } from '../../store/flow-definition';\n\nexport const open_ticket: ActionConfig = {\n name: 'Open Ticket',\n color: COLORS.create,\n render: (_node: Node, action: OpenTicket) => {\n return html`<div>${action.topic.name}</div>`;\n },\n form: {\n topic: {\n type: 'select',\n required: true,\n placeholder: 'Select a topic',\n options: [],\n endpoint: '/api/v2/topics.json',\n valueKey: 'uuid',\n nameKey: 'name',\n maxWidth: '200px'\n },\n assignee: {\n type: 'select',\n required: false,\n placeholder: 'Select an agent (optional)',\n options: [],\n endpoint: '/api/v2/users.json',\n valueKey: 'uuid',\n getName: (item: {\n first_name?: string;\n last_name?: string;\n name?: string;\n }) => {\n return item.name || [item.first_name, item.last_name].join(' ');\n },\n clearable: true\n },\n note: {\n type: 'textarea',\n required: false,\n placeholder: 'Enter a note for the ticket (optional)',\n minHeight: 100\n }\n },\n layout: [{ type: 'row', items: ['topic', 'assignee'] }, 'note'],\n toFormData: (action: OpenTicket) => {\n return {\n uuid: action.uuid,\n topic: action.topic\n ? [{ uuid: action.topic.uuid, name: action.topic.name }]\n : [],\n assignee: action.assignee\n ? [{ uuid: action.assignee.uuid, name: action.assignee.name }]\n : [],\n note: action.note || ''\n };\n },\n fromFormData: (data: Record<string, any>) => {\n return {\n uuid: data.uuid,\n type: 'open_ticket',\n topic:\n data.topic && data.topic.length > 0\n ? {\n uuid: data.topic[0].uuid,\n name: data.topic[0].name\n }\n : undefined,\n assignee:\n data.assignee && data.assignee.length > 0\n ? {\n uuid: data.assignee[0].uuid,\n name:\n data.assignee[0].name ||\n [data.assignee[0].first_name, data.assignee[0].last_name].join(\n ' '\n )\n }\n : undefined,\n note: data.note || ''\n } as OpenTicket;\n }\n};\n"]}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { expect } from '@open-wc/testing';
|
|
2
|
-
import { call_llm } from '../../src/flow/actions/call_llm';
|
|
3
|
-
import { ActionTest } from '../ActionHelper';
|
|
4
|
-
/**
|
|
5
|
-
* Test suite for the call_llm action configuration.
|
|
6
|
-
*/
|
|
7
|
-
describe('call_llm action config', () => {
|
|
8
|
-
const helper = new ActionTest(call_llm, 'call_llm');
|
|
9
|
-
describe('basic properties', () => {
|
|
10
|
-
helper.testBasicProperties();
|
|
11
|
-
it('has correct name', () => {
|
|
12
|
-
expect(call_llm.name).to.equal('Call AI');
|
|
13
|
-
});
|
|
14
|
-
it('has form configuration', () => {
|
|
15
|
-
expect(call_llm.form).to.exist;
|
|
16
|
-
expect(call_llm.form.llm).to.exist;
|
|
17
|
-
expect(call_llm.form.instructions).to.exist;
|
|
18
|
-
expect(call_llm.form.input).to.exist;
|
|
19
|
-
});
|
|
20
|
-
it('has layout configuration', () => {
|
|
21
|
-
expect(call_llm.layout).to.exist;
|
|
22
|
-
expect(call_llm.layout).to.deep.equal(['llm', 'input', 'instructions']);
|
|
23
|
-
});
|
|
24
|
-
it('has data transformation functions', () => {
|
|
25
|
-
expect(call_llm.toFormData).to.be.a('function');
|
|
26
|
-
expect(call_llm.fromFormData).to.be.a('function');
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
describe('data transformations', () => {
|
|
30
|
-
it('converts action to form data correctly', () => {
|
|
31
|
-
const action = {
|
|
32
|
-
uuid: 'test-llm-1',
|
|
33
|
-
type: 'call_llm',
|
|
34
|
-
input: '@input',
|
|
35
|
-
llm: { uuid: 'gpt-4', name: 'GPT 4.1' },
|
|
36
|
-
instructions: 'Translate to French',
|
|
37
|
-
result_name: 'translated_text'
|
|
38
|
-
};
|
|
39
|
-
const formData = call_llm.toFormData(action);
|
|
40
|
-
expect(formData.uuid).to.equal('test-llm-1');
|
|
41
|
-
expect(formData.llm).to.deep.equal([{ value: 'gpt-4', name: 'GPT 4.1' }]);
|
|
42
|
-
expect(formData.instructions).to.equal('Translate to French');
|
|
43
|
-
expect(formData.input).to.equal('@input');
|
|
44
|
-
});
|
|
45
|
-
it('converts form data to action correctly', () => {
|
|
46
|
-
const formData = {
|
|
47
|
-
uuid: 'test-llm-2',
|
|
48
|
-
llm: [{ value: 'gpt-5', name: 'GPT 5' }],
|
|
49
|
-
instructions: 'Summarize the following text',
|
|
50
|
-
input: '@input'
|
|
51
|
-
};
|
|
52
|
-
const action = call_llm.fromFormData(formData);
|
|
53
|
-
expect(action.uuid).to.equal('test-llm-2');
|
|
54
|
-
expect(action.type).to.equal('call_llm');
|
|
55
|
-
expect(action.llm).to.deep.equal({ uuid: 'gpt-5', name: 'GPT 5' });
|
|
56
|
-
expect(action.instructions).to.equal('Summarize the following text');
|
|
57
|
-
expect(action.input).to.equal('@input');
|
|
58
|
-
});
|
|
59
|
-
it('handles empty form data', () => {
|
|
60
|
-
const formData = {
|
|
61
|
-
uuid: 'test-llm-3',
|
|
62
|
-
llm: [],
|
|
63
|
-
instructions: '',
|
|
64
|
-
input: ''
|
|
65
|
-
};
|
|
66
|
-
const action = call_llm.fromFormData(formData);
|
|
67
|
-
expect(action.llm).to.deep.equal({ uuid: '', name: '' });
|
|
68
|
-
expect(action.instructions).to.equal('');
|
|
69
|
-
expect(action.input).to.equal('@input');
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
describe('action scenarios', () => {
|
|
73
|
-
helper.testAction({
|
|
74
|
-
uuid: 'test-action-1',
|
|
75
|
-
type: 'call_llm',
|
|
76
|
-
llm: { uuid: 'gpt-4', name: 'GPT 4.1' },
|
|
77
|
-
instructions: 'Translate to French',
|
|
78
|
-
input: '@input'
|
|
79
|
-
}, 'translation-task');
|
|
80
|
-
helper.testAction({
|
|
81
|
-
uuid: 'test-action-2',
|
|
82
|
-
type: 'call_llm',
|
|
83
|
-
llm: { uuid: 'gpt-5', name: 'GPT 5' },
|
|
84
|
-
instructions: 'Analyze the sentiment of the following message and classify it as positive, negative, or neutral. Provide a brief explanation for your classification.',
|
|
85
|
-
input: '@input'
|
|
86
|
-
}, 'sentiment-analysis');
|
|
87
|
-
helper.testAction({
|
|
88
|
-
uuid: 'test-action-3',
|
|
89
|
-
type: 'call_llm',
|
|
90
|
-
llm: { uuid: 'gpt-4', name: 'GPT 4.1' },
|
|
91
|
-
instructions: 'Summarize the key points from the conversation above in bullet format.',
|
|
92
|
-
input: '@input'
|
|
93
|
-
}, 'summarization');
|
|
94
|
-
helper.testAction({
|
|
95
|
-
uuid: 'test-action-4',
|
|
96
|
-
type: 'call_llm',
|
|
97
|
-
llm: { uuid: 'gpt-5', name: 'GPT 5' },
|
|
98
|
-
instructions: 'Extract any contact information (phone numbers, email addresses) from the text and format them as a JSON object.',
|
|
99
|
-
input: '@input'
|
|
100
|
-
}, 'information-extraction');
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
//# sourceMappingURL=call_llm.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"call_llm.test.js","sourceRoot":"","sources":["../../../test/actions/call_llm.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC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,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,UAAU;YAChB,GAAG,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;YACvC,YAAY,EAAE,qBAAqB;YACnC,KAAK,EAAE,QAAQ;SACL,EACZ,kBAAkB,CACnB,CAAC;QAEF,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,UAAU;YAChB,GAAG,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE;YACrC,YAAY,EACV,wJAAwJ;YAC1J,KAAK,EAAE,QAAQ;SACL,EACZ,oBAAoB,CACrB,CAAC;QAEF,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,UAAU;YAChB,GAAG,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;YACvC,YAAY,EACV,wEAAwE;YAC1E,KAAK,EAAE,QAAQ;SACL,EACZ,eAAe,CAChB,CAAC;QAEF,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,UAAU;YAChB,GAAG,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE;YACrC,YAAY,EACV,kHAAkH;YACpH,KAAK,EAAE,QAAQ;SACL,EACZ,wBAAwB,CACzB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { call_llm } from '../../src/flow/actions/call_llm';\nimport { CallLLM } from '../../src/store/flow-definition';\nimport { ActionTest } from '../ActionHelper';\n\n/**\n * Test suite for the call_llm action configuration.\n */\ndescribe('call_llm action config', () => {\n const helper = new ActionTest(call_llm, 'call_llm');\n\n describe('basic properties', () => {\n helper.testBasicProperties();\n\n it('has correct name', () => {\n expect(call_llm.name).to.equal('Call AI');\n });\n\n it('has form configuration', () => {\n expect(call_llm.form).to.exist;\n expect(call_llm.form.llm).to.exist;\n expect(call_llm.form.instructions).to.exist;\n expect(call_llm.form.input).to.exist;\n });\n\n it('has layout configuration', () => {\n expect(call_llm.layout).to.exist;\n expect(call_llm.layout).to.deep.equal(['llm', 'input', 'instructions']);\n });\n\n it('has data transformation functions', () => {\n expect(call_llm.toFormData).to.be.a('function');\n expect(call_llm.fromFormData).to.be.a('function');\n });\n });\n\n describe('data transformations', () => {\n it('converts action to form data correctly', () => {\n const action: CallLLM = {\n uuid: 'test-llm-1',\n type: 'call_llm',\n input: '@input',\n llm: { uuid: 'gpt-4', name: 'GPT 4.1' },\n instructions: 'Translate to French',\n result_name: 'translated_text'\n };\n\n const formData = call_llm.toFormData(action);\n\n expect(formData.uuid).to.equal('test-llm-1');\n expect(formData.llm).to.deep.equal([{ value: 'gpt-4', name: 'GPT 4.1' }]);\n expect(formData.instructions).to.equal('Translate to French');\n expect(formData.input).to.equal('@input');\n });\n\n it('converts form data to action correctly', () => {\n const formData = {\n uuid: 'test-llm-2',\n llm: [{ value: 'gpt-5', name: 'GPT 5' }],\n instructions: 'Summarize the following text',\n input: '@input'\n };\n\n const action = call_llm.fromFormData(formData) as CallLLM;\n\n expect(action.uuid).to.equal('test-llm-2');\n expect(action.type).to.equal('call_llm');\n expect(action.llm).to.deep.equal({ uuid: 'gpt-5', name: 'GPT 5' });\n expect(action.instructions).to.equal('Summarize the following text');\n expect(action.input).to.equal('@input');\n });\n\n it('handles empty form data', () => {\n const formData = {\n uuid: 'test-llm-3',\n llm: [],\n instructions: '',\n input: ''\n };\n\n const action = call_llm.fromFormData(formData) as CallLLM;\n\n expect(action.llm).to.deep.equal({ uuid: '', name: '' });\n expect(action.instructions).to.equal('');\n expect(action.input).to.equal('@input');\n });\n });\n\n describe('action scenarios', () => {\n helper.testAction(\n {\n uuid: 'test-action-1',\n type: 'call_llm',\n llm: { uuid: 'gpt-4', name: 'GPT 4.1' },\n instructions: 'Translate to French',\n input: '@input'\n } as CallLLM,\n 'translation-task'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-2',\n type: 'call_llm',\n llm: { uuid: 'gpt-5', name: 'GPT 5' },\n instructions:\n 'Analyze the sentiment of the following message and classify it as positive, negative, or neutral. Provide a brief explanation for your classification.',\n input: '@input'\n } as CallLLM,\n 'sentiment-analysis'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-3',\n type: 'call_llm',\n llm: { uuid: 'gpt-4', name: 'GPT 4.1' },\n instructions:\n 'Summarize the key points from the conversation above in bullet format.',\n input: '@input'\n } as CallLLM,\n 'summarization'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-4',\n type: 'call_llm',\n llm: { uuid: 'gpt-5', name: 'GPT 5' },\n instructions:\n 'Extract any contact information (phone numbers, email addresses) from the text and format them as a JSON object.',\n input: '@input'\n } as CallLLM,\n 'information-extraction'\n );\n });\n});\n"]}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { html } from 'lit-html';
|
|
2
|
-
import { ActionConfig, COLORS } from '../types';
|
|
3
|
-
import { Node, CallLLM } from '../../store/flow-definition';
|
|
4
|
-
|
|
5
|
-
export const call_llm: ActionConfig = {
|
|
6
|
-
name: 'Call AI',
|
|
7
|
-
color: COLORS.call,
|
|
8
|
-
render: (_node: Node, action: CallLLM) => {
|
|
9
|
-
return html`<div
|
|
10
|
-
style="word-wrap: break-word; overflow-wrap: break-word; hyphens: auto; max-width: 180px; max-height: 100px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical;"
|
|
11
|
-
>
|
|
12
|
-
${action.instructions}
|
|
13
|
-
</div>`;
|
|
14
|
-
},
|
|
15
|
-
form: {
|
|
16
|
-
llm: {
|
|
17
|
-
type: 'select',
|
|
18
|
-
required: true,
|
|
19
|
-
options: [],
|
|
20
|
-
endpoint: '/test-assets/select/llms.json',
|
|
21
|
-
searchable: true,
|
|
22
|
-
valueKey: 'uuid',
|
|
23
|
-
nameKey: 'name'
|
|
24
|
-
},
|
|
25
|
-
input: {
|
|
26
|
-
type: 'text',
|
|
27
|
-
required: true,
|
|
28
|
-
label: 'The input the AI will process',
|
|
29
|
-
evaluated: true,
|
|
30
|
-
placeholder: '@input'
|
|
31
|
-
},
|
|
32
|
-
instructions: {
|
|
33
|
-
type: 'textarea',
|
|
34
|
-
required: true,
|
|
35
|
-
label: 'Tell the AI what to do with the input',
|
|
36
|
-
evaluated: true,
|
|
37
|
-
placeholder: 'Enter instructions for the AI model...',
|
|
38
|
-
minHeight: 130,
|
|
39
|
-
helpText: 'The result can be referenced as **`@locals._llm_output`**'
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
layout: ['llm', 'input', 'instructions'],
|
|
43
|
-
toFormData: (action: CallLLM) => {
|
|
44
|
-
return {
|
|
45
|
-
uuid: action.uuid,
|
|
46
|
-
llm: action.llm
|
|
47
|
-
? [{ value: action.llm.uuid, name: action.llm.name }]
|
|
48
|
-
: [],
|
|
49
|
-
input: action.input || '@input',
|
|
50
|
-
instructions: action.instructions || ''
|
|
51
|
-
};
|
|
52
|
-
},
|
|
53
|
-
fromFormData: (data: Record<string, any>) => {
|
|
54
|
-
const llmSelection =
|
|
55
|
-
Array.isArray(data.llm) && data.llm.length > 0 ? data.llm[0] : null;
|
|
56
|
-
return {
|
|
57
|
-
uuid: data.uuid,
|
|
58
|
-
type: 'call_llm',
|
|
59
|
-
input: data.input || '@input',
|
|
60
|
-
llm: llmSelection
|
|
61
|
-
? { uuid: llmSelection.value, name: llmSelection.name }
|
|
62
|
-
: { uuid: '', name: '' },
|
|
63
|
-
instructions: data.instructions || ''
|
|
64
|
-
} as CallLLM;
|
|
65
|
-
}
|
|
66
|
-
};
|