esgimate token length after editing

This commit is contained in:
2023-07-08 14:45:21 +08:00
parent 4ce23bb1eb
commit feecd6582d

View File

@@ -74,7 +74,7 @@ export default function Message(props: Props) {
token{" "} token{" "}
<input <input
value={chat.token} value={chat.token}
className='w-20' className="w-20"
onChange={(event: any) => { onChange={(event: any) => {
chat.token = parseInt(event.target.value); chat.token = parseInt(event.target.value);
props.update_total_tokens(); props.update_total_tokens();
@@ -113,6 +113,7 @@ export default function Message(props: Props) {
value={chat.content} value={chat.content}
onChange={(event: any) => { onChange={(event: any) => {
chat.content = event.target.value; chat.content = event.target.value;
chat.token = calculate_token_length(chat.content);
setChatStore({ ...chatStore }); setChatStore({ ...chatStore });
}} }}
></textarea> ></textarea>