@@ -2,16 +2,11 @@ import React, { useRef, useEffect } from 'react';
22import ReactMarkdown from 'react-markdown' ;
33import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter' ;
44import { oneDark } from 'react-syntax-highlighter/dist/cjs/styles/prism' ;
5- import { get_encoding } from "@dqbd/tiktoken" ;
65import ReactTooltip from 'react-tooltip' ;
7- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' ;
8- import { faInfoCircle } from '@fortawesome/free-solid-svg-icons' ;
96import { Virtuoso } from 'react-virtuoso' ;
107import { CopyToClipboard } from 'react-copy-to-clipboard' ;
118import { FaClipboardCheck } from 'react-icons/fa' ;
129
13- const encoding = get_encoding ( "cl100k_base" ) ;
14-
1510const CodeBlock = React . memo ( ( { node, inline, className, children } ) => {
1611 const match = / l a n g u a g e - ( \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 >
0 commit comments