chore: v1 to v2
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { GPUSTACK_API, MODEL_PROXY, OPENAI_COMPATIBLE } from '../apis';
|
||||
import { MODEL_PROXY, OPENAI_COMPATIBLE } from '../apis';
|
||||
import { fomatNodeJsParams, formatCurlArgs, formatPyParams } from './utils';
|
||||
|
||||
export const generateEmbeddingCurlCode = ({
|
||||
@@ -7,9 +7,7 @@ export const generateEmbeddingCurlCode = ({
|
||||
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 = `
|
||||
@@ -26,7 +24,6 @@ export const generateEmbeddingCode = ({
|
||||
parameters
|
||||
}: Record<string, any>) => {
|
||||
const host = window.location.origin;
|
||||
const api = url.replace(OPENAI_COMPATIBLE, GPUSTACK_API);
|
||||
|
||||
// ========================= Curl =========================
|
||||
const curlCode = generateEmbeddingCurlCode({ api: url, parameters });
|
||||
@@ -35,7 +32,7 @@ export const generateEmbeddingCode = ({
|
||||
const pythonCode = `
|
||||
from openai import OpenAI\n
|
||||
client = OpenAI(
|
||||
base_url="${host}/${GPUSTACK_API}",
|
||||
base_url="${host}/${OPENAI_COMPATIBLE}",
|
||||
api_key="YOUR_GPUSTACK_API_KEY"
|
||||
)
|
||||
|
||||
@@ -52,7 +49,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() {
|
||||
|
||||
@@ -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 generateImageCurlCode = ({
|
||||
@@ -10,9 +10,7 @@ export const generateImageCurlCode = ({
|
||||
edit = false
|
||||
}: 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 =========================
|
||||
let curlCode = `
|
||||
@@ -43,7 +41,7 @@ export const generateImageCode = ({
|
||||
edit = false
|
||||
}: Record<string, any>) => {
|
||||
const host = window.location.origin;
|
||||
const api = url.replace(OPENAI_COMPATIBLE, GPUSTACK_API);
|
||||
const api = url;
|
||||
|
||||
// ========================= Curl =========================
|
||||
let curlCode = generateImageCurlCode({
|
||||
@@ -69,7 +67,7 @@ print(response.json()['data'][0]['b64_json'])`.trim();
|
||||
const nodeJsCode = `
|
||||
const axios = require('axios');
|
||||
|
||||
const url = "${host}/${GPUSTACK_API}/images/generations";
|
||||
const url = "${host}/${OPENAI_COMPATIBLE}/images/generations";
|
||||
const headers = {
|
||||
"Content-type": "application/json",
|
||||
"Authorization": "Bearer $\{YOUR_GPUSTACK_API_KEY}"
|
||||
@@ -94,7 +92,7 @@ export const generateOpenaiImageCode = ({
|
||||
edit = false
|
||||
}: Record<string, any>) => {
|
||||
const host = window.location.origin;
|
||||
const api = url.replace(OPENAI_COMPATIBLE, GPUSTACK_API);
|
||||
const api = url;
|
||||
|
||||
// ========================= Curl =========================
|
||||
let curlCode = `
|
||||
@@ -118,7 +116,7 @@ ${formatCurlArgs(_.omit(parameters, ['mask', 'image']), isFormdata)}`
|
||||
const pythonCode = `
|
||||
from openai import OpenAI\n
|
||||
client = OpenAI(
|
||||
base_url="${host}/${GPUSTACK_API}",
|
||||
base_url="${host}/${OPENAI_COMPATIBLE}",
|
||||
api_key="YOUR_GPUSTACK_API_KEY"
|
||||
)
|
||||
|
||||
@@ -135,7 +133,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() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { GPUSTACK_API, MODEL_PROXY, OPENAI_COMPATIBLE } from '../apis';
|
||||
import { MODEL_PROXY, OPENAI_COMPATIBLE } from '../apis';
|
||||
import { fomatNodeJsParams, formatCurlArgs, formatPyParams } from './utils';
|
||||
|
||||
export const generateLLmCurlCode = ({
|
||||
@@ -7,9 +7,7 @@ export const generateLLmCurlCode = ({
|
||||
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 = `
|
||||
@@ -26,7 +24,6 @@ export const generateLLMCode = ({
|
||||
parameters
|
||||
}: Record<string, any>) => {
|
||||
const host = window.location.origin;
|
||||
const api = url.replace(OPENAI_COMPATIBLE, GPUSTACK_API);
|
||||
|
||||
// ========================= Curl =========================
|
||||
const curlCode = generateLLmCurlCode({ api: url, parameters });
|
||||
@@ -35,7 +32,7 @@ export const generateLLMCode = ({
|
||||
const pythonCode = `
|
||||
from openai import OpenAI\n
|
||||
client = OpenAI(
|
||||
base_url="${host}/${GPUSTACK_API}",
|
||||
base_url="${host}/${OPENAI_COMPATIBLE}",
|
||||
api_key="YOUR_GPUSTACK_API_KEY"
|
||||
)
|
||||
|
||||
@@ -52,7 +49,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() {
|
||||
|
||||
Reference in New Issue
Block a user