2
0

🐛 (openai) Fix default response mapping item

This commit is contained in:
Baptiste Arnaud
2023-06-08 15:56:52 +02:00
parent 4614caf498
commit e9c2deee5f
2 changed files with 4 additions and 2 deletions

View File

@ -22,6 +22,7 @@ type Props<T> = {
initialItems: ItemWithId<T>[]
isOrdered?: boolean
addLabel?: string
newItemDefaultProps?: Partial<T>
Item: (props: TableListItemProps<T>) => JSX.Element
ComponentBetweenItems?: (props: unknown) => JSX.Element
onItemsChange: (items: ItemWithId<T>[]) => void
@ -31,6 +32,7 @@ export const TableList = <T,>({
initialItems,
isOrdered,
addLabel = 'Add',
newItemDefaultProps,
Item,
ComponentBetweenItems,
onItemsChange,
@ -40,7 +42,7 @@ export const TableList = <T,>({
const createItem = () => {
const id = createId()
const newItem = { id } as ItemWithId<T>
const newItem = { id, ...newItemDefaultProps } as ItemWithId<T>
setItems([...items, newItem])
onItemsChange([...items, newItem])
}

View File

@ -124,12 +124,12 @@ export const OpenAIChatCompletionSettings = ({
</Text>
<AccordionIcon />
</AccordionButton>
<AccordionPanel pt="4">
<TableList
initialItems={options.responseMapping}
Item={ChatCompletionResponseItem}
onItemsChange={updateResponseMapping}
newItemDefaultProps={{ valueToExtract: 'Message content' }}
/>
</AccordionPanel>
</AccordionItem>