Rename LLM service to Intent service and refactor relevant code
Refactored the `DummyLlmService` to `DummyIntentService` across the codebase for clarity and consistency. Updated variable names, method calls, and documentation to align with this change. This improves code readability and better reflects the service's purpose.
This commit is contained in:
41
bin.js
41
bin.js
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import {
|
||||
DummyLlmService,
|
||||
DummyIntentService,
|
||||
ManifoldRegion,
|
||||
WorkflowFunctionManifold,
|
||||
WorkflowOperator,
|
||||
@@ -9,45 +9,33 @@ import {
|
||||
} from './lib.js';
|
||||
|
||||
async function demonstrateNestedManifold() {
|
||||
console.log('\n🚀 Starting Nested Manifold Demonstration\n');
|
||||
|
||||
console.log('📦 Creating Secondary Manifold...');
|
||||
const nestedLlm = new DummyLlmService();
|
||||
const nestedManifold = new WorkflowFunctionManifold(nestedLlm);
|
||||
const nestedIntentService = new DummyIntentService();
|
||||
const nestedManifold = new WorkflowFunctionManifold(nestedIntentService);
|
||||
|
||||
const validateOp = new WorkflowOperator('validation', async state => {
|
||||
console.log(' ✓ Validating data structure');
|
||||
return { ...state, validated: true };
|
||||
});
|
||||
|
||||
const cleanOp = new WorkflowOperator('cleaning', async state => {
|
||||
console.log(' ✓ Cleaning data');
|
||||
return { ...state, cleaned: true };
|
||||
});
|
||||
|
||||
const validateRegion = new ManifoldRegion('validation', [validateOp]);
|
||||
const cleanRegion = new ManifoldRegion('cleaning', [cleanOp]);
|
||||
|
||||
// Set up nested manifold regions
|
||||
validateRegion.connectTo(cleanRegion);
|
||||
nestedManifold.addRegion(validateRegion);
|
||||
nestedManifold.addRegion(cleanRegion);
|
||||
|
||||
console.log('📦 Creating Primary Manifold...');
|
||||
const mainLlm = new DummyLlmService();
|
||||
const mainManifold = new WorkflowFunctionManifold(mainLlm);
|
||||
const mainIntentService = new DummyIntentService();
|
||||
const mainManifold = new WorkflowFunctionManifold(mainIntentService);
|
||||
|
||||
const analysisOp = new WorkflowOperator('analysis', async state => {
|
||||
console.log(' ✓ Performing data analysis');
|
||||
return { ...state, analyzed: true };
|
||||
});
|
||||
|
||||
const transformOp = new WorkflowOperator('transformation', async state => {
|
||||
console.log(' ✓ Transforming results');
|
||||
return { ...state, transformed: true };
|
||||
});
|
||||
|
||||
// Set up main manifold regions
|
||||
const nestedPreprocessRegion = new NestedManifoldRegion('preprocessing', nestedManifold);
|
||||
const analysisRegion = new ManifoldRegion('analysis', [analysisOp]);
|
||||
const transformRegion = new ManifoldRegion('transformation', [transformOp]);
|
||||
@@ -59,8 +47,6 @@ async function demonstrateNestedManifold() {
|
||||
mainManifold.addRegion(analysisRegion);
|
||||
mainManifold.addRegion(transformRegion);
|
||||
|
||||
console.log('\n🔄 Executing Workflow...\n');
|
||||
|
||||
const prompts = [
|
||||
{ text: 'validate the input', description: 'Nested: Data Validation' },
|
||||
{ text: 'clean the data', description: 'Nested: Data Cleaning' },
|
||||
@@ -69,31 +55,24 @@ async function demonstrateNestedManifold() {
|
||||
];
|
||||
|
||||
for (const { text, description } of prompts) {
|
||||
console.log(`📍 Step: ${description}\n Prompt: "${text}"`);
|
||||
|
||||
try {
|
||||
// First try to navigate
|
||||
const navigated = await mainManifold.navigate(text);
|
||||
if (navigated) {
|
||||
console.log(' ↪ Navigation successful');
|
||||
console.log(`📍 Step: ${description}`);
|
||||
}
|
||||
|
||||
// Then execute the workflow
|
||||
const executed = await mainManifold.executeWorkflow(text);
|
||||
if (executed) {
|
||||
console.log(' ✅ Execution complete\n');
|
||||
console.log(`✅ Execution complete`);
|
||||
} else {
|
||||
console.log(' ❌ Execution failed - No matching operator found\n');
|
||||
console.log(`⚠️ Execution failed`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(` ❌ Error: ${error.message}\n`);
|
||||
console.error(`❌ Error: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('🎉 Workflow Demonstration Complete!\n');
|
||||
}
|
||||
|
||||
demonstrateNestedManifold().catch(error => {
|
||||
console.error('❌ Fatal Error:', error);
|
||||
console.error(`❌ Critical Error: ${error.message}`);
|
||||
process.exit(1);
|
||||
});
|
Reference in New Issue
Block a user