Extract User-provided Values
Extract User-provided Values
This guide teaches you how to extract user-provided values (for example, a name, a date, a query) from a user utterance and store them in context variables. You can then use these values in bot responses or follow-up logic.
Overview
Colang 2.0
Colang 1.0
In Colang 2.0, you use Natural Language Descriptions (NLD) with the generation operator (...) to extract values. The NLD is placed inline after the ... operator:
The NLD together with the variable name is interpreted by the LLM directly. Be specific about the format and type you expect.
... is not a placeholder; it is the actual syntax (the generation operator).
Single Values
You can extract single values from user input:
Colang 2.0
Colang 1.0
Lists of Values
You can instruct the LLM to extract a list of values:
Colang 2.0
Colang 1.0
Multiple Values
You can extract values for multiple variables from the same user input:
Colang 2.0
Colang 1.0
Contextual Queries
This mechanism can enable contextual queries. For example, to answer math questions using Wolfram Alpha with follow-up context:
Example conversation:
Colang 2.0
Colang 1.0
Best Practices
Colang 2.0
Colang 1.0
Be specific in your NLDs:
Use variables in NLDs for context: