chore: download progress
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
import { OPENAI_COMPATIBLE } from '../apis';
|
||||
import { GPUSTACK_API, OPENAI_COMPATIBLE } from '../apis';
|
||||
import { fomatNodeJsParams, formatCurlArgs, formatPyParams } from './utils';
|
||||
|
||||
export const speechToTextCode = ({ api, parameters }: Record<string, any>) => {
|
||||
export const speechToTextCode = ({
|
||||
api: url,
|
||||
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 = `
|
||||
@@ -19,7 +24,7 @@ ${formatCurlArgs(parameters, true)}`
|
||||
from openai import OpenAI\n
|
||||
audio_file = open("audio.mp3", "rb")
|
||||
client = OpenAI(
|
||||
base_url="${host}/${OPENAI_COMPATIBLE}",
|
||||
base_url="${host}/${GPUSTACK_API}",
|
||||
api_key="YOUR_GPUSTACK_API_KEY"
|
||||
)
|
||||
|
||||
@@ -44,7 +49,7 @@ const OpenAI = require("openai");
|
||||
|
||||
const openai = new OpenAI({
|
||||
"apiKey": "YOUR_GPUSTACK_API_KEY",
|
||||
"baseURL": "${host}/${OPENAI_COMPATIBLE}"
|
||||
"baseURL": "${host}/${GPUSTACK_API}"
|
||||
});
|
||||
|
||||
async function main() {
|
||||
@@ -62,8 +67,12 @@ main();`.trim();
|
||||
};
|
||||
};
|
||||
|
||||
export const TextToSpeechCode = ({ api, parameters }: Record<string, any>) => {
|
||||
export const TextToSpeechCode = ({
|
||||
api: url,
|
||||
parameters
|
||||
}: Record<string, any>) => {
|
||||
const host = window.location.origin;
|
||||
const api = url.replace(OPENAI_COMPATIBLE, GPUSTACK_API);
|
||||
|
||||
// ========================= Curl =========================
|
||||
const curlCode = `
|
||||
@@ -78,7 +87,7 @@ from pathlib import Path
|
||||
from openai import OpenAI\n
|
||||
output_file_path = Path(__file__).parent / "output.mp3"
|
||||
client = OpenAI(
|
||||
base_url="${host}/${OPENAI_COMPATIBLE}",
|
||||
base_url="${host}/${GPUSTACK_API}",
|
||||
api_key="YOUR_GPUSTACK_API_KEY"
|
||||
)
|
||||
|
||||
@@ -103,7 +112,7 @@ const ouptFile = path.resolve("./output.mp3");
|
||||
|
||||
const openai = new OpenAI({
|
||||
"apiKey": "YOUR_GPUSTACK_API_KEY",
|
||||
"baseURL": "${host}/${OPENAI_COMPATIBLE}"
|
||||
"baseURL": "${host}/${GPUSTACK_API}"
|
||||
});
|
||||
|
||||
async function main() {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { OPENAI_COMPATIBLE } from '../apis';
|
||||
import { GPUSTACK_API, OPENAI_COMPATIBLE } from '../apis';
|
||||
import { fomatNodeJsParams, formatCurlArgs, formatPyParams } from './utils';
|
||||
|
||||
export const generateEmbeddingCode = ({
|
||||
api,
|
||||
api: url,
|
||||
parameters
|
||||
}: Record<string, any>) => {
|
||||
const host = window.location.origin;
|
||||
const api = url.replace(OPENAI_COMPATIBLE, GPUSTACK_API);
|
||||
|
||||
// ========================= Curl =========================
|
||||
const curlCode = `
|
||||
@@ -18,7 +19,7 @@ ${formatCurlArgs(parameters, false)}`.trim();
|
||||
const pythonCode = `
|
||||
from openai import OpenAI\n
|
||||
client = OpenAI(
|
||||
base_url="${host}/${OPENAI_COMPATIBLE}",
|
||||
base_url="${host}/${GPUSTACK_API}",
|
||||
api_key="YOUR_GPUSTACK_API_KEY"
|
||||
)
|
||||
|
||||
@@ -35,7 +36,7 @@ const OpenAI = require("openai");
|
||||
|
||||
const openai = new OpenAI({
|
||||
"apiKey": "YOUR_GPUSTACK_API_KEY",
|
||||
"baseURL": "${host}/${OPENAI_COMPATIBLE}"
|
||||
"baseURL": "${host}/${GPUSTACK_API}"
|
||||
});
|
||||
|
||||
async function main() {
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import _ from 'lodash';
|
||||
import { OPENAI_COMPATIBLE } from '../apis';
|
||||
import { GPUSTACK_API, OPENAI_COMPATIBLE } from '../apis';
|
||||
import { fomatNodeJsParams, formatCurlArgs, formatPyParams } from './utils';
|
||||
|
||||
export const generateImageCode = ({
|
||||
api,
|
||||
api: url,
|
||||
parameters,
|
||||
isFormdata = false,
|
||||
edit = false
|
||||
}: Record<string, any>) => {
|
||||
const host = window.location.origin;
|
||||
const api = url.replace(OPENAI_COMPATIBLE, GPUSTACK_API);
|
||||
|
||||
// ========================= Curl =========================
|
||||
let curlCode = `
|
||||
@@ -45,7 +46,7 @@ print(response.json()['data'][0]['b64_json'])`.trim();
|
||||
const nodeJsCode = `
|
||||
const axios = require('axios');
|
||||
|
||||
const url = "${host}/${OPENAI_COMPATIBLE}/images/generations";
|
||||
const url = "${host}/${GPUSTACK_API}/images/generations";
|
||||
const headers = {
|
||||
"Content-type": "application/json",
|
||||
"Authorization": "Bearer $\{YOUR_GPUSTACK_API_KEY}"
|
||||
@@ -64,12 +65,13 @@ axios.post(url, data, { headers }).then((response) => {
|
||||
};
|
||||
|
||||
export const generateOpenaiImageCode = ({
|
||||
api,
|
||||
api: url,
|
||||
parameters,
|
||||
isFormdata = false,
|
||||
edit = false
|
||||
}: Record<string, any>) => {
|
||||
const host = window.location.origin;
|
||||
const api = url.replace(OPENAI_COMPATIBLE, GPUSTACK_API);
|
||||
|
||||
// ========================= Curl =========================
|
||||
let curlCode = `
|
||||
@@ -93,7 +95,7 @@ ${formatCurlArgs(_.omit(parameters, ['mask', 'image']), isFormdata)}`
|
||||
const pythonCode = `
|
||||
from openai import OpenAI\n
|
||||
client = OpenAI(
|
||||
base_url="${host}/${OPENAI_COMPATIBLE}",
|
||||
base_url="${host}/${GPUSTACK_API}",
|
||||
api_key="YOUR_GPUSTACK_API_KEY"
|
||||
)
|
||||
|
||||
@@ -110,7 +112,7 @@ const OpenAI = require("openai");
|
||||
|
||||
const openai = new OpenAI({
|
||||
"apiKey": "YOUR_GPUSTACK_API_KEY",
|
||||
"baseURL": "${host}/${OPENAI_COMPATIBLE}"
|
||||
"baseURL": "${host}/${GPUSTACK_API}"
|
||||
});
|
||||
|
||||
async function main() {
|
||||
|
||||
Reference in New Issue
Block a user