Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ export default async (word, options) => {
spinner.stop();
printIciba(result.dict, options);
} catch (error) {
spinner.fail('访问 iciba 失败,请检查网络');
spinner.fail('访问 deepseek 失败,请检查网络');
}
Comment on lines 41 to 43
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Consider adding error logging for the catch block to capture more details about the failure when accessing Deepseek, which can help in diagnosing issues. [enhancement]

Suggested change
} catch (error) {
spinner.fail('访问 iciba 失败,请检查网络');
spinner.fail('访问 deepseek 失败,请检查网络');
}
} catch (error) {
console.error('Deepseek access error:', error);
spinner.fail('访问 deepseek 失败,请检查网络');
}

}

// deepseek
if (isTrueOrUndefined(deepseek)) {
const openai = new OpenAI({
baseURL: 'https://api.deepseek.com',
baseURL: 'https://v10.deepseek.cn/api',
apiKey: LLM_API_KEY || 'sk-a6325c2f3d2044968e6a83f249cc1541',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API key 'sk-a6325c2f3d2044968e6a83f249cc1541' is hardcoded. Consider using environment variables or a secure vault to manage sensitive information.

});
Comment on lines 48 to 51
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Ensure that the baseURL for the OpenAI instance is configurable through environment variables or configuration files to allow flexibility in different environments. [best practice]

Suggested change
const openai = new OpenAI({
baseURL: 'https://api.deepseek.com',
baseURL: 'https://v10.deepseek.cn/api',
apiKey: LLM_API_KEY || 'sk-a6325c2f3d2044968e6a83f249cc1541',
});
const openai = new OpenAI({
baseURL: process.env.DEEPSEEK_API_URL || 'https://v10.deepseek.cn/api',
apiKey: LLM_API_KEY || 'sk-a6325c2f3d2044968e6a83f249cc1541',
});


Expand Down
4 changes: 4 additions & 0 deletions lib/config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
// Added deepseek API configuration for version 10.0
export const deepseekAPI = {
endpoint: 'https://v10.deepseek.cn/api',
timeout: 5000
Comment on lines +3 to +5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Validate the timeout value in the deepseekAPI configuration to ensure it is a positive integer, preventing potential misconfigurations. [possible issue]

Suggested change
export const deepseekAPI = {
endpoint: 'https://v10.deepseek.cn/api',
timeout: 5000
export const deepseekAPI = {
endpoint: 'https://v10.deepseek.cn/api',
timeout: Math.max(0, parseInt(process.env.DEEPSEEK_API_TIMEOUT, 10) || 5000)
};

import { homedir } from 'node:os';
import path from 'node:path';
import { Chalk } from 'chalk';
Expand Down
Loading