@loopstack/prompt-example-workflow
v0.20.6
Published
A simple workflow showing how to integrate an LLM using a simple prompt pattern.
Downloads
457
Maintainers
Readme
@loopstack/prompt-example-workflow
A module for the Loopstack AI automation framework.
This module provides an example workflow demonstrating how to integrate an LLM using a simple prompt pattern.
Overview
The Prompt Example Workflow shows the most basic way to call an LLM in Loopstack—using a simple text prompt. It generates a haiku about a user-provided subject.
By using this workflow as a reference, you'll learn how to:
- Define workflow input arguments with default values
- Use the
promptparameter for simple LLM calls - Interpolate arguments into prompts using template syntax
- Access tool results via the
runtimeobject - Display LLM responses as documents
This example is the ideal starting point for developers new to LLM integration in Loopstack.
Installation
See SETUP.md for installation and setup instructions.
How It Works
Key Concepts
1. Workflow Input
Define input parameters with default values using @Input:
@Input({
schema: z.object({
subject: z.string().default('coffee'),
}),
})
args: {
subject: string;
};Configure the UI form in YAML:
ui:
form:
properties:
subject:
title: 'What should the haiku be about?'2. Simple Prompt Pattern
Use the prompt parameter for straightforward LLM calls without conversation history. The tool call is given an id so its result can be referenced later:
- id: prompt
from: start
to: prompt_executed
call:
- id: llm_call
tool: aiGenerateText
args:
llm:
provider: openai
model: gpt-4o
prompt: Write a haiku about {{ args.subject }}3. Accessing Results via Runtime
Instead of using assign to save results to workflow state, tool results are accessed through the runtime object. The path follows the pattern runtime.tools.<transitionId>.<toolCallId>.data:
- id: add_response
from: prompt_executed
to: end
call:
- tool: createDocument
args:
document: aiMessageDocument
update:
content: ${{ runtime.tools.prompt.llm_call.data }}The TypeScript class declares the runtime types with the @Runtime() decorator:
@Runtime()
runtime: {
tools: Record<'prompt', Record<'llm_call', ToolResult<AiMessageDocumentContentType>>>;
};4. Argument Interpolation
Access workflow arguments in templates using args.<name>:
prompt: Write a haiku about {{ args.subject }}Dependencies
This workflow uses the following Loopstack modules:
@loopstack/core- Core framework functionality@loopstack/core-ui-module- ProvidesCreateDocumenttool@loopstack/ai-module- ProvidesAiGenerateTexttool andAiMessageDocument
About
Author: Jakob Klippel
License: Apache-2.0
Additional Resources
- Loopstack Documentation
- Getting Started with Loopstack
- Find more Loopstack examples in the Loopstack Registry
