🐛 (openai) Fix default response mapping item
This commit is contained in:
@@ -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])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user