-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
51 lines (42 loc) · 1.93 KB
/
Copy pathindex.js
File metadata and controls
51 lines (42 loc) · 1.93 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
const { CodeGuide } = require('@codeguide/core');
async function main() {
console.log('🚀 CodeGuide Development Mode Example');
console.log('===================================\n');
// Initialize CodeGuide with configuration
const codeguide = new CodeGuide({
baseUrl: 'https://api.codeguide.app',
// Note: You'll need to provide actual API keys for real usage
// databaseApiKey: 'sk_your_database_api_key'
// apiKey: 'your_legacy_api_key',
// userId: 'your_user_id',
// jwtToken: 'your_jwt_token'
});
try {
// Check API health
console.log('🔍 Checking API health...');
const isHealthy = await codeguide.isHealthy();
console.log(`Health Status: ${isHealthy ? '✅ Healthy' : '❌ Unhealthy'}\n`);
// Example usage (will fail without valid API key, but shows the structure)
console.log('💬 Example: Asking for code guidance...');
console.log('Note: This will fail without valid authentication\n');
try {
const response = await codeguide.getGuidance('How to create a React component in TypeScript?');
console.log('Response:', response.response);
} catch (error) {
console.log('Expected error (no API key configured):', error.message);
}
console.log('\n📚 Available Services:');
console.log('- generation: Prompt refinement and code generation');
console.log('- projects: Project management');
console.log('- usage: Usage tracking and credit management');
console.log('- repositoryAnalysis: Repository analysis');
console.log('- tasks: Task management');
console.log('\n🔧 To use with real API calls:');
console.log('1. Set up API keys in environment variables');
console.log('2. Or pass them directly to the CodeGuide constructor');
console.log('3. Use the CLI: codeguide ask "your question" --database-api-key sk_your_key');
} catch (error) {
console.error('❌ Error:', error.message);
}
}
main().catch(console.error);