diff --git a/app/api/chat/route.ts b/app/api/chat/route.ts index 6f1a1aa..0de7d7a 100644 --- a/app/api/chat/route.ts +++ b/app/api/chat/route.ts @@ -4,6 +4,21 @@ import { streamText, convertToModelMessages, type UIMessage } from "ai"; const doubao = createOpenAI({ baseURL: "https://ark.cn-beijing.volces.com/api/v3", apiKey: process.env.DOUBAO_API_KEY || "", + fetch: async (url, options) => { + // 拦截请求,将 developer 角色转换为 system 角色 + // 这个 sdk 会自动把 system 等角色转换成 developer... + if (options?.body) { + const body = JSON.parse(options.body as string); + if (body.messages) { + body.messages = body.messages.map((msg: any) => ({ + ...msg, + role: msg.role === "developer" ? "system" : msg.role, + })); + } + options.body = JSON.stringify(body); + } + return fetch(url, options); + }, }).chat; export async function POST(req: Request) { @@ -11,6 +26,7 @@ export async function POST(req: Request) { const result = streamText({ model: doubao("doubao-seed-1-6-flash-250828"), + system: "你是源语奇思(AtomInfinite)开发的人工智能助手 WisModel。", messages: convertToModelMessages(messages), }); diff --git a/app/assistant.tsx b/app/assistant.tsx index 4274894..c8e6b1c 100644 --- a/app/assistant.tsx +++ b/app/assistant.tsx @@ -59,6 +59,11 @@ export const Assistant = () => {
+
+ + 沪ICP备2025110110号-2 + +
diff --git a/components/assistant-ui/thread.tsx b/components/assistant-ui/thread.tsx index da17f61..b771c02 100644 --- a/components/assistant-ui/thread.tsx +++ b/components/assistant-ui/thread.tsx @@ -173,7 +173,7 @@ const ThreadSuggestions: FC = () => { const Composer: FC = () => { return ( -
+
diff --git a/components/assistant-ui/threadlist-sidebar.tsx b/components/assistant-ui/threadlist-sidebar.tsx index 911b320..669ce17 100644 --- a/components/assistant-ui/threadlist-sidebar.tsx +++ b/components/assistant-ui/threadlist-sidebar.tsx @@ -1,10 +1,9 @@ import * as React from "react"; -import { Github, MessagesSquare } from "lucide-react"; +import { MessagesSquare } from "lucide-react"; import Link from "next/link"; import { Sidebar, SidebarContent, - SidebarFooter, SidebarHeader, SidebarMenu, SidebarMenuButton,