Expression Language
LangStream uses an expression language to reference fields of a LangStream record. See Structure of a record for more on the parts of a record.
The expression language is required to evaluate the conditional step when
or the compute step expression
. The syntax is EL, which uses dot notation to access field properties or map keys.
For example, when the query-vector-db agent queries a Pinecone vector database, the agent uses the expression language to reference the values in "embeddings" and "query-result" with "value.embeddings" and "value.query-result".
Operators
The Expression Language supports the following operators:
Arithmetic: +, - (binary), *, / and div, % and mod, - (unary)
Logical: and, &&, or, ||, not, !
Relational: ==, eq, !=, ne, <, lt, >, gt, <=, ge, >=, le.
Functions
Utility methods available under the fn
namespace. For example, to get the current timestamp, use fn:now()
. The Expression Language supports the following functions:
Conditional when steps
Each step accepts an optional when
configuration that is evaluated at step execution time. For example, the Dispatch agent evaluates the output from the language-detector agent and routes messages based on whether the value in the "properties.language" field is "en" or "fr". If neither, it routes to default-topic.
Use the .
operator to access top level or nested properties on a schema-full key or value.
For example, properties.language
or properties.language.nestedValueField
.
The when
condition supports the expression language syntax by providing access to the record fields below:
Last updated