feat: 添加 OpenAI 兼容 API 支持和独立 Vision 服务
- 添加 OpenAI AI SDK provider 支持 (@ai-sdk/openai) - 支持 OpenAI 兼容服务的 baseUrl 配置(如阿里云百炼) - 添加独立的 Vision 配置(visionProvider/visionApiKey/visionBaseUrl/visionModel) - 实现图片引用语法 @path/to/image.png,支持带空格的路径 - 当主模型不支持 vision 时,自动调用配置的 Vision 服务分析图片 - 添加图片处理工具函数和单元测试
This commit is contained in:
+34
-3
@@ -1,9 +1,38 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
// 消息类型
|
||||
// 内容块类型(支持多模态)
|
||||
export interface TextContentBlock {
|
||||
type: 'text';
|
||||
text: string;
|
||||
}
|
||||
|
||||
export interface ImageContentBlock {
|
||||
type: 'image';
|
||||
/** base64 编码的图片数据 */
|
||||
image: string;
|
||||
/** MIME 类型 */
|
||||
mimeType?: string;
|
||||
}
|
||||
|
||||
export type ContentBlock = TextContentBlock | ImageContentBlock;
|
||||
|
||||
// 消息类型(支持多模态)
|
||||
export interface Message {
|
||||
role: 'user' | 'assistant';
|
||||
content: string;
|
||||
/** 内容可以是纯文本或内容块数组 */
|
||||
content: string | ContentBlock[];
|
||||
}
|
||||
|
||||
// 用户输入(带图片)
|
||||
export interface UserInput {
|
||||
/** 文本内容 */
|
||||
text: string;
|
||||
/** 图片列表(base64 编码) */
|
||||
images?: Array<{
|
||||
data: string;
|
||||
mimeType: string;
|
||||
filename?: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
// 工具参数定义
|
||||
@@ -37,7 +66,7 @@ export interface ToolCall {
|
||||
}
|
||||
|
||||
// 支持的 Provider 类型
|
||||
export type ProviderType = 'anthropic' | 'deepseek';
|
||||
export type ProviderType = 'anthropic' | 'deepseek' | 'openai';
|
||||
|
||||
// Agent 配置
|
||||
export interface AgentConfig {
|
||||
@@ -46,6 +75,8 @@ export interface AgentConfig {
|
||||
model: string;
|
||||
maxTokens: number;
|
||||
systemPrompt: string;
|
||||
/** 自定义 API 基础 URL(用于兼容 OpenAI API 的第三方服务,如阿里云百炼) */
|
||||
baseUrl?: string;
|
||||
}
|
||||
|
||||
// 会话上下文
|
||||
|
||||
Reference in New Issue
Block a user