From 5147da913c92915e8ed94119f0a00b624bb9ada6 Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 31 Oct 2023 23:00:09 +0000 Subject: [PATCH] add fix to detect json or string --- packages/components/src/utils.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/components/src/utils.ts b/packages/components/src/utils.ts index 9ef30a0e8..45acdd057 100644 --- a/packages/components/src/utils.ts +++ b/packages/components/src/utils.ts @@ -512,7 +512,7 @@ export const getUserHome = (): string => { /** * Map incoming chat history to ChatMessageHistory - * @param {options} ICommonObject + * @param {ICommonObject} options * @returns {ChatMessageHistory} */ export const mapChatHistory = (options: ICommonObject): ChatMessageHistory => { @@ -550,12 +550,12 @@ export const convertChatHistoryToText = (chatHistory: IMessage[] = []): string = /** * Convert schema to zod schema - * @param {string} schema + * @param {string | object} schema * @returns {ICommonObject} */ -export const convertSchemaToZod = (schema: string) => { +export const convertSchemaToZod = (schema: string | object): ICommonObject => { try { - const parsedSchema = JSON.parse(schema) + const parsedSchema = typeof schema === 'string' ? JSON.parse(schema) : schema const zodObj: ICommonObject = {} for (const sch of parsedSchema) { if (sch.type === 'string') {