Skip to content

Commit

Permalink
✨ feat(documents):Add modal swicher
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackishGreen33 committed Dec 16, 2024
1 parent 30f704b commit 9cd3454
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@

import { UpstashDict, UpstashMessage } from '@upstash/rag-chat';
import dynamic from 'next/dynamic';
import { useState } from 'react';

import { useGetWorkspaceFile } from '@/common/api/files';
import ChatGPT from '@/common/components/chat/ChatGPT';
import ChatWrapper from '@/common/components/chat/ChatWrapper';
import { PageError, PageLoader } from '@/common/components/elements';
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/common/components/ui/select';
import { useFileId } from '@/common/hooks';

// import { getUserSubscriptionPlan } from '@/lib/stripe';

interface ChatClientProps {
Expand All @@ -24,6 +34,7 @@ const ChatClient: React.FC<ChatClientProps> = ({
sessionId,
initialMessages,
}) => {
const [modal, setModal] = useState<string>('bge-base-v1.5');
const fileId = useFileId();
const { data: file, isLoading } = useGetWorkspaceFile({
fileId,
Expand All @@ -47,12 +58,29 @@ const ChatClient: React.FC<ChatClientProps> = ({
<PdfRenderer url={file.url} />
</div>
</div>
<div className="flex-[0.75] shrink-0 border-t border-gray-200 lg:w-96 lg:border-l lg:border-t-0">
{/* <ChatWrapper isSubscribed={plan.isSubscribed} fileId={file.$id} /> */}
<ChatWrapper
sessionId={sessionId}
initialMessages={initialMessages}
/>
<div className="flex flex-[0.75] shrink-0 flex-col gap-3 border-t border-gray-200 lg:w-96 lg:border-l lg:border-t-0">
<Select
onValueChange={(e) => {
setModal(e);
}}
defaultValue={modal}
>
<SelectTrigger className="w-[180px]">
<SelectValue placeholder="选择模型" />
</SelectTrigger>
<SelectContent>
<SelectItem value="bge-base-v1.5">bge-base-v1.5</SelectItem>
<SelectItem value="gpt-4o mini">gpt-4o mini</SelectItem>
</SelectContent>
</Select>
{modal === 'bge-base-v1.5' ? (
<ChatWrapper
sessionId={sessionId}
initialMessages={initialMessages}
/>
) : (
<ChatGPT />
)}
</div>
</div>
</div>
Expand Down
12 changes: 12 additions & 0 deletions src/common/components/chat/ChatGPT.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const ChatGPT: React.FC = () => {
return (
<iframe
src="https://www.chatbase.co/chatbot-iframe/yywnk94ZYc4X6DzPiNKFv"
width="100%"
className="h-full min-h-[700px]"
frameBorder="0"
></iframe>
);
};

export default ChatGPT;

0 comments on commit 9cd3454

Please sign in to comment.