better compatibility for custom api (ollama etc.)

This commit is contained in:
josc146
2024-03-26 21:33:30 +08:00
parent 253568ef29
commit a15c4bdf63
7 changed files with 42 additions and 20 deletions

View File

@@ -32,7 +32,7 @@ import {
flushMidiRecordingContent,
getMidiRawContentMainInstrument,
getMidiRawContentTime,
getServerRoot,
getReqUrl,
OpenFileDialog,
refreshTracksTotalTime
} from '../../utils';
@@ -474,8 +474,13 @@ const AudiotrackEditor: FC<{ setPrompt: (prompt: string) => void }> = observer((
OpenFileDialog('*.mid').then(async blob => {
const bodyForm = new FormData();
bodyForm.append('file_data', blob);
fetch(getServerRoot(commonStore.getCurrentModelConfig().apiParameters.apiPort) + '/midi-to-text', {
const {
url,
headers
} = await getReqUrl(commonStore.getCurrentModelConfig().apiParameters.apiPort, '/midi-to-text');
fetch(url, {
method: 'POST',
headers,
body: bodyForm
}).then(async r => {
if (r.status === 200) {