Skip to main content

Overview

A Chat Block takes in a single Prompt input which can be a single message, or an array of messages that forms the message chain. The Assemble Prompt Block is used to assemble multiple chat messages into a single prompt. It takes multiple chat messages or strings as inputs and outputs a single prompt containing all the messages. If a string is connected to any of the inputs, it will be converted to a User type chat message with the string as the message. Assemble Prompt Block Screenshot

Inputs

TitleData TypeDescriptionDefault ValueNotes
Message [i]chat-message, chat-message[]The ith chat message input to be assembledN/ADynamic number of inputs based on how many connections there are

Example: Assembling Multiple Chat Messages

Let’s say you have two Prompt blocks: one with the the AI’s text “How can I assist you today?” and the user’s response “Hello”. If you want to assemble these two messages into a single prompt to feed into a Chat Block, you can do the following:
  1. Add an Assemble Prompt Block to your flow.
  2. Connect the output of the first Prompt block (AI’s message) to Message 1 of the Assemble Prompt Block.
  3. Connect the output of the second Prompt block (user’s response) to Message 2 of the Assemble Prompt Block.
  4. Connect the output of the Assemble Prompt Block to the Prompt input of a Chat Block.

Example: Appending Chat Messages in a Loop

A common use case for the Assemble Prompt Block is to append chat messages in a loop. This can be achieved by using a Loop Controller Block in conjunction with the Assemble Prompt Block. Here’s how you can set this up:
  1. Add a Loop Controller Block to your flow.
  2. Add an Assemble Prompt Block to your flow.
  3. Connect the Output 1 of the Loop Controller Block to Input 1 of the Assemble Prompt Block. This will feed the output of the loop back into the Assemble Prompt Block.
  4. Connect the Output 1 of the Assemble Prompt Block to Input 1 of the Loop Controller Block. This will effectively create a feedback loop where the Assemble Prompt Block feeds back into itself.
  5. Connect your first message to Input 1 Default of the Loop Controller Block. This will be the initial message that starts the loop.
  6. Any additional messages that you want to append during each loop iteration can be connected to Input 2, Input 3, etc of the Assemble Prompt Block.
The Assemble Prompt Block will flatten the output, resulting in a list of the current messages. During each loop iteration, the Assemble Prompt Block will append any additional messages connected to its inputs. This setup allows you to dynamically append chat messages in a loop, which can be useful in various scenarios such as creating a chatbot that can carry on a conversation with a user. Note: If you want to control the number of loop iterations, you can do so by setting the Max Iterations property of the Loop Controller Block. Here’s a diagram to help visualize the setup: Loop Controller with Assemble Prompt Block This example demonstrates the power and flexibility of Odella’s block-based system, allowing you to create complex behaviors with just a few blocks.

Handling Missing Inputs

If an input is missing or not a chat message, the Assemble Prompt Block will simply ignore it during the assembling process. This can be useful when dealing with optional inputs that may not always be present.

Error Handling

If no valid chat message inputs are provided, the output will be an empty array. Q: What happens if I connect a non-chat message to the Assemble Prompt Block? A: The Assemble Prompt Block is designed to work with chat message inputs. If a non-chat message input is connected, the block will attempt to convert it to a chat message. In most cases, this will be a User type message with message being the data converted to a string. If this conversion isn’t possible, the input will be ignored during the assembling process. Q: Can I connect an Array Block to the Assemble Prompt Block? A: Yes, you can connect an Array Block to the Assemble Prompt Block. Each element of the array will be treated as a separate chat message to be assembled (flattens the array). Q: How does the Assemble Prompt Block handle empty strings or null values? A: The Assemble Prompt Block will ignore any inputs that are null or not a chat message. Empty chat messages, however, will be included in the assembling operation.

See Also