mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-06 05:09:09 +08:00
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:
parent
69e87ce21a
commit
ef6be4a6f9
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@cherrystudio/ai-core",
|
"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",
|
"description": "Cherry Studio AI Core - Unified AI Provider Interface Based on Vercel AI SDK",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"module": "dist/index.mjs",
|
"module": "dist/index.mjs",
|
||||||
|
|||||||
@ -24,13 +24,15 @@ export class ProviderCreationError extends Error {
|
|||||||
export async function createProvider(config: ProviderConfig, options: any): Promise<any> {
|
export async function createProvider(config: ProviderConfig, options: any): Promise<any> {
|
||||||
try {
|
try {
|
||||||
// 验证配置
|
// 验证配置
|
||||||
if (!config.creator && !(config.import && config.creatorFunctionName)) {
|
if (!validateProviderConfig(config)) {
|
||||||
throw new ProviderCreationError(
|
throw new ProviderCreationError(
|
||||||
'Invalid provider configuration: must provide either creator function or import configuration',
|
'Invalid provider configuration: must provide either creator function or import configuration',
|
||||||
config.id
|
config.id
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config.validateOptions?.(options)
|
||||||
|
|
||||||
// 方式一:直接使用 creator 函数
|
// 方式一:直接使用 creator 函数
|
||||||
if (config.creator) {
|
if (config.creator) {
|
||||||
return config.creator(options)
|
return config.creator(options)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user