bazilion 0.19.0 → 0.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/worker.js CHANGED
@@ -3629,11 +3629,26 @@ async function createProtectedPiRuntime(options) {
3629
3629
  baseUrl: options.baseUrl
3630
3630
  });
3631
3631
  }
3632
+ var OPENAI_COMPATIBLE_VERSION_SEGMENT = { fireworks: "/v1" };
3633
+ function fallbackBaseUrl(providerName, baseUrl) {
3634
+ const segment = OPENAI_COMPATIBLE_VERSION_SEGMENT[providerName];
3635
+ if (!segment || !baseUrl) return baseUrl;
3636
+ let url;
3637
+ try {
3638
+ url = new URL(baseUrl);
3639
+ } catch {
3640
+ return baseUrl;
3641
+ }
3642
+ const path = url.pathname.replace(/\/+$/, "");
3643
+ if (path.endsWith(segment)) return baseUrl;
3644
+ url.pathname = `${path}${segment}`;
3645
+ return url.toString();
3646
+ }
3632
3647
  function resolvePiModel(runtime, providerName, modelId, baseUrl) {
3633
3648
  const known = runtime.getModel(piProviderName(providerName), modelId);
3634
3649
  if (known) return baseUrl ? { ...known, baseUrl } : known;
3635
3650
  if (!baseUrl) throw new UnknownModelError(providerName, modelId);
3636
- return fallbackPiModel(providerName, modelId, baseUrl);
3651
+ return fallbackPiModel(providerName, modelId, fallbackBaseUrl(providerName, baseUrl));
3637
3652
  }
3638
3653
 
3639
3654
  // ../daemon/src/runtime/auth/openai-codex.ts