forked from google-gemini/gemini-cli
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtrust-test.js
More file actions
150 lines (130 loc) · 4.39 KB
/
Copy pathtrust-test.js
File metadata and controls
150 lines (130 loc) · 4.39 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
#!/usr/bin/env node
/**
* Simple test CLI for Trust
*/
import {
TrustConfiguration,
TrustContentGenerator,
AuthType,
createContentGenerator,
} from './packages/core/dist/index.js';
async function main() {
const args = process.argv.slice(2);
const command = args[0];
if (!command) {
console.log(`
🛡️ TrustCLI - Local-first AI Assistant
Usage:
node trust-test.js models List available models
node trust-test.js config Show configuration
node trust-test.js recommend <task> Get model recommendation
node trust-test.js chat <message> Test chat (placeholder)
Examples:
node trust-test.js models
node trust-test.js recommend coding
node trust-test.js config
`);
return;
}
try {
const config = new TrustConfiguration();
await config.initialize();
switch (command) {
case 'models':
await showModels(config);
break;
case 'config':
await showConfig(config);
break;
case 'recommend':
await recommendModel(config, args[1] || 'default');
break;
case 'chat':
await testChat(config, args.slice(1).join(' '));
break;
default:
console.log(`❌ Unknown command: ${command}`);
process.exit(1);
}
} catch (error) {
console.error('❌ Error:', error.message);
process.exit(1);
}
}
async function showModels(config) {
const { TrustModelManagerImpl } = await import(
'./packages/core/dist/index.js'
);
const modelManager = new TrustModelManagerImpl(config.getModelsDirectory());
await modelManager.initialize();
const models = modelManager.listAvailableModels();
const currentModel = modelManager.getCurrentModel();
console.log('\n📦 Available Models:');
console.log('─'.repeat(60));
models.forEach((model) => {
const current = currentModel?.name === model.name ? ' (current)' : '';
console.log(`${model.name}${current}`);
console.log(
` Size: ${model.parameters} | RAM: ${model.ramRequirement} | Trust: ${model.trustScore}/10`,
);
console.log(` ${model.description}`);
console.log();
});
}
async function showConfig(config) {
const settings = config.get();
console.log('\n⚙️ Trust Configuration:');
console.log('─'.repeat(40));
console.log(`Default Model: ${settings.models.default}`);
console.log(`Models Directory: ${settings.models.directory}`);
console.log(`Privacy Mode: ${settings.privacy.privacyMode}`);
console.log(
`Model Verification: ${settings.privacy.modelVerification ? 'enabled' : 'disabled'}`,
);
console.log(
`Audit Logging: ${settings.privacy.auditLogging ? 'enabled' : 'disabled'}`,
);
console.log();
console.log('Inference Settings:');
console.log(` Temperature: ${settings.inference.temperature}`);
console.log(` Max Tokens: ${settings.inference.maxTokens}`);
console.log(
` Streaming: ${settings.inference.stream ? 'enabled' : 'disabled'}`,
);
console.log();
}
async function recommendModel(config, task) {
const { TrustModelManagerImpl } = await import(
'./packages/core/dist/index.js'
);
const modelManager = new TrustModelManagerImpl(config.getModelsDirectory());
await modelManager.initialize();
const recommended = modelManager.getRecommendedModel(task, 16); // Assume 16GB available
console.log(`\n🎯 Recommended model for "${task}":`);
if (recommended) {
console.log(`${recommended.name} - ${recommended.description}`);
console.log(`RAM requirement: ${recommended.ramRequirement}`);
console.log(`Trust score: ${recommended.trustScore}/10`);
} else {
console.log('No suitable model found for your requirements.');
}
console.log();
}
async function testChat(config, message) {
if (!message) {
console.log('❌ Please provide a message to chat with.');
return;
}
console.log(`\n💬 Testing chat with Trust (placeholder mode):`);
console.log(`User: ${message}`);
console.log(
`Assistant: I'm a placeholder response! The actual model isn't loaded yet, but the Trust system is ready. To enable real chat, download a model file and update the system to load it.`,
);
console.log();
console.log('📝 To enable real chat:');
console.log(' 1. Download a model file (e.g., from Hugging Face)');
console.log(' 2. Place it in the models directory');
console.log(' 3. The system will automatically detect and use it');
console.log();
}
main().catch(console.error);