From 3fdea6839f61e326bba0741764632c34ba23e6c9 Mon Sep 17 00:00:00 2001 From: lobehubbot Date: Fri, 10 May 2024 07:40:18 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20docs(bot):=20Auto=20sync=20agent?= =?UTF-8?q?s=20&=20plugin=20to=20readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libs/agent-runtime/azureOpenai/index.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/libs/agent-runtime/azureOpenai/index.ts b/src/libs/agent-runtime/azureOpenai/index.ts index 6eef7812f5c10..479ddcd409ca2 100644 --- a/src/libs/agent-runtime/azureOpenai/index.ts +++ b/src/libs/agent-runtime/azureOpenai/index.ts @@ -81,27 +81,25 @@ export class LobeAzureOpenAI implements LobeRuntimeAI { // Convert object keys to camel case, copy from `@azure/openai` in `node_modules/@azure/openai/dist/index.cjs` private camelCaseKeys = (obj: any): any => { - if (typeof obj !== "object" || !obj) - return obj; + if (typeof obj !== 'object' || !obj) return obj; if (Array.isArray(obj)) { return obj.map((v) => this.camelCaseKeys(v)); - } - else { + } else { for (const key of Object.keys(obj)) { const value = obj[key]; const newKey = this.tocamelCase(key); if (newKey !== key) { delete obj[key]; } - obj[newKey] = typeof obj[newKey] === "object" ? this.camelCaseKeys(value) : value; + obj[newKey] = typeof obj[newKey] === 'object' ? this.camelCaseKeys(value) : value; } return obj; } - } + }; private tocamelCase = (str: string) => { return str .toLowerCase() - .replace(/(_[a-z])/g, (group) => group.toUpperCase().replace("_", "")); - } + .replaceAll(/(_[a-z])/g, (group) => group.toUpperCase().replace('_', '')); + }; }