chore: add diagnostic and seeding scripts
- Add script to generate bcrypt admin password hash. - Add script to seed sample articles for local development. - Add Kimi/Moonshot API diagnostic scripts (SDK and direct curl).
This commit is contained in:
27
scripts/test-kimi.ts
Normal file
27
scripts/test-kimi.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { getActiveKey } from '../src/lib/api-keys';
|
||||
import { getAiClient, getAiModel } from '../src/lib/ai/client';
|
||||
|
||||
async function main() {
|
||||
const key = await getActiveKey('KIMI');
|
||||
if (!key) {
|
||||
console.log('No active KIMI key found');
|
||||
return;
|
||||
}
|
||||
console.log('Found active KIMI key. Length:', key.length);
|
||||
console.log('API URL:', process.env.KIMI_API_URL || 'https://api.moonshot.cn/v1');
|
||||
console.log('Model:', process.env.KIMI_MODEL || 'moonshot-v1-8k');
|
||||
|
||||
try {
|
||||
const client = await getAiClient();
|
||||
const res = await client.chat.completions.create({
|
||||
model: getAiModel(),
|
||||
messages: [{ role: 'user', content: 'Say hello' }],
|
||||
});
|
||||
console.log('SUCCESS:', res.choices[0]?.message?.content);
|
||||
} catch (err: any) {
|
||||
console.error('FAILED:', err.status, err.message);
|
||||
if (err.error) console.error('API error:', err.error);
|
||||
}
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
Reference in New Issue
Block a user