@valerypopoff/rivet2-core 2.0.4 → 2.0.6

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.
@@ -3,9 +3,8 @@ import { nanoid } from 'nanoid/non-secure';
3
3
  import { NodeImpl } from '../NodeImpl.js';
4
4
  import { nodeDefinition } from '../NodeDefinition.js';
5
5
  import {} from '../../index.js';
6
- import { mapValues } from 'lodash-es';
7
6
  import { dedent } from 'ts-dedent';
8
- import { coerceType, coerceTypeOptional } from '../../utils/coerceType.js';
7
+ import { coerceTypeOptional } from '../../utils/coerceType.js';
9
8
  import { getInputOrData } from '../../utils/index.js';
10
9
  import { interpolate, extractInterpolationVariables } from '../../utils/interpolation.js';
11
10
  import { match } from 'ts-pattern';
@@ -110,6 +109,14 @@ export class PromptNodeImpl extends NodeImpl {
110
109
  dataKey: 'type',
111
110
  useInputToggleDataKey: 'useTypeInput',
112
111
  },
112
+ {
113
+ type: 'code',
114
+ label: 'Prompt Text',
115
+ dataKey: 'promptText',
116
+ language: 'prompt-interpolation-markdown',
117
+ theme: 'prompt-interpolation',
118
+ showTextStats: true,
119
+ },
113
120
  {
114
121
  type: 'string',
115
122
  label: 'Name',
@@ -136,13 +143,6 @@ export class PromptNodeImpl extends NodeImpl {
136
143
  helperMessage: 'For Anthropic, marks this message as a cache breakpoint - this message and every message before it will be cached using Prompt Caching.',
137
144
  useInputToggleDataKey: 'useIsCacheBreakpointInput',
138
145
  },
139
- {
140
- type: 'code',
141
- label: 'Prompt Text',
142
- dataKey: 'promptText',
143
- language: 'prompt-interpolation-markdown',
144
- theme: 'prompt-interpolation',
145
- },
146
146
  ];
147
147
  }
148
148
  getBody() {
@@ -174,7 +174,10 @@ export class PromptNodeImpl extends NodeImpl {
174
174
  };
175
175
  }
176
176
  async process(inputs, context) {
177
- const inputMap = mapValues(inputs, (input) => coerceType(input, 'string'));
177
+ const inputMap = Object.keys(inputs).reduce((acc, key) => {
178
+ acc[key] = coerceTypeOptional(inputs[key], 'string') ?? '';
179
+ return acc;
180
+ }, {});
178
181
  const outputValue = interpolate(this.chartNode.data.promptText, inputMap, context.graphInputNodeValues, context.contextValues);
179
182
  const type = getInputOrData(this.data, inputs, 'type', 'string');
180
183
  const isCacheBreakpoint = getInputOrData(this.data, inputs, 'isCacheBreakpoint', 'boolean');
@@ -74,6 +74,7 @@ export class TextNodeImpl extends NodeImpl {
74
74
  dataKey: 'text',
75
75
  language: 'prompt-interpolation-markdown',
76
76
  theme: 'prompt-interpolation',
77
+ showTextStats: true,
77
78
  },
78
79
  {
79
80
  type: 'toggle',
@@ -90,6 +90,7 @@ export type CodeEditorDefinition<T extends ChartNode> = SharedEditorDefinitionPr
90
90
  theme?: string;
91
91
  height?: number;
92
92
  enableFolding?: boolean;
93
+ showTextStats?: boolean;
93
94
  };
94
95
  export type ColorEditorDefinition<T extends ChartNode> = SharedEditorDefinitionProps<T> & {
95
96
  type: 'color';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valerypopoff/rivet2-core",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "license": "MIT",
5
5
  "main": "dist/cjs/bundle.cjs",
6
6
  "module": "dist/esm/index.js",