LooseDataValue
Description
LooseDataValue is the convenience input type accepted by graph inputs and context values in run options. It can be a full DataValue, or a primitive string, number, or boolean.
Definition
type LooseDataValue = DataValue | string | number | boolean;
Explanation
Rivet converts primitive loose values before the graph runs:
| Input value | Converted DataValue |
|---|---|
'hello' | { type: 'string', value: 'hello' } |
42 | { type: 'number', value: 42 } |
true | { type: 'boolean', value: true } |
Use a full DataValue when you need objects, arrays, chat messages, images, binary data, documents, vectors, or any other non-primitive graph value.
Usage
LooseDataValue is used for inputs and context values in RunGraphOptions:
await runGraph(project, {
graph: 'Main',
inputs: {
prompt: 'Write a haiku',
maxLines: 3,
includeTitle: true,
metadata: {
type: 'object',
value: { audience: 'internal' },
},
},
});
null and undefined are not LooseDataValue primitives. If a graph input is optional, omit it and let the Graph Input node use its default value.