-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4c3100
commit 28fc65c
Showing
9 changed files
with
17 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
import axios from "axios"; | ||
import { getServiceUrl, isProxyEnabled } from "shared/helpers/utils"; | ||
import { isProxyEnabled } from "shared/helpers/utils"; | ||
|
||
import useSettingStore from "../../../shared/store/setting"; | ||
import type { Service } from "../../service/types"; | ||
import type { TranscriptionsGeneration } from "../types"; | ||
|
||
const generateTranscriptions = async (service: Service, data: TranscriptionsGeneration) => { | ||
const backendUrl = getServiceUrl(service.invokeMethod, "v1/audio/transcriptions"); | ||
const formData = new FormData(); | ||
formData.append("file", data.file); | ||
formData.append("model", data.model); | ||
|
||
const isIP = useSettingStore.getState().isIP; | ||
const headers = { "Content-Type": "multipart/form-data" }; | ||
if (isProxyEnabled() && isIP) { | ||
Object.assign(headers, service.invokeMethod.header); | ||
} | ||
return axios.post(backendUrl, formData, { headers }); | ||
return axios.post(`${service.invokeMethod.baseUrl}/v1/audio/transcriptions`, formData, { | ||
headers, | ||
}); | ||
}; | ||
|
||
export default generateTranscriptions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
import axios from "axios"; | ||
import { getServiceUrl, isProxyEnabled } from "shared/helpers/utils"; | ||
import { isProxyEnabled } from "shared/helpers/utils"; | ||
|
||
import useSettingStore from "../../../shared/store/setting"; | ||
import type { Service } from "../../service/types"; | ||
import type { ImageGeneration } from "../types"; | ||
|
||
const generateImage = async (service: Service, data: ImageGeneration) => { | ||
const backendUrl = getServiceUrl(service.invokeMethod, "v1/images/generations"); | ||
const isIP = useSettingStore.getState().isIP; | ||
const headers = { "Content-Type": "application/json" }; | ||
if (isProxyEnabled() && isIP) { | ||
Object.assign(headers, service.invokeMethod.header); | ||
} | ||
return axios.post(backendUrl, data, { headers }); | ||
return axios.post(`${service.invokeMethod.baseUrl}/v1/images/generation`, data, { headers }); | ||
}; | ||
|
||
export default generateImage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
import axios from "axios"; | ||
import { getServiceUrl, isProxyEnabled } from "shared/helpers/utils"; | ||
import { isProxyEnabled } from "shared/helpers/utils"; | ||
|
||
import useSettingStore from "../../../shared/store/setting"; | ||
import type { Service } from "../../service/types"; | ||
import type { AudioGenerationData } from "../types"; | ||
|
||
const generateAudio = async (service: Service, data: AudioGenerationData) => { | ||
const backendUrl = getServiceUrl(service.invokeMethod, "v1/audio/generation"); | ||
const isIP = useSettingStore.getState().isIP; | ||
const headers = { "Content-Type": "application/json" }; | ||
if (isProxyEnabled() && isIP) { | ||
Object.assign(headers, service.invokeMethod.header); | ||
} | ||
return axios.post(`${backendUrl}`, data, { headers }); | ||
return axios.post(`${service.invokeMethod.baseUrl}/v1/audio/generation`, data, { headers }); | ||
}; | ||
|
||
export default generateAudio; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,24 @@ | ||
import axios from "axios"; | ||
import { getServiceUrl, isProxyEnabled } from "shared/helpers/utils"; | ||
import { isProxyEnabled } from "shared/helpers/utils"; | ||
|
||
import useSettingStore from "../../../shared/store/setting"; | ||
import type { Service } from "../../service/types"; | ||
import type { ImageGeneration } from "../types"; | ||
|
||
const generateUpscalerImage = async (service: Service, data: ImageGeneration) => { | ||
const backendUrl = getServiceUrl(service.invokeMethod, "v1/images/upscale"); | ||
const formData = new FormData(); | ||
formData.append("image", data.image); | ||
formData.append("prompt", data.prompt); | ||
formData.append("n", `${data.n}`); | ||
formData.append("response_format", data.response_format); | ||
formData.append("guidance_scale", `${data.guidance_scale}`); | ||
formData.append("num_inference_steps", `${data.num_inference_steps}`); | ||
|
||
const isIP = useSettingStore.getState().isIP; | ||
const headers = { "Content-Type": "multipart/form-data" }; | ||
if (isProxyEnabled() && isIP) { | ||
Object.assign(headers, service.invokeMethod.header); | ||
} | ||
|
||
return axios.post(backendUrl, formData, { headers }); | ||
return axios.post(`${service.invokeMethod.baseUrl}/v1/images/upscale`, formData, { headers }); | ||
}; | ||
|
||
export default generateUpscalerImage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters