⚡ (openai) Add new models and remove tiktoken
Instead of computing total tokens with tiktoken we just attempt retries after trimming the first message
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { DropdownList } from '@/components/DropdownList'
|
||||
import { Textarea } from '@/components/inputs'
|
||||
import { Textarea, TextInput } from '@/components/inputs'
|
||||
import { VariableSearchInput } from '@/components/inputs/VariableSearchInput'
|
||||
import { TableListItemProps } from '@/components/TableList'
|
||||
import { Stack } from '@chakra-ui/react'
|
||||
@@ -55,6 +55,11 @@ export const ChatCompletionMessageItem = ({ item, onItemChange }: Props) => {
|
||||
})
|
||||
}
|
||||
|
||||
const updateName = (name: string) => {
|
||||
if (item.role === 'Messages sequence ✨') return
|
||||
onItemChange({ ...item, name })
|
||||
}
|
||||
|
||||
return (
|
||||
<Stack p="4" rounded="md" flex="1" borderWidth="1px">
|
||||
<DropdownList
|
||||
@@ -77,12 +82,19 @@ export const ChatCompletionMessageItem = ({ item, onItemChange }: Props) => {
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<Textarea
|
||||
defaultValue={item.content}
|
||||
onChange={changeSingleMessageContent}
|
||||
placeholder="Content"
|
||||
minH="150px"
|
||||
/>
|
||||
<>
|
||||
<Textarea
|
||||
defaultValue={item.content}
|
||||
onChange={changeSingleMessageContent}
|
||||
placeholder="Content"
|
||||
minH="150px"
|
||||
/>
|
||||
<TextInput
|
||||
defaultValue={item.name}
|
||||
onChange={updateName}
|
||||
placeholder="Name (Optional)"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</Stack>
|
||||
)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { DropdownList } from '@/components/DropdownList'
|
||||
import { TableList } from '@/components/TableList'
|
||||
import {
|
||||
chatCompletionModels,
|
||||
ChatCompletionOpenAIOptions,
|
||||
deprecatedCompletionModels,
|
||||
} from '@typebot.io/schemas/features/blocks/integrations/openai'
|
||||
import { ChatCompletionMessageItem } from './ChatCompletionMessageItem'
|
||||
import {
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
import { TextLink } from '@/components/TextLink'
|
||||
import { ChatCompletionResponseItem } from './ChatCompletionResponseItem'
|
||||
import { NumberInput } from '@/components/inputs'
|
||||
import { Select } from '@/components/inputs/Select'
|
||||
|
||||
const apiReferenceUrl =
|
||||
'https://platform.openai.com/docs/api-reference/chat/create'
|
||||
@@ -30,7 +31,11 @@ export const OpenAIChatCompletionSettings = ({
|
||||
options,
|
||||
onOptionsChange,
|
||||
}: Props) => {
|
||||
const updateModel = (model: (typeof chatCompletionModels)[number]) => {
|
||||
const updateModel = (
|
||||
_: string | undefined,
|
||||
model: (typeof chatCompletionModels)[number] | undefined
|
||||
) => {
|
||||
if (!model) return
|
||||
onOptionsChange({
|
||||
...options,
|
||||
model,
|
||||
@@ -74,10 +79,12 @@ export const OpenAIChatCompletionSettings = ({
|
||||
</TextLink>{' '}
|
||||
to better understand the available options.
|
||||
</Text>
|
||||
<DropdownList
|
||||
currentItem={options.model}
|
||||
items={chatCompletionModels}
|
||||
onItemSelect={updateModel}
|
||||
<Select
|
||||
selectedItem={options.model}
|
||||
items={chatCompletionModels.filter(
|
||||
(model) => deprecatedCompletionModels.indexOf(model) === -1
|
||||
)}
|
||||
onSelect={updateModel}
|
||||
/>
|
||||
<Accordion allowMultiple>
|
||||
<AccordionItem>
|
||||
|
||||
Reference in New Issue
Block a user