fix(ui): format model API response data

This commit is contained in:
psychedelicious 2024-03-05 23:07:43 +11:00
parent b0275700b3
commit 4a9cca6c2d

View File

@ -21,6 +21,13 @@ export const ModelMetadata = () => {
return MODEL_TYPE_TRIGGER_PHRASE.includes(data.type); return MODEL_TYPE_TRIGGER_PHRASE.includes(data.type);
}, [data]); }, [data]);
const apiResponseFormatted = useMemo(() => {
if (!data?.source_api_response) {
return {};
}
return JSON.parse(data.source_api_response);
}, [data?.source_api_response]);
return ( return (
<Flex flexDir="column" height="full" gap="3"> <Flex flexDir="column" height="full" gap="3">
{shouldShowTriggerPhraseSettings && ( {shouldShowTriggerPhraseSettings && (
@ -28,7 +35,7 @@ export const ModelMetadata = () => {
<TriggerPhrases /> <TriggerPhrases />
</Box> </Box>
)} )}
<DataViewer label="metadata" data={data?.source_api_response || {}} /> <DataViewer label="metadata" data={apiResponseFormatted} />
</Flex> </Flex>
); );
}; };