english-optimizer-cli 1.3.0 โ 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/dist/config/test.js +93 -0
- package/dist/index.js +13 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -220,8 +220,18 @@ fuck-abc config
|
|
|
220
220
|
|
|
221
221
|
# Run interactive setup wizard
|
|
222
222
|
fuck-abc config --setup
|
|
223
|
+
|
|
224
|
+
# Test API configuration
|
|
225
|
+
fuck-abc test
|
|
223
226
|
```
|
|
224
227
|
|
|
228
|
+
The test command will:
|
|
229
|
+
|
|
230
|
+
- Verify your API configuration is valid
|
|
231
|
+
- Test connection to the API provider
|
|
232
|
+
- Run a simple optimization test
|
|
233
|
+
- Show detailed error messages if something is wrong
|
|
234
|
+
|
|
225
235
|
The setup wizard will guide you through:
|
|
226
236
|
|
|
227
237
|
- Choosing AI provider (local Ollama or cloud API)
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.testConfiguration = testConfiguration;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const config_1 = require("./config");
|
|
9
|
+
const provider_1 = require("../ai/provider");
|
|
10
|
+
async function testConfiguration() {
|
|
11
|
+
console.log(chalk_1.default.cyan.bold('\n๐งช Testing API Configuration...\n'));
|
|
12
|
+
const config = config_1.configManager.getConfig();
|
|
13
|
+
try {
|
|
14
|
+
const provider = (0, provider_1.createProvider)(config);
|
|
15
|
+
console.log(chalk_1.default.gray('Provider:'), chalk_1.default.white.bold(config.ai.provider));
|
|
16
|
+
if (config.ai.provider === 'ollama') {
|
|
17
|
+
console.log(chalk_1.default.gray('Ollama URL:'), chalk_1.default.white(config.ai.ollama.baseUrl));
|
|
18
|
+
console.log(chalk_1.default.gray('Ollama Model:'), chalk_1.default.white(config.ai.ollama.model));
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
console.log(chalk_1.default.gray('API Provider:'), chalk_1.default.white.bold(config.ai.api.provider));
|
|
22
|
+
console.log(chalk_1.default.gray('API URL:'), chalk_1.default.white(config.ai.api.baseUrl));
|
|
23
|
+
console.log(chalk_1.default.gray('API Model:'), chalk_1.default.white(config.ai.api.model));
|
|
24
|
+
console.log(chalk_1.default.gray('API Key:'), chalk_1.default.white(config.ai.api.apiKey.substring(0, 8) + '...'));
|
|
25
|
+
}
|
|
26
|
+
console.log(chalk_1.default.gray('\n' + 'โ'.repeat(50) + '\n'));
|
|
27
|
+
console.log(chalk_1.default.cyan('๐ Testing connection...\n'));
|
|
28
|
+
const isAvailable = await provider.isAvailable();
|
|
29
|
+
if (isAvailable) {
|
|
30
|
+
console.log(chalk_1.default.green.bold('โ
API configuration is valid!\n'));
|
|
31
|
+
if (config.ai.provider === 'api') {
|
|
32
|
+
console.log(chalk_1.default.gray('Attempting a simple test request...\n'));
|
|
33
|
+
try {
|
|
34
|
+
const testText = 'Hello';
|
|
35
|
+
const optimized = await provider.optimize(testText, 'professional');
|
|
36
|
+
console.log(chalk_1.default.cyan('Test Input:'), chalk_1.default.white(testText));
|
|
37
|
+
console.log(chalk_1.default.cyan('Test Output:'), chalk_1.default.white(optimized));
|
|
38
|
+
console.log('\n' + chalk_1.default.green.bold('โ
Full test passed! Your API is working correctly.\n'));
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
console.log(chalk_1.default.yellow('\nโ ๏ธ Connection successful but request failed:'));
|
|
42
|
+
console.log(chalk_1.default.gray(error.message));
|
|
43
|
+
console.log('\n' + chalk_1.default.cyan('Possible issues:'));
|
|
44
|
+
console.log(chalk_1.default.gray(' - API key may be invalid or expired'));
|
|
45
|
+
console.log(chalk_1.default.gray(' - Model may not be available'));
|
|
46
|
+
console.log(chalk_1.default.gray(' - API endpoint may have changed'));
|
|
47
|
+
console.log('\n' + chalk_1.default.cyan('Please check your API configuration:'));
|
|
48
|
+
console.log(chalk_1.default.white(' fuck-abc config --setup\n'));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
console.log(chalk_1.default.green.bold('๐ Your local Ollama is ready!\n'));
|
|
53
|
+
console.log(chalk_1.default.gray('You can start using:'));
|
|
54
|
+
console.log(chalk_1.default.white.bold(' fuck-abc\n'));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
console.log(chalk_1.default.red.bold('โ API configuration is invalid!\n'));
|
|
59
|
+
if (config.ai.provider === 'ollama') {
|
|
60
|
+
console.log(chalk_1.default.red('Issues:'));
|
|
61
|
+
console.log(chalk_1.default.gray(' - Ollama is not running'));
|
|
62
|
+
console.log(chalk_1.default.gray(' - Ollama URL is incorrect'));
|
|
63
|
+
console.log('\n' + chalk_1.default.cyan('To start Ollama:'));
|
|
64
|
+
console.log(chalk_1.default.gray(' docker-compose up -d'));
|
|
65
|
+
console.log(chalk_1.default.gray('\nOr install Ollama locally:'));
|
|
66
|
+
console.log(chalk_1.default.gray(' https://ollama.com/download'));
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
console.log(chalk_1.default.red('Issues:'));
|
|
70
|
+
console.log(chalk_1.default.gray(' - API key is invalid or missing'));
|
|
71
|
+
console.log(chalk_1.default.gray(' - API URL is incorrect'));
|
|
72
|
+
console.log(chalk_1.default.gray(' - Network connection failed'));
|
|
73
|
+
console.log('\n' + chalk_1.default.cyan('Please check your configuration:'));
|
|
74
|
+
console.log(chalk_1.default.white(' fuck-abc config --setup'));
|
|
75
|
+
console.log(chalk_1.default.gray('\nOr view current config:'));
|
|
76
|
+
console.log(chalk_1.default.white(' fuck-abc config\n'));
|
|
77
|
+
}
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
console.log(chalk_1.default.red.bold('\nโ Configuration error!\n'));
|
|
83
|
+
console.log(chalk_1.default.gray(error.message));
|
|
84
|
+
if (error.message.includes('API key')) {
|
|
85
|
+
console.log('\n' + chalk_1.default.cyan('๐ก Tip: Make sure your API key is correct and active.'));
|
|
86
|
+
console.log(chalk_1.default.gray(' For OpenAI: https://platform.openai.com/api-keys'));
|
|
87
|
+
console.log(chalk_1.default.gray(' For GLM: https://open.bigmodel.cn/usercenter/apikeys'));
|
|
88
|
+
console.log(chalk_1.default.gray(' For DeepSeek: https://platform.deepseek.com/\n'));
|
|
89
|
+
}
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=test.js.map
|
package/dist/index.js
CHANGED
|
@@ -321,5 +321,18 @@ program
|
|
|
321
321
|
process.exit(1);
|
|
322
322
|
}
|
|
323
323
|
});
|
|
324
|
+
program
|
|
325
|
+
.command('test')
|
|
326
|
+
.description('Test API configuration and connection')
|
|
327
|
+
.action(async () => {
|
|
328
|
+
try {
|
|
329
|
+
const { testConfiguration } = await Promise.resolve().then(() => __importStar(require('./config/test')));
|
|
330
|
+
await testConfiguration();
|
|
331
|
+
}
|
|
332
|
+
catch (error) {
|
|
333
|
+
(0, display_1.displayError)(error);
|
|
334
|
+
process.exit(1);
|
|
335
|
+
}
|
|
336
|
+
});
|
|
324
337
|
program.parse();
|
|
325
338
|
//# sourceMappingURL=index.js.map
|