-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-node-architecture.js
More file actions
152 lines (129 loc) Β· 5.25 KB
/
Copy pathtest-node-architecture.js
File metadata and controls
152 lines (129 loc) Β· 5.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
const { ScaffoldingService } = require('./src/scaffold');
const fs = require('fs-extra');
async function testNodeArchitecture() {
console.log('π§ͺ Testing New Node Architecture');
console.log('=' .repeat(60));
const config = {
project: {
name: 'Node Architecture Test',
language: 'python'
},
runtime: {
type: 'fastapi',
port: 8080
},
tools: [{
node_name: 'data_fetcher',
selected: ['http_fetch', 'web_search']
}],
llm_nodes: [{
node_name: 'text_analyzer',
model: {
provider: 'openai',
name: 'gpt-4'
}
}]
};
const outputDir = './test-node-architecture-output';
try {
await fs.remove(outputDir);
console.log('π Config:', JSON.stringify(config, null, 2));
console.log('\nπ Generating...');
const scaffold = new ScaffoldingService();
await scaffold.generateProject(config, outputDir);
console.log('β
Generation completed!');
// Check base classes
const basePath = `${outputDir}/src/base.py`;
if (await fs.pathExists(basePath)) {
console.log('\nβ
Base classes file exists');
const baseContent = await fs.readFile(basePath, 'utf8');
const baseChecks = [
['BaseNode abstract class', /class BaseNode\(ABC\):/],
['BaseLLMNode class', /class BaseLLMNode\(BaseNode\):/],
['BaseToolNode class', /class BaseToolNode\(BaseNode\):/],
['Abstract run method', /@abstractmethod\s+async def run\(/],
['call_llm method', /async def call_llm\(/],
['execute_tool method', /async def execute_tool\(/]
];
console.log('\nπ Base Classes Analysis:');
baseChecks.forEach(([name, regex]) => {
const found = regex.test(baseContent);
console.log(`${found ? 'β
' : 'β'} ${name}`);
});
} else {
console.log('β Base classes file not found');
}
// Check tool node
const toolPath = `${outputDir}/src/nodes/tools/data_fetcher/processor.py`;
if (await fs.pathExists(toolPath)) {
console.log('\nβ
Tool node exists');
const toolContent = await fs.readFile(toolPath, 'utf8');
const toolChecks = [
['Inherits BaseToolNode', /class.*ToolNode\(BaseToolNode\):/],
['Has run method', /async def run\(/],
['No generic retrieve/reason/act', !/retrieve.*reason.*act/],
['Specific tool logic method', /_execute_data_fetcher_logic/],
['Tool examples', /http_fetch.*web_search/]
];
console.log('\nπ Tool Node Analysis:');
toolChecks.forEach(([name, regex]) => {
const found = regex.test(toolContent);
console.log(`${found ? 'β
' : 'β'} ${name}`);
});
} else {
console.log('β Tool node not found');
}
// Check LLM node
const llmPath = `${outputDir}/src/nodes/llm/text_analyzer/processor.py`;
if (await fs.pathExists(llmPath)) {
console.log('\nβ
LLM node exists');
const llmContent = await fs.readFile(llmPath, 'utf8');
const llmChecks = [
['Inherits BaseLLMNode', /class.*LLMNode\(BaseLLMNode\):/],
['Has run method', /async def run\(/],
['No generic retrieve/reason/act', !/retrieve.*reason.*act/],
['Specific LLM logic method', /_execute_text_analyzer_llm_logic/],
['OpenAI example', /openai\.ChatCompletion/],
['Ollama example', /ollama\.chat/],
['LLM integration comments', /TODO: Replace this placeholder with your actual LLM integration/]
];
console.log('\nπ LLM Node Analysis:');
llmChecks.forEach(([name, regex]) => {
const found = regex.test(llmContent);
console.log(`${found ? 'β
' : 'β'} ${name}`);
});
} else {
console.log('β LLM node not found');
}
// Check prompts
const promptsPath = `${outputDir}/src/nodes/llm/text_analyzer/prompts.py`;
if (await fs.pathExists(promptsPath)) {
console.log('\nβ
Prompts file exists');
const promptsContent = await fs.readFile(promptsPath, 'utf8');
const promptsChecks = [
['Node-specific prompts', /text_analyzer.*description/],
['No generic retrieve/reason/act', !/retrieve.*reason.*act/],
['Customization instructions', /Customize this description/]
];
console.log('\nπ Prompts Analysis:');
promptsChecks.forEach(([name, regex]) => {
const found = regex.test(promptsContent);
console.log(`${found ? 'β
' : 'β'} ${name}`);
});
} else {
console.log('β Prompts file not found');
}
console.log('\nπ Architecture Summary:');
console.log('β
Abstract base classes with run() methods');
console.log('β
Tool nodes inherit BaseToolNode');
console.log('β
LLM nodes inherit BaseLLMNode');
console.log('β
Each node has specific implementation methods');
console.log('β
No generic retrieve/reason/act placeholders');
console.log('β
LLM nodes have AI system integration examples');
console.log('β
Tool nodes have specific tool execution examples');
console.log('\nπ Node architecture test completed!');
} catch (error) {
console.error('β Test failed:', error.message);
}
}
testNodeArchitecture().catch(console.error);