fix: append routeID to model proxy URL and drop X-GPUStack-Model header

This commit is contained in:
jialin
2026-05-06 12:27:22 +08:00
committed by jialin
parent 9914db6b96
commit 2592f44bc2
14 changed files with 92 additions and 67 deletions
+6 -4
View File
@@ -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;
+3 -2
View File
@@ -4,16 +4,17 @@ import { fomatNodeJsParams, formatCurlArgs, formatPyParams } from './utils';
export const generateEmbeddingCurlCode = ({
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)}`.trim();
return curlCode;
+4 -3
View File
@@ -6,24 +6,25 @@ export const generateImageCurlCode = ({
api: url,
parameters,
modelProxy,
routeID,
isFormdata = false,
edit = false
}: 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 =========================
let 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, isFormdata)}`.trim();
if (edit) {
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 image="@image.png" \\
-F mask="@mask.png" \\
${formatCurlArgs(_.omit(parameters, ['mask', 'image']), isFormdata)}`
+3 -2
View File
@@ -4,16 +4,17 @@ import { fomatNodeJsParams, formatCurlArgs, formatPyParams } from './utils';
export const generateLLmCurlCode = ({
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)}`.trim();
return curlCode;
+5 -2
View File
@@ -4,16 +4,19 @@ import { formatCurlArgs } from './utils';
export const generateRerankCurlCode = ({
api,
modelProxy,
routeID,
parameters
}: Record<string, any>) => {
const host = window.location.origin;
const apiUrl = modelProxy ? `${MODEL_PROXY}/\${YOUR_API_PATH}` : api;
const apiUrl = modelProxy
? `${MODEL_PROXY}/${routeID}/\${YOUR_API_PATH}`
: api;
// ========================= Curl =========================
const curlCode = `
curl ${host}${apiUrl} \\
-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)}`.trim();
return curlCode;
+3 -2
View File
@@ -6,18 +6,19 @@ export const generateCurlCode = ({
api: url,
parameters,
modelProxy,
routeID,
isFormdata = false,
edit = false
}: 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: 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}" \\
${formatCurlArgs(_.omit(parameters, ['mask', 'image']), isFormdata)}`
.trim()
.replace(/\\$/, '');