Skip to content

Commit 79bd40d

Browse files
committed
Minor Fix and refactor
1 parent 82c0b5d commit 79bd40d

4 files changed

Lines changed: 12 additions & 20 deletions

File tree

frontend/components/ChatBox.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@ import React, { useRef, useEffect } from 'react';
22
import ReactMarkdown from 'react-markdown';
33
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
44
import { oneDark } from 'react-syntax-highlighter/dist/cjs/styles/prism';
5-
import { get_encoding } from "@dqbd/tiktoken";
65
import ReactTooltip from 'react-tooltip';
7-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
8-
import { faInfoCircle } from '@fortawesome/free-solid-svg-icons';
96
import { Virtuoso } from 'react-virtuoso';
107
import { CopyToClipboard } from 'react-copy-to-clipboard';
118
import { FaClipboardCheck } from 'react-icons/fa';
129

13-
const encoding = get_encoding("cl100k_base");
14-
1510
const CodeBlock = React.memo(({ node, inline, className, children }) => {
1611
const match = /language-(\w+)/.exec(className || '');
1712
const lang = match && match[1] ? match[1] : '';
@@ -40,18 +35,13 @@ const Chatbox = ({ messages }) => {
4035
const chatboxRef = useRef(null);
4136
const Row = ({ index, data }) => {
4237
const message = data[index];
43-
if (!message.text || !encoding) {
38+
if (!message.text) {
4439
return null;
4540
}
4641

47-
const tokens = encoding.encode(message.text);
4842
return (
4943
<div className={message.user === 'human' ? "bg-gray-700 text-white p-5" : "bg-gray-600 p-5 text-white"}>
5044
<div className='flex flex-row w-1/2 mx-auto'>
51-
<FontAwesomeIcon icon={faInfoCircle} className="cursor-pointer mr-5" data-tip data-for={`tokenTip${index}`} />
52-
<ReactTooltip id={`tokenTip${index}`} place="top" effect='solid' delayHide={500} globalEventOff='mouseout'>
53-
Tokens: {tokens.length}
54-
</ReactTooltip>
5545
<ReactMarkdown children={message.text} className='flex-grow overflow-x-auto' components={{ code: CodeBlock }} />
5646
</div>
5747
</div>

frontend/components/ChatInput.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,33 @@ import React, { useState } from 'react';
22
import { AiOutlineSend } from 'react-icons/ai';
33

44
const ChatInput = ({ onSubmit }) => {
5-
const [input, setInput] = useState("");
5+
const [input, setInput] = useState('');
66

77
const handleSubmit = (e) => {
8-
console.log("input", input);
98
e.preventDefault();
109
onSubmit(input);
11-
setInput("");
10+
setInput('');
1211
};
1312

1413
return (
1514
<div className="flex flex-row bg-gray-800 text-center justify-center items-center w-full text-black pb-5">
16-
<form onSubmit={handleSubmit} className='flex w-1/2'>
15+
<form onSubmit={handleSubmit} className="flex w-1/2 relative">
1716
<input
1817
type="text"
1918
value={input}
2019
onChange={(e) => setInput(e.target.value)}
2120
placeholder="Type a message..."
22-
className="p-2 rounded mr-2 flex-grow"
21+
className="p-2 rounded mr-2 flex-grow pr-10"
2322
/>
24-
<button type="submit" className=" text-purple-700 font-bold py-2 px-4 rounded text-xl">
23+
<button
24+
type="submit"
25+
className="absolute right-0 top-0 bottom-0 m-auto text-purple-700 font-bold py-2 px-4 rounded text-xl"
26+
>
2527
<AiOutlineSend />
2628
</button>
2729
</form>
2830
</div>
2931
);
3032
};
3133

32-
export default ChatInput;
34+
export default ChatInput;

frontend/components/ModalBar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { get_encoding } from "@dqbd/tiktoken";
33
// import CustomModal from './CustomModal';
44
import ReactModal from 'react-modal';
55

6+
ReactModal.setAppElement('#__next');
67

78
const encoding = get_encoding("cl100k_base");
8-
ReactModal.setAppElement('#__next');
99

1010
const ModalBar = () => {
1111
const [systemPrompt, setSystemPrompt] = useState("");

frontend/components/RightSidebar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const RightSidebar = ({ isSidebarOpen }) => {
5656

5757

5858
return (
59-
<div className={`fixed h-full w-1/3 right-0 bg-neutral-800 transition-all duration-500 overflow-y-scroll p-6 text-gray-200 transform ${isSidebarOpen ? 'translate-x-0' : 'translate-x-full'} overflow-x-visible`}>
59+
<div className={`fixed h-full z-10 w-1/3 right-0 bg-neutral-800 transition-all duration-500 overflow-y-scroll p-6 text-gray-200 transform ${isSidebarOpen ? 'translate-x-0' : 'translate-x-full'} overflow-x-visible`}>
6060
<div className="flex flex-row justify-between items-center mb-2">
6161
<h2 className="text-xl font-bold mb-4 text-gray-100">Files and Summaries</h2>
6262
</div>

0 commit comments

Comments
 (0)