Call Another Template

{{ maistro|template: "templateName" }}

Imports the contents of templateName into the current environment.

Example Usage 1

Given an example template, neuralseek_updates:

Based on the changelogs found here:
{{ web|url:"https://documentation.neuralseek.com/changelog/" }}
list the items for the latest month.
{{ LLM }}

Simply using {{ maistro|template: "neuralseek_updates" }} will produce the sample result.

Example Usage 2

To pass parameters to mAIstro templates, you simply define the variables in your current environment.

Given an example template, neuralseek_updates:

Based on the changelogs found here:
{{ web|url:"<< name:'url' >>" }}
list the items for the latest month.
{{ LLM }}

To pass the url variable to the template:

{{ variable  | name: "url" | value: "https://documentation.neuralseek.com/changelog/" }}

{{ maistro|template: "neuralseek_updates" }}

This allows templates to be brought into current context, effectively "splicing" the contents into the desired context.


Set Variable

Creates or sets a variable that can be used later in the NTL expression. For example,

34=>{{ variable | name:"age" }}
or
{{ variable  | name: "age" | value: "34" }}

Parameters

  • Name: The name of the variable to set.
  • Value: The optional (override) value to set to the variable.

No Returns


Use Variable

Syntax to use / expand a variable into the environment.

<< name: variableName, prompt: true >>

Parameters

  • Name: The name of the variable
  • Prompt: If set to true, the UI will prompt for the value for this variable. If set to false, the UI will avoid prompting for this variable.

Returns

  • The contents of the variable.

Note about variables

When the variable is NOT found but used in << >> notation, the variable is considered as user input, and mAIstro will prompt for the value prior to evaluation. For example, if you have << name: new >> or << name: new, prompt: true >> and there is not such thing as {{ variable|name: "new" }} in the expression, mAIstro will ask for it like this:

set_params


Stop

Stops all further processing. Full stop.

{{ stop }}

Loops: Start, End, Break

Start Loop

Denotes the beginning of a loop, and declares the maximum number of loops to perform.

{{ startLoop  | count: "3" }}

End Loop

Denotes the end of a loop. This does not stop the loop, but rather sends the execution back to the beginning if the total number of loops have not yet been reached.

{{ endLoop }}

Break Loop

Stops a loop early. Useful with the condition node.

{{ breakLoop }}
Example Usage
{{ variable  | name: "count" | mode: "" | value: "0" }}
{{ startLoop  | count: "5" }}
{{ math  | equation: "<< name: count >> + 1" }}=>{{ variable  | name: "count" }}
{{ endLoop  }}
The count is now: << name: count >>

Will Yield:

The count is now: 6

Note

The number of loops assigned in startLoop is the number of additional times the nodes will be executed. As seen above, the middle node (math) will be executed a total of 6 times - Once to begin, and then 5 more times (the number of loops set).


Variable Loop

The Variable Loop function allows us to loop arrays, nested arrays, or JSON objects. You can use this feature to format arrays nicely or to take action on the contents during each loop.

{{ variableLoop  | variable: "categories" | loopType: "array-strings" }}
Example Usage 1
{"looper": ["a","b","c"]}=>{{ jsonToVars  }}
{{ variableLoop  | variable: "looper" | loopType: "" }}
was the passed input.
{{ variable  | name: "myVar" | mode: "append" }}
{{ endLoop  }}
<< name: myVar, prompt: false >>

Will yield:

a 
was the passed input.
b 
was the passed input.
c 
was the passed input.
Example Usage 2
{"messages": [
  {
    "message": "Hello, how can I assist you today?",
    "sender": "Assistant",
    "timestamp": "2023-04-12T10:30:00Z"
  },
  {
    "message": "I'm doing well, thanks for asking. How can I help you?",
    "sender": "User",
    "timestamp": "2023-04-12T10:30:15Z"
  },
  {
    "message": "I'm afraid I don't have a specific task for you at the moment. I'm just here to chat and help out however I can.",
    "sender": "Assistant",
    "timestamp": "2023-04-12T10:30:30Z"
  },
  {
    "message": "That's great, I appreciate your availability. I was wondering if you could help me with a project I'm working on.",
    "sender": "User",
    "timestamp": "2023-04-12T10:30:45Z"
  },
  {
    "message": "Absolutely, I'd be happy to assist you with your project. Please go ahead and provide me with the details, and I'll do my best to help.",
    "sender": "Assistant",
    "timestamp": "2023-04-12T10:31:00Z"
  }
]}=>{{ jsonToVars  }}
{{ variableLoop  | variable: "messages" | loopType: "array-objects" }}
[<< name: loopObject.timestamp, prompt: false >>] << name: loopObject.sender, prompt: false >>: << name: loopObject.message, prompt: false >>
{{ variable  | name: "messagesFormatted" | mode: "append" }}
{{ endLoop  }}
<< name: messagesFormatted, prompt: false >>

