feat: 使用免费的deepseek
This commit is contained in:
parent
8dcb54a49b
commit
10e7ef05c9
|
@ -1,7 +1,7 @@
|
|||
NEXT_PUBLIC_SUPABASE_URL=https://yidfukfbrluizjvfrrsj.supabase.co
|
||||
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InlpZGZ1a2Zicmx1aXpqdmZycnNqIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDQ4NjMyNjEsImV4cCI6MjAyMDQzOTI2MX0.EXIXAdNIGLFo5wHmwmY2-9bqLO9vyFYDvMMtCtkxgig
|
||||
NEXT_PUBLIC_AI_URL=https://one.caifree.com
|
||||
NEXT_PUBLIC_OPENAI_API_KEY=sk-aiHrrRLYUUelHstX69E9484509254dBf92061d6744FfFaD1
|
||||
NEXT_PUBLIC_AI_URL=https://api.deepseek.com
|
||||
NEXT_PUBLIC_OPENAI_API_KEY=sk-ffe19ebe9fa44d00884330ff1c18cf82
|
||||
NEXT_PUBLIC_PAPER_URL=/api/paper
|
||||
NEXT_PUBLIC_SEMANTIC_API_KEY=hEQvK6ARe84dzDPcMnpzX4n9jfoqztkMfaftPWnb
|
||||
NEXT_PUBLIC_PUBMED_API_KEY=057616e7ce6c722f2ae8679e38a8be9b1a09
|
||||
|
|
|
@ -58,7 +58,21 @@
|
|||
@apply fixed top-1/4 right-0;
|
||||
transform: translateX(100%); /* 动画开始前,确保组件位于视图右侧之外 */
|
||||
}
|
||||
|
||||
/* 想给上标添加一个鼠标放上去变手型的效果 */
|
||||
.ql-editor .ql-super {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
@keyframes flash {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
.vip-icon {
|
||||
animation: flash 1s linear infinite;
|
||||
}
|
||||
|
|
|
@ -1,28 +1,31 @@
|
|||
import { createClient } from '@/utils/supabase/server'
|
||||
import Link from 'next/link'
|
||||
import { cookies } from 'next/headers'
|
||||
import { redirect } from 'next/navigation'
|
||||
import { createClient } from "@/utils/supabase/server";
|
||||
import Link from "next/link";
|
||||
import { cookies } from "next/headers";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export default async function AuthButton() {
|
||||
const cookieStore = cookies()
|
||||
const supabase = createClient(cookieStore)
|
||||
const cookieStore = cookies();
|
||||
const supabase = createClient(cookieStore);
|
||||
|
||||
const {
|
||||
data: { user },
|
||||
} = await supabase.auth.getUser()
|
||||
} = await supabase.auth.getUser();
|
||||
|
||||
const signOut = async () => {
|
||||
'use server'
|
||||
"use server";
|
||||
|
||||
const cookieStore = cookies()
|
||||
const supabase = createClient(cookieStore)
|
||||
await supabase.auth.signOut()
|
||||
return redirect('/login')
|
||||
}
|
||||
const cookieStore = cookies();
|
||||
const supabase = createClient(cookieStore);
|
||||
await supabase.auth.signOut();
|
||||
return redirect("/login");
|
||||
};
|
||||
|
||||
return user ? (
|
||||
<div className="flex items-center gap-4">
|
||||
Hey, {user.email}!
|
||||
<div className="vip-icon bg-yellow-400 text-white p-2 rounded-full shadow-lg animate-pulse">
|
||||
VIP
|
||||
</div>
|
||||
<form action={signOut}>
|
||||
<button className="py-2 px-4 rounded-md no-underline bg-btn-background hover:bg-btn-background-hover">
|
||||
Logout
|
||||
|
@ -36,5 +39,5 @@ export default async function AuthButton() {
|
|||
>
|
||||
Login
|
||||
</Link>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -69,7 +69,10 @@ const QEditor = () => {
|
|||
"semanticScholar"
|
||||
); // 默认选项
|
||||
//选择语言模型
|
||||
const [selectedModel, setSelectedModel] = useLocalStorage("gpt3.5", "gpt3.5"); // 默认选项
|
||||
const [selectedModel, setSelectedModel] = useLocalStorage(
|
||||
"gpt3.5",
|
||||
"deepseek-chat"
|
||||
); // 默认选项
|
||||
//redux
|
||||
const dispatch = useAppDispatch();
|
||||
const references = useAppSelector((state) => state.auth.referencesRedux);
|
||||
|
@ -291,17 +294,6 @@ const QEditor = () => {
|
|||
}
|
||||
}
|
||||
|
||||
// 插入论文信息
|
||||
// const insertPapers = async (topic: string) => {
|
||||
// const rawData = await getArxivPapers(topic);
|
||||
// const dataString = rawData
|
||||
// .map((entry) => {
|
||||
// return `ID: ${entry.id}\nPublished: ${entry.published}\nTitle: ${entry.title}\nSummary: ${entry.summary}\n\n`;
|
||||
// })
|
||||
// .join("");
|
||||
// quill.insertText(quill.getLength(), dataString);
|
||||
// };
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div id="Qtoolbar" className="space-y-2 flex justify-between">
|
||||
|
@ -345,8 +337,9 @@ const QEditor = () => {
|
|||
onChange={(e) => setSelectedModel(e.target.value)}
|
||||
className=" border border-gray-300 bg-white py-2 px-3 rounded leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
|
||||
>
|
||||
<option value="gpt3.5">gpt3.5</option>
|
||||
<option value="gpt4">gpt4</option>
|
||||
<option value="gpt-3.5-turbo">gpt3.5</option>
|
||||
<option value="gpt-4">gpt4</option>
|
||||
<option value="deepseek-chat">deepseek-chat</option>
|
||||
{/* 其他来源网站 */}
|
||||
</select>
|
||||
{/* 用户输入自己的API key */}
|
||||
|
|
|
@ -27,7 +27,7 @@ const sendMessageToOpenAI = async (
|
|||
prompt?: string
|
||||
) => {
|
||||
//识别应该使用的模型
|
||||
let model = selectedModel === "gpt3.5" ? "gpt-3.5-turbo" : "gpt-4";
|
||||
let model = selectedModel;
|
||||
console.log("upstreamUrl", upsreamUrl);
|
||||
// 设置API请求参数
|
||||
const requestOptions = {
|
||||
|
@ -76,8 +76,8 @@ const sendMessageToOpenAI = async (
|
|||
(upsreamUrl || process.env.NEXT_PUBLIC_AI_URL) + "/v1/chat/completions",
|
||||
requestOptions
|
||||
);
|
||||
if (!response.ok) {
|
||||
throw new Error("Server responded with an error");
|
||||
if (!response.ok || !response.body) {
|
||||
throw new Error("Server responded with an error" + response);
|
||||
}
|
||||
const reader = response.body.getReader();
|
||||
const decoder = new TextDecoder();
|
||||
|
|
Loading…
Reference in New Issue
Block a user