chore: v1 to v2

This commit is contained in:
jialin
2025-11-20 17:31:15 +08:00
parent ea39a45f31
commit 551f04011a
12 changed files with 40 additions and 55 deletions
+7 -14
View File
@@ -1,5 +1,5 @@
import _ from 'lodash';
import { GPUSTACK_API, MODEL_PROXY, OPENAI_COMPATIBLE } from '../apis';
import { MODEL_PROXY, OPENAI_COMPATIBLE } from '../apis';
import { fomatNodeJsParams, formatCurlArgs, formatPyParams } from './utils';
export const generateSpeechToTextCurlCode = ({
@@ -9,9 +9,7 @@ export const generateSpeechToTextCurlCode = ({
}: Record<string, any>) => {
const host = window.location.origin;
// replace url OPENAI_COMPATIBLE with GPUSTACK
const api = modelProxy
? `${MODEL_PROXY}/\${YOUR_API_PATH}`
: url.replace(OPENAI_COMPATIBLE, GPUSTACK_API);
const api = modelProxy ? `${MODEL_PROXY}/\${YOUR_API_PATH}` : url;
// ========================= Curl =========================
const curlCode = `
@@ -32,8 +30,6 @@ export const speechToTextCode = ({
parameters
}: Record<string, any>) => {
const host = window.location.origin;
// replace url OPENAI_COMPATIBLE with GPUSTACK
const api = url.replace(OPENAI_COMPATIBLE, GPUSTACK_API);
// ========================= Curl =========================
const curlCode = generateSpeechToTextCurlCode({ api: url, parameters });
@@ -43,7 +39,7 @@ export const speechToTextCode = ({
from openai import OpenAI\n
audio_file = open("audio.mp3", "rb")
client = OpenAI(
base_url="${host}/${GPUSTACK_API}",
base_url="${host}/${OPENAI_COMPATIBLE}",
api_key="YOUR_GPUSTACK_API_KEY"
)
@@ -68,7 +64,7 @@ const OpenAI = require("openai");
const openai = new OpenAI({
"apiKey": "YOUR_GPUSTACK_API_KEY",
"baseURL": "${host}/${GPUSTACK_API}"
"baseURL": "${host}/${OPENAI_COMPATIBLE}"
});
async function main() {
@@ -92,9 +88,7 @@ export const generateTextToSpeechCurlCode = ({
parameters
}: Record<string, any>) => {
const host = window.location.origin;
const api = modelProxy
? `${MODEL_PROXY}/\${YOUR_API_PATH}`
: url.replace(OPENAI_COMPATIBLE, GPUSTACK_API);
const api = modelProxy ? `${MODEL_PROXY}/\${YOUR_API_PATH}` : url;
// ========================= Curl =========================
const curlCode = `
@@ -111,7 +105,6 @@ export const TextToSpeechCode = ({
parameters
}: Record<string, any>) => {
const host = window.location.origin;
const api = url.replace(OPENAI_COMPATIBLE, GPUSTACK_API);
// ========================= Curl =========================
const curlCode = generateTextToSpeechCurlCode({ api: url, parameters });
@@ -122,7 +115,7 @@ from pathlib import Path
from openai import OpenAI\n
output_file_path = Path(__file__).parent / "output.mp3"
client = OpenAI(
base_url="${host}/${GPUSTACK_API}",
base_url="${host}/${OPENAI_COMPATIBLE}",
api_key="YOUR_GPUSTACK_API_KEY"
)
@@ -147,7 +140,7 @@ const ouptFile = path.resolve("./output.mp3");
const openai = new OpenAI({
"apiKey": "YOUR_GPUSTACK_API_KEY",
"baseURL": "${host}/${GPUSTACK_API}"
"baseURL": "${host}/${OPENAI_COMPATIBLE}"
});
async function main() {