AgenticFlow AI: ChatGPT in the Flow of Work
HomeCommunityDiscordLogin
  • Get Started
    • AgenticFlow - Build agents that handle sales, marketing, and creative tasks around the clock.
    • Introduction to Large Language Models
    • Templates
    • AgenticFlow MCP
    • API Keys
    • Workflows quickstart
    • Agents quickstart
    • Plans and Credits
    • System Quotas
    • FAQs
    • Affiliate program 💵
  • AGENTS
    • Introduction to agents
    • Agent Templates
    • Create an Agent
    • Customize an Agent
    • Tools and Integrations
  • Workflows
    • Introduction
    • Workflow Templates
    • Creating a Workflow
    • User Inputs - Get Started
      • Text Input
      • Long text input
      • Drop-down
      • Numeric Input
      • File to URL
      • File to Text
      • Checkbox
      • Image Input
      • Audio Input
      • Video Input
      • Multiple Media Input
      • Carousel Select Input
    • Actions - Get Started
      • LLM
        • LLM - Advanced Settings
        • Validators
        • Too Much Text
        • LLM Prompt
        • LLM Output
      • Code - JavaScript
      • Code - Python
      • Python Helper Functions
      • PDF to text
      • Extract Website Content
      • Knowledge Search
      • Audio/Video to Text
      • Insert Data into a Dataset
    • Knowledge
    • Workflow Single Run
    • Workflow Table Run
    • Export Results
    • API Run
    • Parameter Substitution Utility
  • Data
    • Introduction
    • Data Table
  • Use Cases
    • Summarization
      • GPT on My Files
      • GPT on My Website
      • Question-Answering on Data
    • Research
      • Sentiment Analysis
      • Anonymize Text
      • Audio Transcription + High-Level Analysis
  • Sales
    • Teach LLMs to Mimic Your Style
  • Marketing
    • SEO Optimize
    • Automating Creativity Transforming Workflow with AgenticFlow AI (PDF)
  • Policies
    • Security Overview
      • AI Policy
      • Reporting bugs and vulnerabilities
      • Subprocessors
      • DPA
    • Privacy Policy
    • Terms of Service
    • Cookies Policy
  • Advanced Topics
    • Advanced Topics
Powered by GitBook
On this page
  • Understanding LLM Output
  • Converting LLM Output

Was this helpful?

  1. Workflows
  2. Actions - Get Started
  3. LLM

LLM Output

Large Language Model (LLM) Output

How to use the LLM step output in other steps

Understanding LLM Output

An LLM step produces an output based on the provided inputs and the instructions given in the prompt. It is important to note that even if your instruction specifies to "produce a list of items," "generate a JSON object," or "write a number between x and y," the output is always a string that only resembles a list, a JSON object, or a number.

LLM Output is Always a String

LLM outputs are always of type string. Therefore, even if they resemble a list, a JSON object, a number, or a Boolean, you must convert the output from a string to the actual type when necessary.

Example Explanation

For non-programmers, consider this example to understand the difference more easily: A string is just a chain of characters with a simple underlying structure. For instance, the text you are reading now is composed of characters forming words and sentences, but it is just a continuous sequence of characters.

A JSON object, however, is a structured set of key-value pairs. In the JSON object below, you can access the person’s information using the keys (Name, Last name, and Age):

{
    "Name": "Jack",
    "Last name": "Smith",
    "Age": 28
}

If an LLM outputs the same object as a string, there will be no underlying structure to access any of the keys or values. A string version of the above JSON object might look like this:

'{"Name":"Jack","Last name":"Smith","Age":28}'

To be able to work with the output further, you will need to convert it to the desired format.

Converting LLM Output

String to JSON

When instructing an LLM to generate a JSON object, it is recommended to also set up the is_json validator. Next, use a "Convert string to JSON" action. Feed the LLM output to the converter component, which will generate the corresponding JSON object.

Example

// JavaScript example
const jsonString = '{"Name":"Jack","Last name":"Smith","Age":28}';
const jsonObject = JSON.parse(jsonString);
console.log(jsonObject.Name); // Output: Jack

String to List

Use a coding step (JavaScript or Python) to handle the conversion. Feed the LLM output to your code step, apply the transformation (e.g., split(separator) in JavaScript), and return the value.

Example

// JavaScript example
const listString = "apple,banana,orange";
const listArray = listString.split(",");
console.log(listArray); // Output: ["apple", "banana", "orange"]

String to Numbers or Booleans

Use a coding step (JavaScript or Python) to handle the conversion. For numbers, apply the parser (e.g., parseInt(stringValue) in JavaScript) and return the results. For Booleans, use a conditional statement (if ... else ...) to return the corresponding Boolean value (true or false).

Example

// JavaScript example for number
const numberString = "123";
const number = parseInt(numberString);
console.log(number); // Output: 123

// JavaScript example for Boolean
const booleanString = "true";
const booleanValue = (booleanString === "true");
console.log(booleanValue); // Output: true

By following these guidelines, you can effectively handle and convert LLM outputs to the desired formats, ensuring smooth integration and processing within your workflows.

PreviousLLM PromptNextCode - JavaScript

Last updated 5 hours ago

Was this helpful?