qtools-ai-two-step-sample
v1.0.1
Published
A simple two-step AI processing example using qtools-ai-framework
Maintainers
Readme
qtoolsAiTwoStepSample
A simple example application demonstrating the qtools-ai-framework with a two-step AI processing pipeline.
Overview
This application demonstrates how to create a minimal AI processing application using the qtools-ai-framework. It processes user input through two sequential steps:
- Create Something - Takes a user prompt and generates initial content
- Revise That Thing - Takes the generated content and modifies it based on a revision prompt
Installation
npm installUsage
node qtoolsAiTwoStepSample.js --creatingPrompt="tell me a one sentence story" --revisingPrompt="Make it talk like a pirate"Parameters
--creatingPrompt(required) - The initial prompt for content creation--revisingPrompt(required) - The prompt for revising the created content--debug(optional) - Enable debug logging to see intermediate steps
Examples
Basic usage:
node qtoolsAiTwoStepSample.js --creatingPrompt="write a haiku about coffee" --revisingPrompt="make it rhyme better"With debug output:
node qtoolsAiTwoStepSample.js --creatingPrompt="describe a sunset" --revisingPrompt="make it more poetic" --debugSample Output:
Once upon a fine time, th' scurvyre be a fine brave knight who saved th' scurvy kingdom, arrr! Yo ho ho!Environment Variables
Note: The current implementation uses simple text transformations instead of actual AI calls. To use real AI, you would need to:
- Set your OpenAI API key:
export OPENAI_API_KEY=your_api_key_here- Update the thinkers to use the provided
promptGeneratorandaccessSmartyPantsfunctions instead of the simplified text transformations.
Architecture
The application follows the qtools-ai-framework pattern with wisdom-bus architecture:
- Main Application (
qtoolsAiTwoStepSample.js) - Entry point and CLI handling - Configuration (
qtoolsAiTwoStepSample.ini) - Thought process and thinker definitions - Thinkers (
lib/thinkers/) - Processing modules using wisdom-bus for data flow - Prompt Library (
lib/prompt-library/) - AI prompt templates - Wisdom-Bus - Thread-safe data management system for sharing data between thinkers
Project Structure
qtoolsAiTwoStepSample/
├── qtoolsAiTwoStepSample.js # Main application
├── qtoolsAiTwoStepSample.ini # Configuration
├── package.json # Dependencies
├── README.md # This file
└── lib/
├── thinkers/
│ ├── create-something/
│ │ └── create-something.js
│ └── revise-that-thing/
│ └── revise-that-thing.js
└── prompt-library/
├── onlyPrompts.js
└── prompts.d/
└── onlyPrompts/
├── create-something.js
└── revise-that-thing.jsHow It Works
- User provides creating and revising prompts via command line
- Framework initializes with configuration from
.inifile and creates wisdom-bus - Initial prompts are stored in wisdom-bus as
initialThinkerData create-somethingthinker:- Reads
creatingPromptfrom wisdom-bus usingwisdomBus.getAll() - Generates content using AI
- Stores result as
lastAiResponseusingwisdomBus.add()
- Reads
revise-that-thingthinker:- Reads both
lastAiResponseandrevisingPromptfrom wisdom-bus - Processes revision using AI
- Updates
lastAiResponsewith revised content
- Reads both
- Final consolidated wisdom is output to stdout via
xLog.result()
Wisdom-Bus Data Flow
The wisdom-bus ensures thread-safe data sharing between thinkers:
// Thinker reads data
const currentWisdom = wisdomBus.getAll();
const inputData = currentWisdom.someKey;
// Thinker processes and adds results
const result = processData(inputData);
wisdomBus.add('outputKey', result);Each thinker gets its own namespaced accessor, preventing data collisions while allowing access to shared data from previous thinkers.
This serves as a template for building more complex AI processing applications with the qtools-ai-framework wisdom-bus architecture.
