diff --git a/src/components/ConfigMenu/ModelSelect.tsx b/src/components/ConfigMenu/ModelSelect.tsx index ab00d7b7..a49b57b2 100644 --- a/src/components/ConfigMenu/ModelSelect.tsx +++ b/src/components/ConfigMenu/ModelSelect.tsx @@ -42,6 +42,7 @@ export const ModelSelect = ({ switch (m) { case 'gpt-4': case 'gpt-4-32k': + case 'gpt-4-1106-preview': case 'gpt-4-turbo-preview': case 'gpt-3.5-turbo': case 'gpt-3.5-turbo-16k': diff --git a/src/components/TokenCount/TokenCount.tsx b/src/components/TokenCount/TokenCount.tsx index 977bf993..f2463076 100644 --- a/src/components/TokenCount/TokenCount.tsx +++ b/src/components/TokenCount/TokenCount.tsx @@ -1,6 +1,7 @@ import React, { useEffect, useMemo, useState } from 'react'; import useStore from '@store/store'; import { shallow } from 'zustand/shallow'; +import { ModelChoice } from '@type/chat'; import countTokens from '@utils/messageUtils'; import { modelCost } from '@constants/chat'; @@ -15,12 +16,17 @@ const TokenCount = React.memo(() => { shallow ); - const model = useStore((state) => + let model = useStore((state) => state.chats ? state.chats[state.currentChatIndex].config.model : 'gpt-3.5-turbo' ); + // stop modelcount null index if bad model value (i.e. from 2.0.9) + if (!model) { + model = 'gpt-3.5-turbo'; + } + const cost = useMemo(() => { const price = modelCost[model].prompt.price * diff --git a/src/constants/chat.ts b/src/constants/chat.ts index 30df6061..1a9d3af5 100644 --- a/src/constants/chat.ts +++ b/src/constants/chat.ts @@ -12,6 +12,7 @@ Respond using Markdown.`; export const modelOptions: ModelChoice[] = [ 'gpt-3.5-turbo', 'gpt-3.5-turbo-16k', + 'gpt-4-1106-preview', 'gpt-4-turbo-preview', 'gpt-4', 'gpt-4-32k', @@ -32,6 +33,7 @@ export const modelMaxToken = { 'gpt-4': 8192, 'gpt-4-0314': 8192, 'gpt-4-0613': 8192, + 'gpt-4-1106-preview': 128000, 'gpt-4-turbo-preview': 128000, 'gpt-4-32k': 32768, 'gpt-4-32k-0314': 32768, @@ -77,6 +79,10 @@ export const modelCost = { prompt: { price: 0.03, unit: 1000 }, completion: { price: 0.06, unit: 1000 }, }, + 'gpt-4-1106-preview': { + prompt: { price: 0.01, unit: 1000 }, + completion: { price: 0.03, unit: 1000 }, + }, 'gpt-4-turbo-preview': { prompt: { price: 0.01, unit: 1000 }, completion: { price: 0.03, unit: 1000 }, diff --git a/src/types/chat.ts b/src/types/chat.ts index e467b7cf..3f984dd9 100644 --- a/src/types/chat.ts +++ b/src/types/chat.ts @@ -61,6 +61,7 @@ export type ModelChoice = | 'gpt-4' | 'gpt-4-0314' | 'gpt-4-0613' + | 'gpt-4-1106-preview' | 'gpt-4-turbo-preview' | 'gpt-4-32k' | 'gpt-4-32k-0314'