chore: bump @cherrystudio/ai-core version to 1.0.0-alpha.5

- Updated version in package.json to 1.0.0-alpha.5.
- Enhanced provider configuration validation in createProvider function for improved error handling.
This commit is contained in:
MyPrototypeWhat 2025-07-18 16:30:49 +08:00
parent 69e87ce21a
commit ef6be4a6f9
2 changed files with 4 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@cherrystudio/ai-core",
"version": "1.0.0-alpha.4",
"version": "1.0.0-alpha.5",
"description": "Cherry Studio AI Core - Unified AI Provider Interface Based on Vercel AI SDK",
"main": "dist/index.js",
"module": "dist/index.mjs",

View File

@ -24,13 +24,15 @@ export class ProviderCreationError extends Error {
export async function createProvider(config: ProviderConfig, options: any): Promise<any> {
try {
// 验证配置
if (!config.creator && !(config.import && config.creatorFunctionName)) {
if (!validateProviderConfig(config)) {
throw new ProviderCreationError(
'Invalid provider configuration: must provide either creator function or import configuration',
config.id
)
}
config.validateOptions?.(options)
// 方式一:直接使用 creator 函数
if (config.creator) {
return config.creator(options)