From 17da9f8a1585b2bdcef22167d3161203d77c8d09 Mon Sep 17 00:00:00 2001 From: Stan Ke <156306548@qq.com> Date: Mon, 26 Aug 2024 23:41:55 +0800 Subject: [PATCH] remove deprecated code --- app/api/chat/openai/route.ts | 5 +- app/chat/agent.tsx | 1 - app/chat/page.tsx | 6 - app/components/Carousel.tsx | 32 ++-- app/page.tsx | 11 +- lib/ModelSetting.ts | 5 +- lib/supabase.ts | 72 +++++++++ package.json | 2 +- public/styles.css | 281 ++++++++++++++++++++++++++++++++++- tsconfig.json | 5 +- 10 files changed, 376 insertions(+), 44 deletions(-) create mode 100644 lib/supabase.ts diff --git a/app/api/chat/openai/route.ts b/app/api/chat/openai/route.ts index 97758e0..33fb833 100644 --- a/app/api/chat/openai/route.ts +++ b/app/api/chat/openai/route.ts @@ -34,7 +34,7 @@ export async function POST(request: Request) { console.log(chunk.choices[0].delta); process.stdout.write(chunk.choices[0]?.delta?.content || ""); } - return response; + return ; } catch (error: any) { const errorMessage = error.error?.message || "An unexpected error occurred"; const errorCode = error.status || 500; @@ -42,9 +42,6 @@ export async function POST(request: Request) { return new Response(JSON.stringify({ message: errorMessage }), { status: errorCode, - headers: { - "Content-Type": "application/json", - }, }); } } diff --git a/app/chat/agent.tsx b/app/chat/agent.tsx index 1dcf919..a0f98ce 100644 --- a/app/chat/agent.tsx +++ b/app/chat/agent.tsx @@ -13,7 +13,6 @@ export function createAgent(): Agent { id, name: `Agent ${id}`, content: 'This is the default agent content.', - config: agentConfig, // 将agentConfig添加到新创建的Agent中 }; agents[id] = newAgent; return newAgent; diff --git a/app/chat/page.tsx b/app/chat/page.tsx index 42d85bb..ca09fda 100644 --- a/app/chat/page.tsx +++ b/app/chat/page.tsx @@ -57,11 +57,6 @@ const Chat = () => { setMessage(event.target.value); }; - const handleKeyPress = (event) => { - if (event.key === 'Enter') { - sendMessage(); - } - }; return (
@@ -127,7 +122,6 @@ const Chat = () => { type="text" value={message} onChange={handleMessageChange} - onKeyPress={handleKeyPress} className="flex-1 p-2 border-2 border-gray-200 rounded-md" placeholder="Type your message..." /> diff --git a/app/components/Carousel.tsx b/app/components/Carousel.tsx index ca8090e..481f022 100644 --- a/app/components/Carousel.tsx +++ b/app/components/Carousel.tsx @@ -1,6 +1,5 @@ "use client"; -import Image from "next/image"; import { useEffect, useState } from "react"; import { ChevronLeft, ChevronRight } from "react-feather"; @@ -10,6 +9,7 @@ const Carousel = ({ autoSlideInterval = 4000, }) => { const [currentSlide, setCurrentSlide] = useState(0); + const handleNextSlide = () => { let newSlide = currentSlide === slides.length - 1 ? 0 : currentSlide + 1; setCurrentSlide(newSlide); @@ -21,36 +21,37 @@ const Carousel = ({ }; useEffect(() => { - if (!autoPlay) return () => clearInterval(slideInterval); + if (!autoPlay) return; + const slideInterval = setInterval(handleNextSlide, autoSlideInterval); return () => clearInterval(slideInterval); - }, [currentSlide]); + }, [currentSlide, autoPlay, autoSlideInterval]); return ( -
+
{slides.map((slide, index) => ( - {`Slide + {`Slide ))}
- -
-
+
{slides.map((_slide, index) => (
); }; -export default Carousel; + +export default Carousel; \ No newline at end of file diff --git a/app/page.tsx b/app/page.tsx index 639f2a2..20a1f5d 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -27,11 +27,7 @@ export default function Home() { - {/*
- - {slides} - -
*/} +
@@ -42,6 +38,11 @@ export default function Home() { Chat Now Bot Store
+
+ + {slides} + +
diff --git a/lib/ModelSetting.ts b/lib/ModelSetting.ts index fcd38a1..65095d1 100644 --- a/lib/ModelSetting.ts +++ b/lib/ModelSetting.ts @@ -1,5 +1,3 @@ -import { LLMID } from "@/types" - /** * LLM 模型 */ @@ -181,7 +179,6 @@ export interface ChatStreamPayload { */ temperature: number; tool_choice?: string; - tools?: ChatCompletionTool[]; /** * @title 控制生成文本中最高概率的单个令牌 * @default 1 @@ -219,7 +216,7 @@ type ChatSettingLimits = { MAX_CONTEXT_LENGTH: number } -export const CHAT_SETTING_LIMITS: Record = { +export const CHAT_SETTING_LIMITS= { // ANTHROPIC MODELS "claude-2.1": { MIN_TEMPERATURE: 0.0, diff --git a/lib/supabase.ts b/lib/supabase.ts new file mode 100644 index 0000000..74c1822 --- /dev/null +++ b/lib/supabase.ts @@ -0,0 +1,72 @@ +// import { createClient } from "@supabase/supabase-js"; + +// interface Client { +// url?: string; +// key?: string; +// } + +// const client: Client = { +// url: process.env.NEXT_PUBLIC_SUPABASE_URL, +// key: process.env.SUPABASE_ANON_KEY +// }; + +// if (!client.url || !client.key) { +// throw new Error("Missing Supabase credentials"); +// } + +// export const supabaseClient = createClient(client.url!, client.key!); + +// import { NextPage } from "next"; +// import { useState } from "react"; + + +// const Embeddings: NextPage = () => { +// const [urls, setUrls] = useState([]); +// const [loading, setLoading] = useState(false); + +// const handleSubmit = async (e: React.FormEvent) => { +// e.preventDefault(); +// setLoading(true); + +// const response = await fetch("/api/generate-embeddings", { +// method: "POST", +// headers: { "Content-Type": "application/json" }, +// body: JSON.stringify({ urls }) +// }); + +// setLoading(false); + +// if (!response.ok) { +// // Handle error +// } +// }; + +// return ( +//
+//

+// Generate embeddings +//

+//

+// Paste a list of URLs below to geneate embeddings using the OpenAI API, and add the embeddings to the Supabase embeddings table. +//

+//
+//