darabos commited on
Commit
52ec402
·
1 Parent(s): b7a4f8b

Boxes for Marton's chatbot flow. Visual tweaks.

Browse files
server/lynxscribe_ops.py CHANGED
@@ -13,3 +13,39 @@ reg('PII removal')
13
  reg('Intent classification')
14
  reg('System prompt', inputs={}, params=[P('prompt', 'You are a helpful chatbot.')])
15
  reg('LLM', inputs={'multi': '*'}, params=[P.options('backend', ['GPT-4', 'Yi-34b', 'Claude 3 Opus', 'Google Gemini'])])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  reg('Intent classification')
14
  reg('System prompt', inputs={}, params=[P('prompt', 'You are a helpful chatbot.')])
15
  reg('LLM', inputs={'multi': '*'}, params=[P.options('backend', ['GPT-4', 'Yi-34b', 'Claude 3 Opus', 'Google Gemini'])])
16
+
17
+ # From Marton's mock-up.
18
+ yi = 'Yi-34B (triton)'
19
+ reg('Chat Input', inputs={}, params=[
20
+ P.options('load_mode', ['augmented']),
21
+ P.options('model', [yi]),
22
+ P.options('embedder', ['GritLM-7b (triton)']),
23
+ ])
24
+ reg('k-NN Intent Classifier', inputs={'qa_embs': None, 'rag_graph': None}, params=[
25
+ P.options('distance', ['cosine', 'euclidean']),
26
+ P('max_dist', 0.3),
27
+ P('k', 3),
28
+ P.options('voting', ['most common', 'weighted']),
29
+ ])
30
+ reg('Chroma Graph RAG Loader', inputs={}, params=[
31
+ P.options('location', ['GCP']),
32
+ P.collapsed('bucket', ''),
33
+ P.collapsed('folder', ''),
34
+ P.options('embedder', ['GritLM-7b (triton)']),
35
+ ])
36
+ reg('Scenario Builder', params=[
37
+ P.collapsed('scenario', ''),
38
+ ])
39
+ reg('Graph RAG Answer', inputs={'qa_embs': None, 'intent': None, 'rag_graph': None, 'prompt_dict': None}, params=[
40
+ P.options('answer_llm', [yi]),
41
+ P('faq_dist', 0.12),
42
+ P('max_dist', 0.25),
43
+ P('ctx_tokens', 2800),
44
+ P.options('distance', ['cosine', 'euclidean']),
45
+ P.collapsed('graph_rag_params', ''),
46
+ ])
47
+ reg('Answer Post Processing', inputs={'qa_embs': None, 'rag_graph': None}, params=[
48
+ P.options('distance', ['cosine', 'euclidean']),
49
+ P('min_conf', 0.78),
50
+ ])
51
+ reg('Chat Output', outputs={})
server/ops.py CHANGED
@@ -9,6 +9,7 @@ import typing
9
 
10
  ALL_OPS = {}
11
  PARAM_TYPE = type[typing.Any]
 
12
 
13
  @dataclasses.dataclass
14
  class Parameter:
@@ -18,8 +19,13 @@ class Parameter:
18
  type: PARAM_TYPE = None
19
 
20
  @staticmethod
21
- def options(name, options):
22
- return Parameter(name, options[0], enum.Enum(f'OptionsFor{name}', options))
 
 
 
 
 
23
 
24
  def __post_init__(self):
25
  if self.default is inspect._empty:
@@ -27,13 +33,16 @@ class Parameter:
27
  if self.type is None or self.type is inspect._empty:
28
  self.type = type(self.default)
29
  def to_json(self):
 
 
30
  if isinstance(self.type, type) and issubclass(self.type, enum.Enum):
31
  t = {'enum': list(self.type.__members__.keys())}
32
- else:
33
- t = str(self.type)
 
34
  return {
35
  'name': self.name,
36
- 'default': self.default,
37
  'type': t,
38
  }
39
 
 
9
 
10
  ALL_OPS = {}
11
  PARAM_TYPE = type[typing.Any]
12
+ typeof = type # We have some arguments called "type".
13
 
14
  @dataclasses.dataclass
15
  class Parameter:
 
19
  type: PARAM_TYPE = None
20
 
21
  @staticmethod
22
+ def options(name, options, default=None):
23
+ e = enum.Enum(f'OptionsFor_{name}', options)
24
+ return Parameter(name, e[default or options[0]], e)
25
+
26
+ @staticmethod
27
+ def collapsed(name, default, type=None):
28
+ return Parameter(name, default, ('collapsed', type or typeof(default)))
29
 
30
  def __post_init__(self):
31
  if self.default is inspect._empty:
 
33
  if self.type is None or self.type is inspect._empty:
34
  self.type = type(self.default)
35
  def to_json(self):
36
+ t = str(self.type)
37
+ default = self.default
38
  if isinstance(self.type, type) and issubclass(self.type, enum.Enum):
39
  t = {'enum': list(self.type.__members__.keys())}
40
+ default = self.default.name if self.default else t['enum'][0]
41
+ if isinstance(self.type, tuple) and self.type[0] == 'collapsed':
42
+ t = {'collapsed': str(self.type[1])}
43
  return {
44
  'name': self.name,
45
+ 'default': default,
46
  'type': t,
47
  }
48
 
web/src/LynxKiteNode.svelte CHANGED
@@ -38,7 +38,8 @@
38
  <div class="lynxkite-node" style={nodeStyle}>
39
  <div class="title" on:click={titleClicked}>
40
  {data.title}
