Putting It All Together
Before moving on to domains and namespace resolution, here is a complete bundle that uses both operators and controllers. It shows how concepts, pipes, and working memory flow together.
domain = "joke_generation"
description = "Generating one-liner jokes from topics"
main_pipe = "generate_jokes_from_topics"
[concept.Topic]
description = "A subject or theme that can be used as the basis for a joke."
refines = "Text"
[concept.Joke]
description = "A humorous one-liner intended to make people laugh."
refines = "Text"
[pipe.generate_jokes_from_topics]
type = "PipeSequence"
description = "Generate 3 joke topics and create a joke for each"
output = "Joke[]"
steps = [
{ pipe = "generate_topics", result = "topics" },
{ pipe = "batch_generate_jokes", result = "jokes" },
]
[pipe.generate_topics]
type = "PipeLLM"
description = "Generate 3 distinct topics suitable for jokes"
output = "Topic[3]"
prompt = "Generate 3 distinct and varied topics for crafting one-liner jokes."
[pipe.batch_generate_jokes]
type = "PipeBatch"
description = "Generate a joke for each topic"
inputs = { topics = "Topic[]" }
output = "Joke[]"
branch_pipe_code = "generate_joke"
input_list_name = "topics"
input_item_name = "topic"
[pipe.generate_joke]
type = "PipeLLM"
description = "Write a clever one-liner joke about the given topic"
inputs = { topic = "Topic" }
output = "Joke"
prompt = "Write a clever one-liner joke about $topic. Be concise and witty."
How It Works
generate_jokes_from_topicsis aPipeSequence— the entry point.- Step 1 calls
generate_topics, aPipeLLMthat produces exactly 3Topicitems (Topic[3]). The result is stored in working memory astopics. - Step 2 calls
batch_generate_jokes, aPipeBatchthat iterates overtopics. For eachTopic, it invokesgenerate_joke. generate_jokeis aPipeLLMthat takes onetopicand produces oneJoke.- The batch collects all jokes into
Joke[], which becomes the final output.
The concepts (Topic and Joke) both refine the native Text concept. The pipes — a sequence, a batch, and LLM operators — work together through working memory.