Skip to content

Commit

Permalink
remove deprecated code
Browse files Browse the repository at this point in the history
  • Loading branch information
Stan370 committed Aug 26, 2024
1 parent 0d6efa4 commit 17da9f8
Show file tree
Hide file tree
Showing 10 changed files with 376 additions and 44 deletions.
5 changes: 1 addition & 4 deletions app/api/chat/openai/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,14 @@ 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;
console.log(error);

return new Response(JSON.stringify({ message: errorMessage }), {
status: errorCode,
headers: {
"Content-Type": "application/json",
},
});
}
}
1 change: 0 additions & 1 deletion app/chat/agent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 0 additions & 6 deletions app/chat/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ const Chat = () => {
setMessage(event.target.value);
};

const handleKeyPress = (event) => {
if (event.key === 'Enter') {
sendMessage();
}
};
return (

<div className="relative min-h-screen flex flex-row bg-gray-50 dark:bg-[#17171a] dark:text-red-50 ">
Expand Down Expand Up @@ -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..."
/>
Expand Down
32 changes: 17 additions & 15 deletions app/components/Carousel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use client";

import Image from "next/image";
import { useEffect, useState } from "react";
import { ChevronLeft, ChevronRight } from "react-feather";

Expand All @@ -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);
Expand All @@ -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 (
<div className="overflow-hidden relative w-1/4 ">
<div className="overflow-hidden relative w-1/4">
<div
style={{ transform: `translateX(-${currentSlide * 100}%)` }}
className="flex w-full transition-transform duration-500 ease-in-out transform "
className="flex w-full transition-transform duration-500 ease-in-out transform"
>
{slides.map((slide, index) => (
<img
key={index}
className="flex-shrink-0 w-full md:min-h-96"
src={slide}
alt={`Slide ${index + 1}`}
/>
<img
key={index}
className="flex-shrink-0 w-full md:min-h-96"
src={slide}
alt={`Slide ${index + 1}`}
/>
))}
</div>

<div className="absolute flex justify-between items-center inset-0">
<button onClick={handlePrevSlide}>
<button onClick={handlePrevSlide} aria-label="Previous Slide">
<ChevronLeft />
</button>
<button onClick={handleNextSlide}>
<button onClick={handleNextSlide} aria-label="Next Slide">
<ChevronRight />
</button>
</div>
<div className="absolute left-0 right-0 bottom-2 ">
<div className="absolute left-0 right-0 bottom-2">
<div className="flex justify-center items-center gap-4">
{slides.map((_slide, index) => (
<div
Expand All @@ -68,4 +69,5 @@ const Carousel = ({
</div>
);
};
export default Carousel;

export default Carousel;
11 changes: 6 additions & 5 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ export default function Home() {
<link rel="icon" href="/favicon.ico" />
</Head>
<Sidebar />
{/* <div className="relative m-auto p-4">
<Carousel autoPlay={true}>
{slides}
</Carousel>
</div> */}

<div>

<section className="bg-gradient-to-r from-purple-500 to-indigo-600 text-white py-20">
Expand All @@ -42,6 +38,11 @@ export default function Home() {
<a href="/chat" className="bg-white text-purple-600 px-6 py-3 rounded-lg font-semibold hover:bg-gray-100">Chat Now</a>
<a href="#" className="bg-purple-700 text-white px-6 py-3 rounded-lg font-semibold hover:bg-purple-800">Bot Store</a>
</div>
<div className="relative m-auto p-4">
<Carousel autoPlay={true}>
{slides}
</Carousel>
</div>
</div>
</section>

Expand Down
5 changes: 1 addition & 4 deletions lib/ModelSetting.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { LLMID } from "@/types"

/**
* LLM 模型
*/
Expand Down Expand Up @@ -181,7 +179,6 @@ export interface ChatStreamPayload {
*/
temperature: number;
tool_choice?: string;
tools?: ChatCompletionTool[];
/**
* @title 控制生成文本中最高概率的单个令牌
* @default 1
Expand Down Expand Up @@ -219,7 +216,7 @@ type ChatSettingLimits = {
MAX_CONTEXT_LENGTH: number
}

export const CHAT_SETTING_LIMITS: Record<LLMID, ChatSettingLimits> = {
export const CHAT_SETTING_LIMITS= {
// ANTHROPIC MODELS
"claude-2.1": {
MIN_TEMPERATURE: 0.0,
Expand Down
72 changes: 72 additions & 0 deletions lib/supabase.ts
Original file line number Diff line number Diff line change
@@ -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<string[]>([]);
// const [loading, setLoading] = useState(false);

// const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
// 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 (
// <div className="flex flex-col items-center max-w-xl m-auto text-center">
// <h1 className="w-full my-5 text-2xl font-bold sm:text-4xl ">
// Generate embeddings
// </h1>
// <p className="mb-4">
// Paste a list of URLs below to geneate embeddings using the OpenAI API, and add the embeddings to the Supabase embeddings table.
// </p>
// <form onSubmit={handleSubmit}>
// <textarea
// className="w-full h-[150px] textarea textarea-bordered"
// placeholder="Enter URLs here"
// value={urls.join("\n")}
// onChange={(e) => setUrls(e.target.value.split("\n"))}
// />
// <button
// className="my-4 btn btn-primary"
// type="submit"
// disabled={loading}
// >
// Generate Embeddings
// </button>
// </form>
// {loading && <div>Loading...</div>}
// </div>
// );
// };

// export default Embeddings;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"scripts": {
"dev": "next dev",
"build": "tailwindcss -i ./app/globals.css -o ./public/styles.css && next build",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
Expand Down
Loading

0 comments on commit 17da9f8

Please sign in to comment.