-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest-langchain-integration.js
More file actions
131 lines (112 loc) · 4.57 KB
/
test-langchain-integration.js
File metadata and controls
131 lines (112 loc) · 4.57 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
#!/usr/bin/env node
/**
* Simple test script to verify LangChain integration works
* without full compilation issues
*/
import fs from 'fs';
import path from 'path';
async function testLangChainIntegration() {
console.log("🚀 Testing LangChain Integration Status...\n");
// Test 1: Check if LangChain packages are available
console.log("1. Checking LangChain package availability:");
try {
const { ChatOpenAI } = await import('@langchain/openai');
const { HumanMessage } = await import('@langchain/core/messages');
console.log(" ✅ @langchain/core: Available");
console.log(" ✅ @langchain/openai: Available");
console.log(" ✅ langchain: Available");
} catch (error) {
console.log(" ❌ LangChain packages missing:", error.message);
}
// Test 2: Check if our LangChain services exist
console.log("\n2. Checking LangChain service files:");
const langchainFiles = [
'src/services/enhancements/langchain-content-enhancer.ts',
'src/services/compilation/langchain-compiler.ts',
'src/handlers/database/langchain-semantic-layer.ts',
'src/services/realtime/langchain-writing-assistant.ts',
'src/analysis/langchain-analytics-pipeline.ts',
'src/services/optimization/langchain-intelligent-cache.ts',
'src/services/agents/langchain-multi-agent.ts',
'src/services/learning/langchain-continuous-learning.ts'
];
langchainFiles.forEach(file => {
if (fs.existsSync(file)) {
console.log(` ✅ ${path.basename(file)}: Created`);
} else {
console.log(` ❌ ${path.basename(file)}: Missing`);
}
});
// Test 3: Check if handlers are updated with LangChain integration
console.log("\n3. Checking handler integration:");
const handlerFiles = [
'src/handlers/analysis-handlers.ts',
'src/handlers/compilation-handlers.ts',
'src/handlers/search-handlers.ts'
];
handlerFiles.forEach(file => {
if (fs.existsSync(file)) {
const content = fs.readFileSync(file, 'utf8');
const hasLangChainImports = content.includes('LangChain') || content.includes('langchain');
const hasEnhancedHandlers = content.includes('enhanced: true');
console.log(` ${path.basename(file)}:`);
console.log(` ${hasLangChainImports ? '✅' : '❌'} LangChain imports`);
console.log(` ${hasEnhancedHandlers ? '✅' : '❌'} Enhanced handlers`);
} else {
console.log(` ❌ ${path.basename(file)}: Missing`);
}
});
// Test 4: Check new MCP tool definitions
console.log("\n4. New LangChain MCP Tools Available:");
const toolPatterns = [
'multi_agent_analysis',
'semantic_search',
'start_realtime_assistance',
'collect_feedback',
'intelligent_compilation',
'generate_marketing_materials',
'build_vector_store',
'vector_search',
'find_mentions',
'cross_reference_analysis'
];
let toolsFound = 0;
handlerFiles.forEach(file => {
if (fs.existsSync(file)) {
const content = fs.readFileSync(file, 'utf8');
toolPatterns.forEach(pattern => {
if (content.includes(pattern)) {
console.log(` ✅ ${pattern}: Available`);
toolsFound++;
}
});
}
});
console.log(`\n Found ${toolsFound}/${toolPatterns.length} new LangChain-powered tools`);
// Test 5: Integration status summary
console.log("\n📊 LangChain Integration Status Summary:");
console.log("=" .repeat(50));
const integrationScore = (toolsFound / toolPatterns.length) * 100;
if (integrationScore >= 80) {
console.log("🎉 INTEGRATION STATUS: EXCELLENT");
console.log(` ${Math.round(integrationScore)}% of advanced features implemented`);
console.log(" ✅ LangChain services created");
console.log(" ✅ Handlers enhanced with LangChain");
console.log(" ✅ New advanced tools available");
console.log(" ✅ Continuous learning system integrated");
} else if (integrationScore >= 60) {
console.log("✅ INTEGRATION STATUS: GOOD");
console.log(` ${Math.round(integrationScore)}% of advanced features implemented`);
} else {
console.log("⚠️ INTEGRATION STATUS: NEEDS WORK");
console.log(` ${Math.round(integrationScore)}% of advanced features implemented`);
}
console.log("\n🔧 Next Steps:");
console.log(" 1. Fix TypeScript compilation errors");
console.log(" 2. Test individual LangChain services");
console.log(" 3. Verify MCP tool functionality");
console.log(" 4. Test end-to-end user workflows");
console.log("\n✨ LangChain Integration Test Complete!");
}
// Run the test
testLangChainIntegration().catch(console.error);