41
- {#if data.error}<span class="error-sign">⚠️</span>{/if}
 
42
  </div>
43
  {#if expanded}
44
  {#if data.error}
@@ -49,12 +50,16 @@
49
  {#each inputs as [name, input], i}
50
  <Handle
51
  id={name} type="target" position={targetPosition || 'left'}
52
- style="{handleOffsetDirection[targetPosition || 'left']}: {100 * (i + 1) / (inputs.length + 1)}%" />
 
 
53
  {/each}
54
  {#each outputs as [name, output], i}
55
  <Handle
56
  id={name} type="source" position={sourcePosition || 'right'}
57
- style="{handleOffsetDirection[sourcePosition || 'right']}: {100 * (i + 1) / (outputs.length + 1)}%" />
 
 
58
  {/each}
59
  </div>
60
  </div>
@@ -65,7 +70,7 @@
65
  padding: 8px;
66
  font-size: 12px;
67
  }
68
- .error-sign {
69
  float: right;
70
  }
71
  .node-container {
@@ -86,4 +91,24 @@
86
  font-weight: bold;
87
  padding: 8px;
88
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  </style>
 
38
  <div class="lynxkite-node" style={nodeStyle}>
39
  <div class="title" on:click={titleClicked}>
40
  {data.title}
41
+ {#if data.error}<span class="title-icon">⚠️</span>{/if}
42
+ {#if !expanded}<span class="title-icon">⋯</span>{/if}
43
  </div>
44
  {#if expanded}
45
  {#if data.error}
 
50
  {#each inputs as [name, input], i}
51
  <Handle
52
  id={name} type="target" position={targetPosition || 'left'}
53
+ style="{handleOffsetDirection[targetPosition || 'left']}: {100 * (i + 1) / (inputs.length + 1)}%">
54
+ {#if inputs.length>1}<span class="handle-name">{name.replace("_", " ")}</span>{/if}
55
+ </Handle>
56
  {/each}
57
  {#each outputs as [name, output], i}
58
  <Handle
59
  id={name} type="source" position={sourcePosition || 'right'}
60
+ style="{handleOffsetDirection[sourcePosition || 'right']}: {100 * (i + 1) / (outputs.length + 1)}%">
61
+ {#if outputs.length>1}<span class="handle-name">{name.replace("_", " ")}</span>{/if}
62
+ </Handle>
63
  {/each}
64
  </div>
65
  </div>
 
70
  padding: 8px;
71
  font-size: 12px;
72
  }
73
+ .title-icon {
74
  float: right;
75
  }
76
  .node-container {
 
91
  font-weight: bold;
92
  padding: 8px;
93
  }
94
+ .handle-name {
95
+ font-size: 12px;
96
+ color: #840;
97
+ text-align: right;
98
+ white-space: nowrap;
99
+ position: absolute;
100
+ top: -5px;
101
+ -webkit-text-stroke: 5px white;
102
+ paint-order: stroke fill;
103
+ visibility: hidden;
104
+ }
105
+ :global(.left) .handle-name {
106
+ right: 15px;
107
+ }
108
+ :global(.right) .handle-name {
109
+ left: 15px;
110
+ }
111
+ .node-container:hover .handle-name {
112
+ visibility: visible;
113
+ }
114
  </style>
web/src/NodeParameter.svelte CHANGED
@@ -7,8 +7,12 @@
7
 
8
  <div class="param">
9
  <label>
10
- {name}<br>
11
- {#if meta?.type?.enum}
 
 
 
 
12
  <select
13
  value={value}
14
  on:change={(evt) => onChange(evt.currentTarget.value)}
@@ -28,14 +32,31 @@
28
 
29
  <style>
30
  .param {
31
- padding: 8px;
32
  }
33
  .param label {
34
  font-size: 12px;
35
  display: block;
36
  }
37
- .param input,
38
- .param select {
 
 
39
  width: calc(100% - 8px);
40
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  </style>
 
7
 
8
  <div class="param">
9
  <label>
10
+ <span class="param-name">{name.replace('_', ' ')}</span>
11
+ {#if meta?.type?.collapsed}
12
+ <button class="collapsed-param">
13
+
14
+ </button>
15
+ {:else if meta?.type?.enum}
16
  <select
17
  value={value}
18
  on:change={(evt) => onChange(evt.currentTarget.value)}
 
32
 
33
  <style>
34
  .param {
35
+ padding: 0 8px 8px 8px;
36
  }
37
  .param label {
38
  font-size: 12px;
39
  display: block;
40
  }
41
+ .param-name {
42
+ color: #840;
43
+ }
44
+ .param input {
45
  width: calc(100% - 8px);
46
  }
47
+ .param select {
48
+ width: 100%;
49
+ }
50
+ .param input,
51
+ .param select,
52
+ .param button {
53
+ border: 1px solid #840;
54
+ border-radius: 4px;
55
+ }
56
+ .collapsed-param {
57
+ width: 100%;
58
+ font-family: auto;
59
+ font-size: 200%;
60
+ line-height: 0.5;
61
+ }
62
  </style>
web/src/NodeWithArea.svelte CHANGED
@@ -5,7 +5,6 @@
5
 
6
  type $$Props = NodeProps;
7
 
8
- export let nodeStyle = '';
9
  export let containerStyle = '';
10
  export let id: $$Props['id']; id;
11
  export let data: $$Props['data'];
 
5
 
6
  type $$Props = NodeProps;
7
 
 
8
  export let containerStyle = '';
9
  export let id: $$Props['id']; id;
10
  export let data: $$Props['data'];