Will yield:

[2023-04-12T10:30:00Z] Assistant: Hello, how can I assist you today?
[2023-04-12T10:30:15Z] User: I'm doing well, thanks for asking. How can I help you?
[2023-04-12T10:30:30Z] Assistant: I'm afraid I don't have a specific task for you at the moment. I'm just here to chat and help out however I can.
[2023-04-12T10:30:45Z] User: That's great, I appreciate your availability. I was wondering if you could help me with a project I'm working on.
[2023-04-12T10:31:00Z] Assistant: Absolutely, I'd be happy to assist you with your project. Please go ahead and provide me with the details, and I'll do my best to help.

Condition

The Conditional function allows us to direct the flow of operations.

{{ condition | value: "1 == 1" }}

Parameters

  • Value: The conditional / logic to evaluate. Supports the following:
  • Common comparison operators like ==, !=, >, <, >=, <=, <>.
  • Common mathematical operators like +, -, /, * wrapped within parenthesis ().
  • Logical functions:
    • IF: Ternary operator: IF(condition or function, truevalue, falsevalue)
    • NOT: Inverse operator: NOT(condition)
    • AND: Logical and: AND(condition, condition) - Accepts 2 or more conditions
    • OR: Logical or: OR(condition, condition) - Accepts 2 or more conditions
  • String comparisons:
    • Using single-quoted strings, you can use equality conditions == and !=.
    • CONTAINS: You can check for substrings: CONTAINS('long string to check', 'string')
    • LENGTH: You can evaluate the length of a string to use in conditions: LENGTH('string') (this example evaluates to 6)
    • Variables must be wrapped in single quotes for comparison or substring check.

Returns

No returns, however:

  • A condition that evaluates to 'true' will continue the horizontal chain.
  • A condition that evaluates to 'false' will stop the horizontal chain from executing and continue to the next flow step.
Example usage

Example set 1: Basic

{{ condition  | value: "1 == 1" }}=>This is true!

Will yield the output text: This is true!

{{ condition  | value: "(5 + 5) == 10" }}=>This is true!

Will yield the output text: This is true!

Example set 2: OR, AND

{{ condition  | value: "OR(1==1, 2==3, 1==2, 1==1)" }}=>This is true!

Will continue the chain and yield the output text: This is true!.

{{ condition  | value: "AND(1==1, 2==2, 3==3, 4==4)" }}=>This is true!

Will continue the chain and yield the output text: This is true!.

{{ condition  | value: "OR(1==2,2==3)" }}=>This is true!

Will stop the chain and yield no output, as the chain was blocked with a false condition.

Example set 3: Strings

{{ condition  | value: "'name' == 'name'" }}=>This is true!

Will yield the output text: This is true!

{{ condition  | value: "CONTAINS('this is a test string', 'test')" }}=>This is true!
{{ condition  | value: "CONTAINS('<< name: variableContainingTest, prompt: false >>', 'test')" }}=>This is true!

Both will yield the output text: This is true!

{{ condition  | value: "LENGTH('Hello World') > 5" }}=>This is true!

Will yield the output text: This is true!

{{ condition  | value: "(LENGTH('<< name: variableContainingTest, prompt: false >>') + 12) > 10" }}=>This is true!

Will yield the output text: This is true!

For more: See the "Conditional Logic" Example Template for a working example on routing chains based on a variable value:

Conditional mAIstro Example


Ⓒ 2024 NeuralSeek, all rights reserved.