fix: append routeID to model proxy URL and drop X-GPUStack-Model header
This commit is contained in:
@@ -5,17 +5,18 @@ import { fomatNodeJsParams, formatCurlArgs, formatPyParams } from './utils';
|
||||
export const generateSpeechToTextCurlCode = ({
|
||||
api: url,
|
||||
modelProxy,
|
||||
routeID,
|
||||
parameters
|
||||
}: Record<string, any>) => {
|
||||
const host = window.location.origin;
|
||||
// replace url OPENAI_COMPATIBLE with GPUSTACK
|
||||
const api = modelProxy ? `${MODEL_PROXY}/\${YOUR_API_PATH}` : url;
|
||||
const api = modelProxy ? `${MODEL_PROXY}/${routeID}/\${YOUR_API_PATH}` : url;
|
||||
|
||||
// ========================= Curl =========================
|
||||
const curlCode = `
|
||||
curl ${host}${api} \\
|
||||
-H "Content-Type: multipart/form-data" \\
|
||||
-H "Authorization: Bearer $\{YOUR_GPUSTACK_API_KEY}" \\${modelProxy ? `\n-H "X-GPUStack-Model: ${parameters.model}" \\` : ''}
|
||||
-H "Authorization: Bearer $\{YOUR_GPUSTACK_API_KEY}" \\
|
||||
-F model="${parameters.model}" \\
|
||||
-F file="@/path/to/file/audio.mp3;type=audio/mpeg" \\
|
||||
${formatCurlArgs(_.omit(parameters, 'model'), true)}`
|
||||
@@ -85,16 +86,17 @@ main();`.trim();
|
||||
export const generateTextToSpeechCurlCode = ({
|
||||
api: url,
|
||||
modelProxy,
|
||||
routeID,
|
||||
parameters
|
||||
}: Record<string, any>) => {
|
||||
const host = window.location.origin;
|
||||
const api = modelProxy ? `${MODEL_PROXY}/\${YOUR_API_PATH}` : url;
|
||||
const api = modelProxy ? `${MODEL_PROXY}/${routeID}/\${YOUR_API_PATH}` : url;
|
||||
|
||||
// ========================= Curl =========================
|
||||
const curlCode = `
|
||||
curl ${host}${api} \\
|
||||
-H "Content-Type: application/json" \\
|
||||
-H "Authorization: Bearer $\{YOUR_GPUSTACK_API_KEY}" \\${modelProxy ? `\n-H "X-GPUStack-Model: ${parameters.model}" \\` : ''}
|
||||
-H "Authorization: Bearer $\{YOUR_GPUSTACK_API_KEY}" \\
|
||||
${formatCurlArgs(parameters, false)} \\\n--output output.${parameters.response_format}`.trim();
|
||||
|
||||
return curlCode;
|
||||
|
||||
Reference in New Issue
Block a user