File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -18,10 +18,20 @@ export class OpenAiHandler implements ApiHandler, SingleCompletionHandler {
1818
1919 constructor ( options : ApiHandlerOptions ) {
2020 this . options = options
21- // Azure API shape slightly differs from the core API shape:
22- // https://github.com/openai/openai-node?tab=readme-ov-file#microsoft-azure-openai
23- const urlHost = new URL ( this . options . openAiBaseUrl ?? "" ) . host
21+
22+ let urlHost : string
23+
24+ try {
25+ urlHost = new URL ( this . options . openAiBaseUrl ?? "" ) . host
26+ } catch ( error ) {
27+ // Likely an invalid `openAiBaseUrl`; we're still working on
28+ // proper settings validation.
29+ urlHost = ""
30+ }
31+
2432 if ( urlHost === "azure.com" || urlHost . endsWith ( ".azure.com" ) || options . openAiUseAzure ) {
33+ // Azure API shape slightly differs from the core API shape:
34+ // https://github.com/openai/openai-node?tab=readme-ov-file#microsoft-azure-openai
2535 this . client = new AzureOpenAI ( {
2636 baseURL : this . options . openAiBaseUrl ,
2737 apiKey : this . options . openAiApiKey ,
You can’t perform that action at this time.
0 commit comments