From 063acc6f20af7333e8b8ee71aa1c368b500ef0b6 Mon Sep 17 00:00:00 2001 From: Sean Sube Date: Thu, 20 Jul 2023 08:23:58 -0500 Subject: [PATCH] handle json in comments field --- gui/src/components/Profiles.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gui/src/components/Profiles.tsx b/gui/src/components/Profiles.tsx index c0185e11..92fe992f 100644 --- a/gui/src/components/Profiles.tsx +++ b/gui/src/components/Profiles.tsx @@ -14,7 +14,7 @@ import { TextField, } from '@mui/material'; import * as ExifReader from 'exifreader'; -import { defaultTo } from 'lodash'; +import { defaultTo, isString } from 'lodash'; import * as React from 'react'; import { useContext } from 'react'; import { useTranslation } from 'react-i18next'; @@ -176,11 +176,11 @@ export async function parseImageParams(file: File): Promise { +export async function parseAutoComment(comment: string): Promise> { + if (isProbablyJSON(comment)) { + return parseJSONParams(comment); + } + const lines = comment.split('\n'); const [prompt, maybeNegative, ...otherLines] = lines;