diff --git a/README.md b/README.md index 492c246..6b540c2 100644 --- a/README.md +++ b/README.md @@ -20,14 +20,15 @@ Expect frequent improvements. **Next up:** +- [ ] More custom model settings +- [ ] Regenerate & edit responses - [ ] Saving via data export - [ ] Folders -- [ ] Custom model settings - [ ] Prompt templates -- [ ] Regenerate & edit responses **Recent updates:** +- [x] Custom system prompt (3/21/23) - [x] Error handling (3/20/23) - [x] GPT-4 support (access required) (3/20/23) - [x] Search conversations (3/19/23) @@ -52,7 +53,7 @@ Modify the system prompt in `utils/index.ts`. Host your own live version of Chatbot UI with Vercel. -[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fmckaywrigley%2Fchatbot-ui&envDescription=Your%20OpenAI%20API%20Key.%20Chat%20will%20not%20work%20if%20you%20don't%20provide%20it.) +[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fmckaywrigley%2Fchatbot-ui) **Replit** diff --git a/components/Chat/Chat.tsx b/components/Chat/Chat.tsx index 85ddd8b..6a997b1 100644 --- a/components/Chat/Chat.tsx +++ b/components/Chat/Chat.tsx @@ -1,10 +1,11 @@ -import { Conversation, Message, OpenAIModel } from "@/types"; +import { Conversation, KeyValuePair, Message, OpenAIModel } from "@/types"; import { FC, useEffect, useRef, useState } from "react"; import { ChatInput } from "./ChatInput"; import { ChatLoader } from "./ChatLoader"; import { ChatMessage } from "./ChatMessage"; import { ModelSelect } from "./ModelSelect"; import { Regenerate } from "./Regenerate"; +import { SystemPrompt } from "./SystemPrompt"; interface Props { conversation: Conversation; @@ -15,20 +16,10 @@ interface Props { loading: boolean; lightMode: "light" | "dark"; onSend: (message: Message, isResend: boolean) => void; - onModelChange: (conversation: Conversation, model: OpenAIModel) => void; + onUpdateConversation: (conversation: Conversation, data: KeyValuePair) => void; } -export const Chat: FC = ({ - conversation, - models, - messageIsStreaming, - modelError, - messageError, - loading, - lightMode, - onSend, - onModelChange, -}) => { +export const Chat: FC = ({ conversation, models, messageIsStreaming, modelError, messageError, loading, lightMode, onSend, onUpdateConversation }) => { const [currentMessage, setCurrentMessage] = useState(); const messagesEndRef = useRef(null); @@ -46,38 +37,36 @@ export const Chat: FC = ({ {modelError ? (
Error fetching models.
-
- Make sure your OpenAI API key is set in the bottom left of the - sidebar or in a .env.local file and refresh. -
-
- If you completed this step, OpenAI may be experiencing issues. -
+
Make sure your OpenAI API key is set in the bottom left of the sidebar or in a .env.local file and refresh.
+
If you completed this step, OpenAI may be experiencing issues.
) : ( <>
{conversation.messages.length === 0 ? ( <> -
- - onModelChange(conversation, model) - } - /> -
+
+
{models.length === 0 ? "Loading..." : "Chatbot UI"}
-
- {models.length === 0 ? "Loading..." : "Chatbot UI"} + {models.length > 0 && ( +
+ onUpdateConversation(conversation, { key: "model", value: model })} + /> + + onUpdateConversation(conversation, { key: "prompt", value: prompt })} + /> +
+ )}
) : ( <> -
- Model: {conversation.model.name} -
+
Model: {conversation.model.name}
{conversation.messages.map((message, index) => ( = ({ onSend, messageIsStreaming, model }) => { }; const isMobile = () => { - const userAgent = - typeof window.navigator === "undefined" ? "" : navigator.userAgent; - const mobileRegex = - /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i; + const userAgent = typeof window.navigator === "undefined" ? "" : navigator.userAgent; + const mobileRegex = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i; return mobileRegex.test(userAgent); }; @@ -72,12 +70,12 @@ export const ChatInput: FC = ({ onSend, messageIsStreaming, model }) => {