cortad 0.1.8 → 0.1.9

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.
Files changed (2) hide show
  1. package/lib/listing.mjs +12 -0
  2. package/package.json +2 -1
@@ -0,0 +1,12 @@
1
+ // Where a provider key is asked for its model listing: the base URL their app is pointed at, when
2
+ // their env sets one beside the key (OPENAI_BASE_URL beside OPENAI_API_KEY), else the provider's own
3
+ // host. A Fireworks key under OPENAI_API_KEY is refused by api.openai.com and works where it is sent.
4
+ export function listingUrl(name, canonical, values) {
5
+ const prefix = name.replace(/_API_KEY$/, "");
6
+ const base = values[`${prefix}_BASE_URL`] || values[`${prefix}_API_BASE`];
7
+ if (!base) return canonical;
8
+ try {
9
+ const u = new URL(base);
10
+ return /^https?:$/.test(u.protocol) ? `${base.replace(/\/+$/, "")}/models` : canonical;
11
+ } catch { return canonical; }
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortad",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Connects the AI app on your machine to Cortad for test conversations. No dependencies.",
5
5
  "bin": {
6
6
  "cortad": "local.mjs"
@@ -10,6 +10,7 @@
10
10
  "README.md",
11
11
  "lib/door.mjs",
12
12
  "lib/identities.mjs",
13
+ "lib/listing.mjs",
13
14
  "lib/lock.mjs",
14
15
  "lib/mint.mjs",
15
16
  "lib/pyhook/sitecustomize.py",