-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to Radix-UI for UX Framework (#44)
- Loading branch information
Showing
63 changed files
with
5,246 additions
and
3,065 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
# Duplicate this to .env.local for local development | ||
# For more details, visit the following link: https://github.com/blrchen/chatgpt-lite#environment-variables | ||
# Duplicate this file and rename as '.env.local' for local development. | ||
# You must obtain OpenAI or Azure OpenAI credentials to run this application. | ||
# For detailed instructions on using these variables, visit: | ||
# https://github.com/blrchen/chatgpt-lite#environment-variables | ||
|
||
# OpenAI API credentials. These are necessary if you intend to utilize the OpenAI API. | ||
OPENAI_API_KEY= | ||
# OpenAI API credentials (required for using the OpenAI API): | ||
# Sign up at https://openai.com/api/ to get your API key. | ||
OPENAI_API_KEY= # <-- Insert your OpenAI API key here | ||
OPENAI_API_BASE_URL="https://api.openai.com" | ||
|
||
# Azure OpenAI API credentials. These are necessary if you intend to utilize the Azure OpenAI API. | ||
# AZURE_OPENAI_API_BASE_URL= | ||
# AZURE_OPENAI_API_KEY= | ||
# AZURE_OPENAI_DEPLOYMENT= | ||
# Azure OpenAI API credentials (required for using the Azure OpenAI API): | ||
# Sign up at https://azure.microsoft.com/en-us/services/cognitive-services/openai/ for Azure OpenAI credentials. | ||
# Uncomment the following lines and insert your credentials if you're using Azure OpenAI. | ||
# AZURE_OPENAI_API_BASE_URL= # <-- Insert your Azure OpenAI API base URL here | ||
# AZURE_OPENAI_API_KEY= # <-- Insert your Azure OpenAI API key here | ||
# AZURE_OPENAI_DEPLOYMENT= # <-- Insert your Azure OpenAI deployment name here | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,5 @@ | ||
'use client' | ||
|
||
import { useState } from 'react' | ||
|
||
import Sidebar from '@/components/sidebar' | ||
import Chat from '@/components/chat' | ||
import MobileNav from '@/components/mobileNav' | ||
import ChatContext from '@/contexts/chatContext' | ||
import useChatHook from '@/hooks/useChatHook' | ||
import PersonaModal from '@/components/personaModal' | ||
import PromptPanel from '@/components/personaPanel' | ||
|
||
export default function Home() { | ||
const provider = useChatHook() | ||
|
||
const [isComponentVisible, setIsComponentVisible] = useState(false) | ||
|
||
const toggleComponentVisibility = () => { | ||
setIsComponentVisible(!isComponentVisible) | ||
} | ||
|
||
return ( | ||
<ChatContext.Provider value={provider}> | ||
<main className="overflow-hidden w-full h-screen relative flex"> | ||
<MobileNav | ||
showMobileSiderbar={isComponentVisible} | ||
toggleComponentVisibility={toggleComponentVisibility} | ||
/> | ||
|
||
<div className="dark hidden flex-shrink-0 bg-gray-900 md:flex md:w-[260px] md:flex-col"> | ||
<Sidebar /> | ||
</div> | ||
|
||
<div className="relative max-w-full flex-1 h-full"> | ||
<Chat ref={provider.chatRef} /> | ||
<PromptPanel /> | ||
</div> | ||
<PersonaModal /> | ||
</main> | ||
</ChatContext.Provider> | ||
) | ||
return <main className="p-4"></main> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import React, { useContext, useEffect } from 'react' | ||
|
||
import { Button, Dialog, Flex, TextField, TextArea } from '@radix-ui/themes' | ||
import { useForm } from 'react-hook-form' | ||
|
||
import { ChatContext, Persona } from '@/components' | ||
|
||
const PersonaModal = () => { | ||
const { | ||
isOpenPersonaModal: open, | ||
personaModalLoading: isLoading, | ||
editPersona: detail, | ||
onCreatePersona, | ||
onClosePersonaModal | ||
} = useContext(ChatContext) | ||
|
||
const { | ||
register, | ||
handleSubmit, | ||
setValue, | ||
formState: { errors } | ||
} = useForm() | ||
|
||
const formSubmit = handleSubmit((values: any) => { | ||
onCreatePersona?.(values as Persona) | ||
}) | ||
|
||
useEffect(() => { | ||
if (detail) { | ||
setValue('name', detail.name, { shouldTouch: true }) | ||
setValue('prompt', detail.prompt, { shouldTouch: true }) | ||
} | ||
}, [detail, setValue]) | ||
|
||
return ( | ||
<Dialog.Root open={open!}> | ||
<Dialog.Content size="4"> | ||
<Dialog.Title>Prompt</Dialog.Title> | ||
<Dialog.Description size="2" mb="4"></Dialog.Description> | ||
<form onSubmit={formSubmit}> | ||
<Flex direction="column" gap="3"> | ||
<TextField.Input placeholder="Name" {...register('name', { required: true })} /> | ||
|
||
<TextArea placeholder="Prompt" rows={7} {...register('prompt', { required: true })} /> | ||
</Flex> | ||
|
||
<Flex gap="3" mt="4" justify="end"> | ||
<Dialog.Close> | ||
<Button variant="soft" type="button" color="gray" onClick={onClosePersonaModal}> | ||
Cancel | ||
</Button> | ||
</Dialog.Close> | ||
<Dialog.Close> | ||
<Button variant="soft" type="submit"> | ||
OK | ||
</Button> | ||
</Dialog.Close> | ||
</Flex> | ||
</form> | ||
</Dialog.Content> | ||
</Dialog.Root> | ||
) | ||
} | ||
|
||
export default PersonaModal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use client' | ||
|
||
import { Flex } from '@radix-ui/themes' | ||
import { Chat, ChatSiderBar, PersonaPanel, ChatContext, useChatHook } from '@/components' | ||
|
||
import PersonaModal from './PersonaModal' | ||
|
||
const ChatPage = () => { | ||
const provider = useChatHook() | ||
|
||
return ( | ||
<ChatContext.Provider value={provider}> | ||
<Flex style={{ height: 'calc(100% - 56px)' }} className="relative"> | ||
<ChatSiderBar /> | ||
<div className="flex-1 relative"> | ||
<Chat ref={provider.chatRef} /> | ||
<PersonaPanel /> | ||
</div> | ||
</Flex> | ||
<PersonaModal /> | ||
</ChatContext.Provider> | ||
) | ||
} | ||
|
||
export default ChatPage |
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.