Spaces:
Running
Running
Use a checkbox for boolean parameters.
Browse files- data/LynxScribe demo +94 -83
- server/lynxscribe_ops.py +5 -2
- server/ops.py +1 -1
- web/src/NodeParameter.svelte +21 -8
data/LynxScribe demo
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
"data": {
|
8 |
"title": "Input chat",
|
9 |
"params": {
|
10 |
-
"chat": "
|
11 |
},
|
12 |
"display": null,
|
13 |
"error": null,
|
@@ -37,8 +37,8 @@
|
|
37 |
}
|
38 |
},
|
39 |
"position": {
|
40 |
-
"x": -
|
41 |
-
"y":
|
42 |
},
|
43 |
"parentId": null
|
44 |
},
|
@@ -52,11 +52,11 @@
|
|
52 |
"dataframes": {
|
53 |
"df": {
|
54 |
"columns": [
|
55 |
-
"
|
56 |
],
|
57 |
"data": [
|
58 |
[
|
59 |
-
"
|
60 |
]
|
61 |
]
|
62 |
}
|
@@ -81,8 +81,8 @@
|
|
81 |
}
|
82 |
},
|
83 |
"position": {
|
84 |
-
"x":
|
85 |
-
"y":
|
86 |
},
|
87 |
"parentId": null
|
88 |
},
|
@@ -234,8 +234,8 @@
|
|
234 |
}
|
235 |
},
|
236 |
"position": {
|
237 |
-
"x": -
|
238 |
-
"y":
|
239 |
},
|
240 |
"parentId": null
|
241 |
},
|
@@ -305,7 +305,7 @@
|
|
305 |
"negative_answer": "I'm sorry, but the data I've been trained on does not contain any information related to your question.",
|
306 |
"limits_by_type": "{\"information\": [2, 3], \"summary\": [2, 3]}",
|
307 |
"strict_limits": true,
|
308 |
-
"max_results": 5
|
309 |
},
|
310 |
"display": null,
|
311 |
"error": null,
|
@@ -379,7 +379,7 @@
|
|
379 |
"beingResized": false
|
380 |
},
|
381 |
"position": {
|
382 |
-
"x": -
|
383 |
"y": 547.294980747757
|
384 |
},
|
385 |
"parentId": null,
|
@@ -662,52 +662,6 @@
|
|
662 |
},
|
663 |
"parentId": null
|
664 |
},
|
665 |
-
{
|
666 |
-
"id": "Test Chat API 1",
|
667 |
-
"type": "basic",
|
668 |
-
"data": {
|
669 |
-
"title": "Test Chat API",
|
670 |
-
"params": {},
|
671 |
-
"display": null,
|
672 |
-
"error": null,
|
673 |
-
"meta": {
|
674 |
-
"name": "Test Chat API",
|
675 |
-
"params": {},
|
676 |
-
"inputs": {
|
677 |
-
"message": {
|
678 |
-
"name": "message",
|
679 |
-
"type": {
|
680 |
-
"type": "<class 'inspect._empty'>"
|
681 |
-
},
|
682 |
-
"position": "left"
|
683 |
-
},
|
684 |
-
"chat_api": {
|
685 |
-
"name": "chat_api",
|
686 |
-
"type": {
|
687 |
-
"type": "<class 'inspect._empty'>"
|
688 |
-
},
|
689 |
-
"position": "bottom"
|
690 |
-
}
|
691 |
-
},
|
692 |
-
"outputs": {
|
693 |
-
"output": {
|
694 |
-
"name": "output",
|
695 |
-
"type": {
|
696 |
-
"type": "None"
|
697 |
-
},
|
698 |
-
"position": "right"
|
699 |
-
}
|
700 |
-
},
|
701 |
-
"type": "basic",
|
702 |
-
"sub_nodes": null
|
703 |
-
}
|
704 |
-
},
|
705 |
-
"position": {
|
706 |
-
"x": 30.070483767962628,
|
707 |
-
"y": 30.871931330853627
|
708 |
-
},
|
709 |
-
"parentId": null
|
710 |
-
},
|
711 |
{
|
712 |
"id": "Mask 1",
|
713 |
"type": "basic",
|
@@ -728,28 +682,28 @@
|
|
728 |
"name": "name",
|
729 |
"default": "",
|
730 |
"type": {
|
731 |
-
"type": "
|
732 |
}
|
733 |
},
|
734 |
"regex": {
|
735 |
"name": "regex",
|
736 |
"default": "",
|
737 |
"type": {
|
738 |
-
"type": "
|
739 |
}
|
740 |
},
|
741 |
"exceptions": {
|
742 |
"name": "exceptions",
|
743 |
"default": "",
|
744 |
"type": {
|
745 |
-
"type": "
|
746 |
}
|
747 |
},
|
748 |
"mask_pattern": {
|
749 |
"name": "mask_pattern",
|
750 |
"default": "",
|
751 |
"type": {
|
752 |
-
"type": "
|
753 |
}
|
754 |
}
|
755 |
},
|
@@ -793,28 +747,28 @@
|
|
793 |
"name": "name",
|
794 |
"default": "",
|
795 |
"type": {
|
796 |
-
"type": "
|
797 |
}
|
798 |
},
|
799 |
"regex": {
|
800 |
"name": "regex",
|
801 |
"default": "",
|
802 |
"type": {
|
803 |
-
"type": "
|
804 |
}
|
805 |
},
|
806 |
"exceptions": {
|
807 |
"name": "exceptions",
|
808 |
"default": "",
|
809 |
"type": {
|
810 |
-
"type": "
|
811 |
}
|
812 |
},
|
813 |
"mask_pattern": {
|
814 |
"name": "mask_pattern",
|
815 |
"default": "",
|
816 |
"type": {
|
817 |
-
"type": "
|
818 |
}
|
819 |
}
|
820 |
},
|
@@ -837,6 +791,63 @@
|
|
837 |
"y": 1034.8547191984255
|
838 |
},
|
839 |
"parentId": null
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
840 |
}
|
841 |
],
|
842 |
"edges": [
|
@@ -911,39 +922,39 @@
|
|
911 |
"targetHandle": "chat_processor"
|
912 |
},
|
913 |
{
|
914 |
-
"id": "xy-
|
915 |
-
"source": "
|
916 |
-
"target": "
|
917 |
"sourceHandle": "output",
|
918 |
-
"targetHandle": "
|
919 |
},
|
920 |
{
|
921 |
-
"id": "xy-
|
922 |
-
"source": "
|
923 |
-
"target": "
|
924 |
"sourceHandle": "output",
|
925 |
-
"targetHandle": "
|
926 |
},
|
927 |
{
|
928 |
-
"id": "xy-edge__Input chat 1output-Test Chat API
|
929 |
"source": "Input chat 1",
|
930 |
-
"target": "Test Chat API
|
931 |
"sourceHandle": "output",
|
932 |
"targetHandle": "message"
|
933 |
},
|
934 |
{
|
935 |
-
"id": "xy-
|
936 |
-
"source": "
|
937 |
-
"target": "
|
938 |
"sourceHandle": "output",
|
939 |
-
"targetHandle": "
|
940 |
},
|
941 |
{
|
942 |
-
"id": "xy-
|
943 |
-
"source": "
|
944 |
-
"target": "Chat
|
945 |
"sourceHandle": "output",
|
946 |
-
"targetHandle": "
|
947 |
}
|
948 |
]
|
949 |
}
|
|
|
7 |
"data": {
|
8 |
"title": "Input chat",
|
9 |
"params": {
|
10 |
+
"chat": "who is the CIO of Lynx?"
|
11 |
},
|
12 |
"display": null,
|
13 |
"error": null,
|
|
|
37 |
}
|
38 |
},
|
39 |
"position": {
|
40 |
+
"x": -383.5496596237119,
|
41 |
+
"y": 27.567899191800223
|
42 |
},
|
43 |
"parentId": null
|
44 |
},
|
|
|
52 |
"dataframes": {
|
53 |
"df": {
|
54 |
"columns": [
|
55 |
+
"answer"
|
56 |
],
|
57 |
"data": [
|
58 |
[
|
59 |
+
"The Chief Innovation Officer (CIO) of Lynx Analytics is Gabor Benedek. He is responsible for defining the methodological roadmap for the company's predictive analytics consulting and product development departments. If you need more specific information about his role, feel free to ask!\n\nPlease visit <a href='https://www.lynxanalytics.com/team-leadership' target='_blank'>https://www.lynxanalytics.com/team-leadership</a> for further information."
|
60 |
]
|
61 |
]
|
62 |
}
|
|
|
81 |
}
|
82 |
},
|
83 |
"position": {
|
84 |
+
"x": 722.1450069267316,
|
85 |
+
"y": -785.6076562320527
|
86 |
},
|
87 |
"parentId": null
|
88 |
},
|
|
|
234 |
}
|
235 |
},
|
236 |
"position": {
|
237 |
+
"x": -22.866663363810787,
|
238 |
+
"y": 258.20943122219336
|
239 |
},
|
240 |
"parentId": null
|
241 |
},
|
|
|
305 |
"negative_answer": "I'm sorry, but the data I've been trained on does not contain any information related to your question.",
|
306 |
"limits_by_type": "{\"information\": [2, 3], \"summary\": [2, 3]}",
|
307 |
"strict_limits": true,
|
308 |
+
"max_results": "5"
|
309 |
},
|
310 |
"display": null,
|
311 |
"error": null,
|
|
|
379 |
"beingResized": false
|
380 |
},
|
381 |
"position": {
|
382 |
+
"x": -533.1301830766971,
|
383 |
"y": 547.294980747757
|
384 |
},
|
385 |
"parentId": null,
|
|
|
662 |
},
|
663 |
"parentId": null
|
664 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
665 |
{
|
666 |
"id": "Mask 1",
|
667 |
"type": "basic",
|
|
|
682 |
"name": "name",
|
683 |
"default": "",
|
684 |
"type": {
|
685 |
+
"type": "<class 'str'>"
|
686 |
}
|
687 |
},
|
688 |
"regex": {
|
689 |
"name": "regex",
|
690 |
"default": "",
|
691 |
"type": {
|
692 |
+
"type": "<class 'str'>"
|
693 |
}
|
694 |
},
|
695 |
"exceptions": {
|
696 |
"name": "exceptions",
|
697 |
"default": "",
|
698 |
"type": {
|
699 |
+
"type": "<class 'str'>"
|
700 |
}
|
701 |
},
|
702 |
"mask_pattern": {
|
703 |
"name": "mask_pattern",
|
704 |
"default": "",
|
705 |
"type": {
|
706 |
+
"type": "<class 'str'>"
|
707 |
}
|
708 |
}
|
709 |
},
|
|
|
747 |
"name": "name",
|
748 |
"default": "",
|
749 |
"type": {
|
750 |
+
"type": "<class 'str'>"
|
751 |
}
|
752 |
},
|
753 |
"regex": {
|
754 |
"name": "regex",
|
755 |
"default": "",
|
756 |
"type": {
|
757 |
+
"type": "<class 'str'>"
|
758 |
}
|
759 |
},
|
760 |
"exceptions": {
|
761 |
"name": "exceptions",
|
762 |
"default": "",
|
763 |
"type": {
|
764 |
+
"type": "<class 'str'>"
|
765 |
}
|
766 |
},
|
767 |
"mask_pattern": {
|
768 |
"name": "mask_pattern",
|
769 |
"default": "",
|
770 |
"type": {
|
771 |
+
"type": "<class 'str'>"
|
772 |
}
|
773 |
}
|
774 |
},
|
|
|
791 |
"y": 1034.8547191984255
|
792 |
},
|
793 |
"parentId": null
|
794 |
+
},
|
795 |
+
{
|
796 |
+
"id": "Test Chat API 2",
|
797 |
+
"type": "basic",
|
798 |
+
"data": {
|
799 |
+
"title": "Test Chat API",
|
800 |
+
"params": {
|
801 |
+
"show_details": false
|
802 |
+
},
|
803 |
+
"display": null,
|
804 |
+
"error": null,
|
805 |
+
"meta": {
|
806 |
+
"name": "Test Chat API",
|
807 |
+
"params": {
|
808 |
+
"show_details": {
|
809 |
+
"name": "show_details",
|
810 |
+
"default": false,
|
811 |
+
"type": {
|
812 |
+
"type": "<class 'bool'>"
|
813 |
+
}
|
814 |
+
}
|
815 |
+
},
|
816 |
+
"inputs": {
|
817 |
+
"message": {
|
818 |
+
"name": "message",
|
819 |
+
"type": {
|
820 |
+
"type": "<class 'inspect._empty'>"
|
821 |
+
},
|
822 |
+
"position": "left"
|
823 |
+
},
|
824 |
+
"chat_api": {
|
825 |
+
"name": "chat_api",
|
826 |
+
"type": {
|
827 |
+
"type": "<class 'inspect._empty'>"
|
828 |
+
},
|
829 |
+
"position": "bottom"
|
830 |
+
}
|
831 |
+
},
|
832 |
+
"outputs": {
|
833 |
+
"output": {
|
834 |
+
"name": "output",
|
835 |
+
"type": {
|
836 |
+
"type": "None"
|
837 |
+
},
|
838 |
+
"position": "right"
|
839 |
+
}
|
840 |
+
},
|
841 |
+
"type": "basic",
|
842 |
+
"sub_nodes": null
|
843 |
+
},
|
844 |
+
"collapsed": false
|
845 |
+
},
|
846 |
+
"position": {
|
847 |
+
"x": -11.653333595036415,
|
848 |
+
"y": -0.9210389517918429
|
849 |
+
},
|
850 |
+
"parentId": null
|
851 |
}
|
852 |
],
|
853 |
"edges": [
|
|
|
922 |
"targetHandle": "chat_processor"
|
923 |
},
|
924 |
{
|
925 |
+
"id": "xy-edge__Mask 1output-Chat processor 1processor",
|
926 |
+
"source": "Mask 1",
|
927 |
+
"target": "Chat processor 1",
|
928 |
"sourceHandle": "output",
|
929 |
+
"targetHandle": "processor"
|
930 |
},
|
931 |
{
|
932 |
+
"id": "xy-edge__Mask 2output-Chat processor 1processor",
|
933 |
+
"source": "Mask 2",
|
934 |
+
"target": "Chat processor 1",
|
935 |
"sourceHandle": "output",
|
936 |
+
"targetHandle": "processor"
|
937 |
},
|
938 |
{
|
939 |
+
"id": "xy-edge__Input chat 1output-Test Chat API 2message",
|
940 |
"source": "Input chat 1",
|
941 |
+
"target": "Test Chat API 2",
|
942 |
"sourceHandle": "output",
|
943 |
"targetHandle": "message"
|
944 |
},
|
945 |
{
|
946 |
+
"id": "xy-edge__Test Chat API 2output-View 1input",
|
947 |
+
"source": "Test Chat API 2",
|
948 |
+
"target": "View 1",
|
949 |
"sourceHandle": "output",
|
950 |
+
"targetHandle": "input"
|
951 |
},
|
952 |
{
|
953 |
+
"id": "xy-edge__Chat API 1output-Test Chat API 2chat_api",
|
954 |
+
"source": "Chat API 1",
|
955 |
+
"target": "Test Chat API 2",
|
956 |
"sourceHandle": "output",
|
957 |
+
"targetHandle": "chat_api"
|
958 |
}
|
959 |
]
|
960 |
}
|
server/lynxscribe_ops.py
CHANGED
@@ -121,11 +121,14 @@ def mask(*, name='', regex='', exceptions='', mask_pattern=''):
|
|
121 |
|
122 |
@ops.input_position(chat_api="bottom")
|
123 |
@op("Test Chat API")
|
124 |
-
def test_chat_api(message, chat_api):
|
125 |
chat_api = chat_api[0]['chat_api']
|
126 |
request = ChatAPIRequest(session_id="b43215a0-428f-11ef-9454-0242ac120002", question=message['text'], history=[])
|
127 |
response = asyncio.run(chat_api.answer(request))
|
128 |
-
|
|
|
|
|
|
|
129 |
|
130 |
@op("Input chat")
|
131 |
def input_chat(*, chat: str):
|
|
|
121 |
|
122 |
@ops.input_position(chat_api="bottom")
|
123 |
@op("Test Chat API")
|
124 |
+
def test_chat_api(message, chat_api, *, show_details=False):
|
125 |
chat_api = chat_api[0]['chat_api']
|
126 |
request = ChatAPIRequest(session_id="b43215a0-428f-11ef-9454-0242ac120002", question=message['text'], history=[])
|
127 |
response = asyncio.run(chat_api.answer(request))
|
128 |
+
if show_details:
|
129 |
+
return {**response.__dict__}
|
130 |
+
else:
|
131 |
+
return {'answer': response.answer}
|
132 |
|
133 |
@op("Input chat")
|
134 |
def input_chat(*, chat: str):
|
server/ops.py
CHANGED
@@ -61,7 +61,7 @@ class Parameter(BaseConfig):
|
|
61 |
if default is inspect._empty:
|
62 |
default = None
|
63 |
if type is None or type is inspect._empty:
|
64 |
-
type = typeof(default) if default else None
|
65 |
return Parameter(name=name, default=default, type=type)
|
66 |
|
67 |
class Input(BaseConfig):
|
|
|
61 |
if default is inspect._empty:
|
62 |
default = None
|
63 |
if type is None or type is inspect._empty:
|
64 |
+
type = typeof(default) if default is not None else None
|
65 |
return Parameter(name=name, default=default, type=type)
|
66 |
|
67 |
class Input(BaseConfig):
|
web/src/NodeParameter.svelte
CHANGED
@@ -3,21 +3,24 @@
|
|
3 |
export let value;
|
4 |
export let meta;
|
5 |
export let onChange;
|
|
|
6 |
</script>
|
7 |
|
8 |
<label class="param">
|
9 |
-
<span class="param-name">{name.replace(/_/g, ' ')}</span>
|
10 |
{#if meta?.type?.format === 'collapsed'}
|
|
|
11 |
<button class="collapsed-param form-control form-control-sm">
|
12 |
⋯
|
13 |
</button>
|
14 |
{:else if meta?.type?.format === 'textarea'}
|
|
|
15 |
<textarea class="form-control form-control-sm"
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
{:else if meta?.type?.enum}
|
|
|
21 |
<select class="form-select form-select-sm"
|
22 |
value={value || meta.type.enum[0]}
|
23 |
on:change={(evt) => onChange(evt.currentTarget.value)}
|
@@ -26,11 +29,21 @@
|
|
26 |
<option value={option}>{option}</option>
|
27 |
{/each}
|
28 |
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
{:else}
|
|
|
30 |
<input class="form-control form-control-sm"
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
{/if}
|
35 |
</label>
|
36 |
|
|
|
3 |
export let value;
|
4 |
export let meta;
|
5 |
export let onChange;
|
6 |
+
const BOOLEAN = "<class 'bool'>";
|
7 |
</script>
|
8 |
|
9 |
<label class="param">
|
|
|
10 |
{#if meta?.type?.format === 'collapsed'}
|
11 |
+
<span class="param-name">{name.replace(/_/g, ' ')}</span>
|
12 |
<button class="collapsed-param form-control form-control-sm">
|
13 |
⋯
|
14 |
</button>
|
15 |
{:else if meta?.type?.format === 'textarea'}
|
16 |
+
<span class="param-name">{name.replace(/_/g, ' ')}</span>
|
17 |
<textarea class="form-control form-control-sm"
|
18 |
+
rows="6"
|
19 |
+
value={value}
|
20 |
+
on:change={(evt) => onChange(evt.currentTarget.value)}
|
21 |
+
/>
|
22 |
{:else if meta?.type?.enum}
|
23 |
+
<span class="param-name">{name.replace(/_/g, ' ')}</span>
|
24 |
<select class="form-select form-select-sm"
|
25 |
value={value || meta.type.enum[0]}
|
26 |
on:change={(evt) => onChange(evt.currentTarget.value)}
|
|
|
29 |
<option value={option}>{option}</option>
|
30 |
{/each}
|
31 |
</select>
|
32 |
+
{:else if meta?.type?.type === BOOLEAN}
|
33 |
+
<label class="form-check-label">
|
34 |
+
<input class="form-check-input"
|
35 |
+
type="checkbox"
|
36 |
+
checked={value}
|
37 |
+
on:change={(evt) => onChange(evt.currentTarget.checked)}
|
38 |
+
/>
|
39 |
+
{name.replace(/_/g, ' ')}
|
40 |
+
</label>
|
41 |
{:else}
|
42 |
+
<span class="param-name">{name.replace(/_/g, ' ')}</span>
|
43 |
<input class="form-control form-control-sm"
|
44 |
+
value={value}
|
45 |
+
on:change={(evt) => onChange(evt.currentTarget.value)}
|
46 |
+
/>
|
47 |
{/if}
|
48 |
</label>
|
49 |
|