mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
Merge pull request #812 from RooVetGit/cte/catch-openai-handler-exception
Don't throw when `openAiBaseUrl` is not a valid URL
This commit is contained in:
commit
8f410b7bbf
1 changed files with 13 additions and 3 deletions
|
|
@ -18,10 +18,20 @@ export class OpenAiHandler implements ApiHandler, SingleCompletionHandler {
|
|||
|
||||
constructor(options: ApiHandlerOptions) {
|
||||
this.options = options
|
||||
// Azure API shape slightly differs from the core API shape:
|
||||
// https://github.com/openai/openai-node?tab=readme-ov-file#microsoft-azure-openai
|
||||
const urlHost = new URL(this.options.openAiBaseUrl ?? "").host
|
||||
|
||||
let urlHost: string
|
||||
|
||||
try {
|
||||
urlHost = new URL(this.options.openAiBaseUrl ?? "").host
|
||||
} catch (error) {
|
||||
// Likely an invalid `openAiBaseUrl`; we're still working on
|
||||
// proper settings validation.
|
||||
urlHost = ""
|
||||
}
|
||||
|
||||
if (urlHost === "azure.com" || urlHost.endsWith(".azure.com") || options.openAiUseAzure) {
|
||||
// Azure API shape slightly differs from the core API shape:
|
||||
// https://github.com/openai/openai-node?tab=readme-ov-file#microsoft-azure-openai
|
||||
this.client = new AzureOpenAI({
|
||||
baseURL: this.options.openAiBaseUrl,
|
||||
apiKey: this.options.openAiApiKey,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue