Skip to content

Commit

Permalink
[UI]: Fix curl sample in model code button (#2027)
Browse files Browse the repository at this point in the history
- Remove trailing comma in JSON object
- Handle missing trailing slash in model URL
  • Loading branch information
jvstme authored Nov 22, 2024
1 parent 69eb0cf commit d8b6ccb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions frontend/src/pages/Models/Details/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 '{
Expand All @@ -35,6 +36,6 @@ export const getCurlModelCode = ({ model, token }: { model?: IModelExtended | nu
}
],
"stream": true,
"max_tokens": 512,
"max_tokens": 512
}'`;
};

0 comments on commit d8b6ccb

Please sign in to comment.