Skip to content

Commit

Permalink
fix: migrate old url if in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
briansunter committed Oct 9, 2024
1 parent a1352d6 commit 1d8bd59
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lib/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,16 @@ const retryOptions = {
},
};

function migrateOldUrl(url: string) {
if (url.startsWith("http://api.openai.com")) {
return url.replace("http://api.openai.com", "https://api.openai.com");
}
return url;
}

export async function whisper(file: File,openAiOptions:OpenAIOptions): Promise<string> {
const apiKey = openAiOptions.apiKey;
const baseUrl = openAiOptions.completionEndpoint ? openAiOptions.completionEndpoint : "https://api.openai.com/v1";
const baseUrl = openAiOptions.completionEndpoint ? migrateOldUrl(openAiOptions.completionEndpoint) : "https://api.openai.com/v1";
const model = 'whisper-1';

// Create a FormData object and append the file
Expand Down

0 comments on commit 1d8bd59

Please sign in to comment.