55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
import { createOpenAI } from "@ai-sdk/openai";
|
|
import {
|
|
customProvider,
|
|
extractReasoningMiddleware,
|
|
wrapLanguageModel,
|
|
} from "ai";
|
|
import { isTestEnvironment } from "../constants";
|
|
|
|
const aliQwen = createOpenAI({
|
|
apiKey: process.env.DASHSCOPE_API_KEY,
|
|
baseURL: process.env.DASHSCOPE_BASE_URL,
|
|
});
|
|
|
|
const gtp5 = createOpenAI({
|
|
apiKey: process.env.GTP5_API_KEY,
|
|
baseURL: process.env.GTP5_API_URL,
|
|
});
|
|
|
|
export const myProvider = isTestEnvironment
|
|
? (() => {
|
|
const {
|
|
artifactModel,
|
|
chatModel,
|
|
reasoningModel,
|
|
titleModel,
|
|
} = require("./models.mock");
|
|
return customProvider({
|
|
languageModels: {
|
|
"chat-model": chatModel,
|
|
"chat-model-reasoning": reasoningModel,
|
|
"title-model": titleModel,
|
|
"artifact-model": artifactModel,
|
|
},
|
|
});
|
|
})()
|
|
: customProvider({
|
|
languageModels: {
|
|
// 基础对话模型 - 使用千问
|
|
"chat-model": aliQwen.chat("qwen-turbo"),
|
|
// 推理模型 - 使用千问 plus
|
|
"chat-model-reasoning": wrapLanguageModel({
|
|
model: aliQwen.chat("qwen-plus"),
|
|
middleware: extractReasoningMiddleware({ tagName: "think" }),
|
|
}),
|
|
// 千问多模态模型
|
|
"qwen3-vl-plus": aliQwen.chat("qwen-vl-plus"),
|
|
// GPT-5 Nano (第三方接口)
|
|
"gpt-5-nano": gtp5.chat(process.env.GTP5_MODEL ?? "gpt-5-nano"),
|
|
// 标题生成模型
|
|
"title-model": aliQwen.chat("qwen-turbo"),
|
|
// 文档生成模型
|
|
"artifact-model": aliQwen.chat("qwen-turbo"),
|
|
},
|
|
});
|