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

View File

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