新功能: - 创建AI聊天助手组件(AIChatWidget) - 支持文字+图片多模态对话 - 集成Gemini AI API - 支持图片编辑和内容生成 - 实时对话历史管理 - 优雅的UI设计,支持黑夜模式 技术实现: - 后端API代理Gemini API(/api/ai-chat) - 支持最多5张图片上传 - 流式响应处理 - 对话历史管理 - Base64图片处理 配置: - 在.env中添加Gemini API配置 - GEMINI_API_KEY - GEMINI_API_BASE_URL - GEMINI_MODEL 替换原弹幕功能,提供更强大的AI助手体验!
103 lines
2.2 KiB
JavaScript
Executable File
103 lines
2.2 KiB
JavaScript
Executable File
import Ajv from "ajv";
|
|
import { createResponseSchema } from "./response";
|
|
const ajv = new Ajv();
|
|
|
|
export const previewImageUploadFileReponseSchemaValidate = ajv.compile(
|
|
createResponseSchema({
|
|
type: "object",
|
|
properties: {
|
|
ServiceId: {
|
|
type: "string",
|
|
},
|
|
FileName: {
|
|
type: "string",
|
|
},
|
|
StoreUri: {
|
|
type: "string",
|
|
},
|
|
ImageURL: {
|
|
type: "string",
|
|
},
|
|
ImageFormat: {
|
|
type: "string",
|
|
},
|
|
ImageSize: {
|
|
type: "number",
|
|
},
|
|
ImageWidth: {
|
|
type: "number",
|
|
},
|
|
ImageHeight: {
|
|
type: "number",
|
|
},
|
|
ImageFrames: {
|
|
type: "number",
|
|
},
|
|
ImageDuration: {
|
|
type: "number",
|
|
},
|
|
},
|
|
required: ["ServiceId", "FileName", "StoreUri", "ImageURL", "ImageFormat", "ImageSize", "ImageWidth", "ImageHeight"],
|
|
})
|
|
);
|
|
|
|
export const uploadImagesReponseSchemaValidate = ajv.compile(
|
|
createResponseSchema({
|
|
type: 'object',
|
|
properties: {
|
|
Results: {
|
|
type: 'array',
|
|
items: {
|
|
type: 'object',
|
|
properties: {
|
|
Uri: {
|
|
type: 'string',
|
|
}
|
|
},
|
|
required: ['Uri'],
|
|
}
|
|
},
|
|
RequestId: {
|
|
type: 'string',
|
|
},
|
|
PluginResult: {
|
|
type: 'array',
|
|
items: {
|
|
type: 'object',
|
|
properties: {
|
|
FileName: {
|
|
type: 'string',
|
|
},
|
|
ImageUri: {
|
|
type: "string",
|
|
},
|
|
ImageFormat: {
|
|
type: "string",
|
|
},
|
|
ImageSize: {
|
|
type: "number",
|
|
},
|
|
ImageWidth: {
|
|
type: "number",
|
|
},
|
|
ImageHeight: {
|
|
type: "number",
|
|
},
|
|
ImageMd5: {
|
|
type: "string",
|
|
},
|
|
FrameCnt: {
|
|
type: "number",
|
|
},
|
|
Duration: {
|
|
type: "number",
|
|
},
|
|
},
|
|
required: ['FileName', 'ImageUri', 'ImageFormat', 'ImageSize', 'ImageWidth', 'ImageHeight', 'ImageMd5'],
|
|
}
|
|
}
|
|
},
|
|
required: ['Results', 'RequestId', 'PluginResult'],
|
|
})
|
|
);
|