UNPKG

ernie-ai-provider

Version:

Community-built ERNIE AI Provider for Vercel AI SDK - Integrate Baidu's ERNIE models with Vercel's AI application framework

63 lines 1.76 kB
import { ErnieChatLanguageModel } from './ernie-chat-language-model'; import { ErnieChatModelId, ErnieChatSettings } from './ernie-chat-settings'; /** * ERNIE 提供商接口 * 支持通过工厂函数创建模型实例 */ export interface ErnieProvider { (modelId: ErnieChatModelId, settings?: ErnieChatSettings): ErnieChatLanguageModel; /** * 显式的聊天模型创建方法 */ chat(modelId: ErnieChatModelId, settings?: ErnieChatSettings): ErnieChatLanguageModel; } /** * ERNIE 提供商设置 */ export interface ErnieProviderSettings { /** * API 密钥 * 默认从 QIANFAN_API_KEY 环境变量读取 */ apiKey?: string; /** * API 基础 URL * 默认: https://qianfan.baidubce.com/v2 */ baseURL?: string; /** * 自定义请求头 */ headers?: Record<string, string>; /** * 自定义 fetch 实现 * 可用于代理、测试或中间件 */ fetch?: (input: string | URL | Request, init?: RequestInit) => Promise<Response>; /** * 自定义 ID 生成器 */ generateId?: () => string; } /** * 创建 ERNIE 提供商实例 * * @param options 提供商配置选项 * @returns ERNIE 提供商实例 * * @example * ```typescript * import { createErnie } from 'ernie-ai-provider'; * * const ernie = createErnie({ * apiKey: 'your-api-key', * }); * * const model = ernie('ernie-4.0-8k'); * ``` */ export declare function createErnie(options?: ErnieProviderSettings): ErnieProvider; export declare const ernie: ErnieProvider; export type { ErnieChatModelId, ErnieChatSettings, } from './ernie-chat-settings'; export { ErnieChatLanguageModel } from './ernie-chat-language-model'; //# sourceMappingURL=index.d.ts.map