chore: update dependencies in package.json and pnpm-lock.yaml; add cnb.ts for custom-cnb provider testing
This commit is contained in:
27
test/cnb.ts
Normal file
27
test/cnb.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
|
||||
import { generateText } from 'ai';
|
||||
import 'dotenv/config';
|
||||
|
||||
// 使用 custom-cnb provider (聚合了多个模型)
|
||||
const cnb = createOpenAICompatible({
|
||||
baseURL: 'https://api.cnb.cool/kevisual/kevisual/-/ai',
|
||||
name: 'custom-cnb',
|
||||
apiKey: process.env.CNB_API_KEY!,
|
||||
});
|
||||
|
||||
// 测试所有可用模型
|
||||
// const models = ['qwen3-coder-plus', 'ark-code-latest', 'GLM-4.7', 'MiniMax-M2.1'];
|
||||
const models = ['CNB_Models'];
|
||||
|
||||
for (const model of models) {
|
||||
console.log(`\n=== Testing model: ${model} ===`);
|
||||
try {
|
||||
const { text } = await generateText({
|
||||
model: cnb(model),
|
||||
prompt: 'Say hello in one sentence.',
|
||||
});
|
||||
console.log(`Response: ${text}`);
|
||||
} catch (error) {
|
||||
console.error(`Error: ${error}`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user