@@ -3,11 +3,12 @@ import { atom, useAtom, useAtomValue } from 'jotai';
3
3
import { atomWithStorage } from 'jotai/utils' ;
4
4
import { memo , useEffect , useMemo } from 'react' ;
5
5
6
+ import { modelFromName } from '@/app/utils/models' ;
6
7
import { getTokenCount } from '@/app/utils/tokens' ;
7
8
8
9
import { parametersAtom } from '@/app/components/Parameters' ;
9
10
10
- const systemMessageMaxTokens = 400 ;
11
+ const systemMessageMaxTokens = 4096 ;
11
12
12
13
export const tokensAtom = atomWithStorage ( 'tokens' , {
13
14
input : 0 ,
@@ -20,15 +21,11 @@ export const tokensAtom = atomWithStorage('tokens', {
20
21
interface TokenCountProps {
21
22
input ?: string ;
22
23
systemMessage : string ;
23
- display ?: " input" | " systemMessage" ;
24
+ display ?: ' input' | ' systemMessage' ;
24
25
}
25
26
26
27
export const TokenCount = memo (
27
- ( {
28
- input = '' ,
29
- systemMessage,
30
- display = 'input'
31
- } : TokenCountProps ) => {
28
+ ( { input = '' , systemMessage, display = 'input' } : TokenCountProps ) => {
32
29
const inputTokensAtom = atom ( 0 ) ;
33
30
const systemMessageTokensAtom = atom ( 0 ) ;
34
31
const remainingTokensAtom = atom ( 16384 ) ;
@@ -43,7 +40,8 @@ export const TokenCount = memo(
43
40
remainingSystemTokensAtom
44
41
) ;
45
42
const parameters = useAtomValue ( parametersAtom ) ;
46
- const maxTokens = parameters . model . includes ( 'gpt-4' ) ? 128000 : 16384 ;
43
+ const model = modelFromName ( parameters . model ) ;
44
+ const maxTokens = model ?. maxInputTokens || 16384 ;
47
45
const [ tokens , setTokens ] = useAtom ( tokensAtom ) ;
48
46
49
47
useEffect ( ( ) => {
0 commit comments