From d8b6ccb829bcd822943c89f7c302922ffad44ff1 Mon Sep 17 00:00:00 2001 From: jvstme <36324149+jvstme@users.noreply.github.com> Date: Fri, 22 Nov 2024 09:15:09 +0000 Subject: [PATCH] [UI]: Fix curl sample in model code button (#2027) - Remove trailing comma in JSON object - Handle missing trailing slash in model URL --- frontend/src/pages/Models/Details/helpers.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/Models/Details/helpers.ts b/frontend/src/pages/Models/Details/helpers.ts index 22d60b708..54d44e7c7 100644 --- a/frontend/src/pages/Models/Details/helpers.ts +++ b/frontend/src/pages/Models/Details/helpers.ts @@ -23,7 +23,8 @@ response = client.chat.completions.create( }; export const getCurlModelCode = ({ model, token }: { model?: IModelExtended | null; token?: string }) => { - return `curl ${getModelGateway(model?.base_url ?? '') + 'chat/completions'} \\ + const url = getModelGateway(model?.base_url ?? '').replace(/\/$/, '') + '/chat/completions'; + return `curl ${url} \\ -H "Content-Type: application/json" \\ -H "Authorization: Bearer ${token}" \\ -d '{ @@ -35,6 +36,6 @@ export const getCurlModelCode = ({ model, token }: { model?: IModelExtended | nu } ], "stream": true, - "max_tokens": 512, + "max_tokens": 512 }'`; };