build_prompt

A tool to build a prompt dynamically based on provided templates and values. If a template or value is not provided, the corresponding section will be skipped.

Arguments

NameTypeDescriptionRequired

prompt_templates

array

A list of objects each containing a template string and a value to insert.

prompt_templates.check_exists

boolean, string, array

If True, the template will be included if the content is not None.

prompt_templates.template

string

The template string to insert the value into. To insert content, use {content}.

prompt_templates.content

prompt, prompt array

The value to insert into the template. If this is an array, the elements will be joined with double newlines.

Returns

TypeDescription

prompt

A dynamically constructed prompt based on the provided templates and values.

Example

- name: build_prompt
  arguments:
    prompt_templates:
      - check_exists: '{{directive_content}}'
        template: |
          # Directive:
          ```
          {content}
          ```
        content: '{{directive_content}}'
      - check_exists: '{{view_content}}'
        template: |
          # View:
          ```
          {content}
          ```
        content: '{{view_content}}'
      - check_exists: '{{controller_content}}'
        template: |
          # Controller:
          ```
          {content}
          ```
        content: '{{controller_content}}'
  returns: <constructed-prompt>

Last updated