From 7129f9a877a1e38737f7d203fa2555c18539cc45 Mon Sep 17 00:00:00 2001 From: abearxiong Date: Wed, 4 Mar 2026 15:48:11 +0800 Subject: [PATCH] chore: update dependencies in package.json and pnpm-lock.yaml; add cnb.ts for custom-cnb provider testing --- package.json | 10 +++--- pnpm-lock.yaml | 82 +++++++++++++++++++++++++------------------------- test/cnb.ts | 27 +++++++++++++++++ 3 files changed, 73 insertions(+), 46 deletions(-) create mode 100644 test/cnb.ts diff --git a/package.json b/package.json index 668a5b7..4b5a1c8 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@kevisual/router": "0.0.84", "@kevisual/types": "^0.0.12", "@kevisual/use-config": "^1.0.30", - "@types/bun": "^1.3.9", + "@types/bun": "^1.3.10", "@types/crypto-js": "^4.2.2", "@types/formidable": "^3.4.7", "@types/node": "^25.3.3", @@ -59,10 +59,10 @@ }, "dependencies": { "@kevisual/logger": "^0.0.4", - "@ai-sdk/anthropic": "^3.0.51", - "@ai-sdk/openai": "^3.0.38", - "@ai-sdk/openai-compatible": "^2.0.31", - "ai": "^6.0.106", + "@ai-sdk/anthropic": "^3.0.53", + "@ai-sdk/openai": "^3.0.39", + "@ai-sdk/openai-compatible": "^2.0.33", + "ai": "^6.0.108", "@kevisual/permission": "^0.0.4", "@kevisual/query": "^0.0.52" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6fb18ce..a34c34f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,14 +9,14 @@ importers: .: dependencies: '@ai-sdk/anthropic': - specifier: ^3.0.51 - version: 3.0.51(zod@3.25.76) + specifier: ^3.0.53 + version: 3.0.53(zod@3.25.76) '@ai-sdk/openai': - specifier: ^3.0.38 - version: 3.0.38(zod@3.25.76) + specifier: ^3.0.39 + version: 3.0.39(zod@3.25.76) '@ai-sdk/openai-compatible': - specifier: ^2.0.31 - version: 2.0.31(zod@3.25.76) + specifier: ^2.0.33 + version: 2.0.33(zod@3.25.76) '@kevisual/logger': specifier: ^0.0.4 version: 0.0.4 @@ -27,8 +27,8 @@ importers: specifier: ^0.0.52 version: 0.0.52 ai: - specifier: ^6.0.106 - version: 6.0.106(zod@3.25.76) + specifier: ^6.0.108 + version: 6.0.108(zod@3.25.76) devDependencies: '@kevisual/router': specifier: 0.0.84 @@ -40,8 +40,8 @@ importers: specifier: ^1.0.30 version: 1.0.30(dotenv@17.3.1) '@types/bun': - specifier: ^1.3.9 - version: 1.3.9 + specifier: ^1.3.10 + version: 1.3.10 '@types/crypto-js': specifier: ^4.2.2 version: 4.2.2 @@ -84,32 +84,32 @@ importers: packages: - '@ai-sdk/anthropic@3.0.51': - resolution: {integrity: sha512-ZQ3UE4KpKFBe6Vr1mJu6QwUxlnwwJNGrnxGpW1eFj9CA3hmDVT3XVeevCWps4R+c1YT4GZig6IjJgFmwLeWlFQ==} + '@ai-sdk/anthropic@3.0.53': + resolution: {integrity: sha512-HVuVLUt4VtioGKV5gxRg7Wu2g0BvX3zzrAa51OHPG9sJlP+caPyZu3n4j4FHjZmg++8A9JHDCMWBQfHra3gtWg==} engines: {node: '>=18'} peerDependencies: zod: ^3.25.76 || ^4.1.8 - '@ai-sdk/gateway@3.0.60': - resolution: {integrity: sha512-CUwcZRzJEGVhz68Ve7WY0YYbnNOnB6MkL8GcmgjU5hAZbUPaBWUmHOp3N6BRgNzAnwh1mtOLSC3e3+F5Dx+PKg==} + '@ai-sdk/gateway@3.0.61': + resolution: {integrity: sha512-OT6SeORuOoqfABhntMJHmInblxE2DbBYvRTynVOGl6dCDDh0cNU1lJgknyDV698eQmfb6Um/94/rImgt0ZPjDA==} engines: {node: '>=18'} peerDependencies: zod: ^3.25.76 || ^4.1.8 - '@ai-sdk/openai-compatible@2.0.31': - resolution: {integrity: sha512-e78xiImcTe2aCMQoFbVJluQmUV4XgahOmmehAuRPlcwzRv2KtkvuLCXPC9Xcy2u83e8SimVva9k9G8SvZcnaBA==} + '@ai-sdk/openai-compatible@2.0.33': + resolution: {integrity: sha512-HwptqeUS4vtDyjSSjmKCQExjoQMwPVq0C4pHH18i7c+3CQ0QN81HLvz3BdpULo0n/UtdQwTNISRqx3G5miPZhw==} engines: {node: '>=18'} peerDependencies: zod: ^3.25.76 || ^4.1.8 - '@ai-sdk/openai@3.0.38': - resolution: {integrity: sha512-TtHxdEOUpRTEGgYOUHzgrrFYBiI3BBz8zbQokWNtQtR6CWSP/7JjmsGamU31CEhH2LD98vxc4V30/kjTNgGGUQ==} + '@ai-sdk/openai@3.0.39': + resolution: {integrity: sha512-EZrs4L6kMkPQhpodagpEvqLSryOIK99WgblN0IsVHr1xhajWizQOZ0XMa7c5JpSYgIjV6u8GCpGV6hS3Mk2Bug==} engines: {node: '>=18'} peerDependencies: zod: ^3.25.76 || ^4.1.8 - '@ai-sdk/provider-utils@4.0.16': - resolution: {integrity: sha512-kBvDqNkt5EwlzF9FujmNhhtl8FYg3e8FO8P5uneKliqfRThWemzBj+wfYr7ZCymAQhTRnwSSz1/SOqhOAwmx9g==} + '@ai-sdk/provider-utils@4.0.17': + resolution: {integrity: sha512-oyCeFINTYK0B8ZGUBiQc05G5vytPlKSmTTtm19xfJuUgoi8zkvvRcoPQci4mSnyfpPn2XSFFDfsALG8uGcapfg==} engines: {node: '>=18'} peerDependencies: zod: ^3.25.76 || ^4.1.8 @@ -457,8 +457,8 @@ packages: '@tootallnate/quickjs-emscripten@0.23.0': resolution: {integrity: sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==} - '@types/bun@1.3.9': - resolution: {integrity: sha512-KQ571yULOdWJiMH+RIWIOZ7B2RXQGpL1YQrBtLIV3FqDcCu6FsbFUBwhdKUlCKUpS3PJDsHlJ1QKlpxoVR+xtw==} + '@types/bun@1.3.10': + resolution: {integrity: sha512-0+rlrUrOrTSskibryHbvQkDOWRJwJZqZlxrUs1u4oOoTln8+WIXBPmAuCF35SWB2z4Zl3E84Nl/D0P7803nigQ==} '@types/crypto-js@4.2.2': resolution: {integrity: sha512-sDOLlVbHhXpAUAL0YHDUUwDZf3iN4Bwi4W6a0W0b+QcAezUbRtH4FVb+9J4h+XFPW7l/gQ9F8qC7P+Ec4k8QVQ==} @@ -480,8 +480,8 @@ packages: resolution: {integrity: sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==} engines: {node: '>= 14'} - ai@6.0.106: - resolution: {integrity: sha512-wAOLMLoVfTEN99FMwdqREi8tWeQCcns6DxkQg8kkzcTxc/ZTQaF7CRqgjI2OSQt2RlzKXPLcJBpZr7axc8cCgQ==} + ai@6.0.108: + resolution: {integrity: sha512-h2xwwU9lE+tdLyII/uFcjcrw+7ciWj2S68GrwQsebjHPSfnvxwrn+sjIl+tBt419yA9rYznWXtQvHJxM1wEAAQ==} engines: {node: '>=18'} peerDependencies: zod: ^3.25.76 || ^4.1.8 @@ -550,8 +550,8 @@ packages: buffer-from@1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} - bun-types@1.3.9: - resolution: {integrity: sha512-+UBWWOakIP4Tswh0Bt0QD0alpTY8cb5hvgiYeWCMet9YukHbzuruIEeXC2D7nMJPB12kbh8C7XJykSexEqGKJg==} + bun-types@1.3.10: + resolution: {integrity: sha512-tcpfCCl6XWo6nCVnpcVrxQ+9AYN1iqMIzgrSKYMB/fjLtV2eyAVEg7AxQJuCq/26R6HpKWykQXuSOq/21RYcbg==} chalk@3.0.0: resolution: {integrity: sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==} @@ -1195,32 +1195,32 @@ packages: snapshots: - '@ai-sdk/anthropic@3.0.51(zod@3.25.76)': + '@ai-sdk/anthropic@3.0.53(zod@3.25.76)': dependencies: '@ai-sdk/provider': 3.0.8 - '@ai-sdk/provider-utils': 4.0.16(zod@3.25.76) + '@ai-sdk/provider-utils': 4.0.17(zod@3.25.76) zod: 3.25.76 - '@ai-sdk/gateway@3.0.60(zod@3.25.76)': + '@ai-sdk/gateway@3.0.61(zod@3.25.76)': dependencies: '@ai-sdk/provider': 3.0.8 - '@ai-sdk/provider-utils': 4.0.16(zod@3.25.76) + '@ai-sdk/provider-utils': 4.0.17(zod@3.25.76) '@vercel/oidc': 3.1.0 zod: 3.25.76 - '@ai-sdk/openai-compatible@2.0.31(zod@3.25.76)': + '@ai-sdk/openai-compatible@2.0.33(zod@3.25.76)': dependencies: '@ai-sdk/provider': 3.0.8 - '@ai-sdk/provider-utils': 4.0.16(zod@3.25.76) + '@ai-sdk/provider-utils': 4.0.17(zod@3.25.76) zod: 3.25.76 - '@ai-sdk/openai@3.0.38(zod@3.25.76)': + '@ai-sdk/openai@3.0.39(zod@3.25.76)': dependencies: '@ai-sdk/provider': 3.0.8 - '@ai-sdk/provider-utils': 4.0.16(zod@3.25.76) + '@ai-sdk/provider-utils': 4.0.17(zod@3.25.76) zod: 3.25.76 - '@ai-sdk/provider-utils@4.0.16(zod@3.25.76)': + '@ai-sdk/provider-utils@4.0.17(zod@3.25.76)': dependencies: '@ai-sdk/provider': 3.0.8 '@standard-schema/spec': 1.1.0 @@ -1462,9 +1462,9 @@ snapshots: '@tootallnate/quickjs-emscripten@0.23.0': {} - '@types/bun@1.3.9': + '@types/bun@1.3.10': dependencies: - bun-types: 1.3.9 + bun-types: 1.3.10 '@types/crypto-js@4.2.2': {} @@ -1482,11 +1482,11 @@ snapshots: agent-base@7.1.4: {} - ai@6.0.106(zod@3.25.76): + ai@6.0.108(zod@3.25.76): dependencies: - '@ai-sdk/gateway': 3.0.60(zod@3.25.76) + '@ai-sdk/gateway': 3.0.61(zod@3.25.76) '@ai-sdk/provider': 3.0.8 - '@ai-sdk/provider-utils': 4.0.16(zod@3.25.76) + '@ai-sdk/provider-utils': 4.0.17(zod@3.25.76) '@opentelemetry/api': 1.9.0 zod: 3.25.76 @@ -1541,7 +1541,7 @@ snapshots: buffer-from@1.1.2: {} - bun-types@1.3.9: + bun-types@1.3.10: dependencies: '@types/node': 25.3.3 diff --git a/test/cnb.ts b/test/cnb.ts new file mode 100644 index 0000000..90e5343 --- /dev/null +++ b/test/cnb.ts @@ -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}`); + } +}