Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added time to first token as requested in the README #110

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion app/src/pages/compare.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,17 @@ const ModelCardStats = (props: any) => {
const [isTimerRunning, setIsTimerRunning] = useState<boolean>(false);
const intervalRef = useRef(null);
const [time, setTime] = useState(0);
const [timeToFirstToken, setFirstTokenTime] = useState(0);
const [receivedFirstToken, setReceivedFirstToken] = useState(false);

useEffect(() => {
if (is_running && isTimerRunning === false) {
startTimer()
if (!receivedFirstToken){
let first_token_time = intervalRef.current >= 1000 ? `${intervalRef.current} s` : `${intervalRef.current} ms`
setFirstTokenTime(first_token_time)
setReceivedFirstToken(false)
}
} else if (!is_running && isTimerRunning === true) {
stopTimer()
}
Expand Down Expand Up @@ -121,7 +128,9 @@ const ModelCardStats = (props: any) => {

return (
<div className="flex font-medium">
<span>{formatTime(time)}</span>
<span>First: {timeToFirstToken}</span>
<span className="flex-1"></span>
<span>Total: {formatTime(time)}</span>
<span className="flex-1"></span>
<span>
<Tooltip delayDuration={300} skipDelayDuration={150} open={errorMessage ? true : false}>
Expand Down
1 change: 1 addition & 0 deletions server/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ six==1.16.0
sseclient==0.0.27
torch==2.0.0
transformers==4.27.1
Werkzeug==2.2.2