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:
37
scripts/test-kimi-curl.ts
Normal file
37
scripts/test-kimi-curl.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { getActiveKey } from '../src/lib/api-keys';
|
||||
|
||||
async function main() {
|
||||
const key = await getActiveKey('KIMI');
|
||||
if (!key) {
|
||||
console.log('No active KIMI key found');
|
||||
return;
|
||||
}
|
||||
|
||||
const model = process.env.KIMI_MODEL || 'moonshot-v1-8k';
|
||||
const url = process.env.KIMI_API_URL || 'https://api.moonshot.cn/v1';
|
||||
|
||||
console.log('Key length:', key.length);
|
||||
console.log('Key starts with:', key.slice(0, 6));
|
||||
console.log('API URL:', url);
|
||||
console.log('Model:', model);
|
||||
console.log('');
|
||||
|
||||
const res = await fetch(`${url}/chat/completions`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${key}`,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
model,
|
||||
messages: [{ role: 'user', content: 'Say hello' }],
|
||||
temperature: 0.2,
|
||||
}),
|
||||
});
|
||||
|
||||
const body = await res.text();
|
||||
console.log('Status:', res.status);
|
||||
console.log('Body:', body);
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
Reference in New Issue
Block a user