|
45 | 45 | nil)) |
46 | 46 |
|
47 | 47 | (defn ^:private models-endpoint-headers |
48 | | - [provider auth-type api-type api-key] |
| 48 | + [provider auth-type api-type api-key extra-headers] |
49 | 49 | (let [oauth? (= :auth/oauth auth-type) |
50 | 50 | anthropic? (= "anthropic" api-type)] |
51 | 51 | (client/merge-llm-headers |
52 | | - (assoc-some |
53 | | - (cond-> {"Content-Type" "application/json"} |
54 | | - (= "github-copilot" provider) (merge (llm-util/copilot-ide-headers))) |
55 | | - "anthropic-version" (when anthropic? "2023-06-01") |
56 | | - "x-api-key" (when (and api-key anthropic? (not oauth?)) api-key) |
57 | | - "Authorization" (when (and api-key (or oauth? (not anthropic?))) (str "Bearer " api-key)) |
58 | | - "anthropic-beta" (when (and anthropic? oauth?) "oauth-2025-04-20"))))) |
| 52 | + (merge |
| 53 | + (assoc-some |
| 54 | + (cond-> {"Content-Type" "application/json"} |
| 55 | + (= "github-copilot" provider) (merge (llm-util/copilot-ide-headers))) |
| 56 | + "anthropic-version" (when anthropic? "2023-06-01") |
| 57 | + "x-api-key" (when (and api-key anthropic? (not oauth?)) api-key) |
| 58 | + "Authorization" (when (and api-key (or oauth? (not anthropic?))) (str "Bearer " api-key)) |
| 59 | + "anthropic-beta" (when (and anthropic? oauth?) "oauth-2025-04-20")) |
| 60 | + extra-headers)))) |
59 | 61 |
|
60 | 62 | (defn ^:private fetch-models-dev-data [] |
61 | 63 | (let [{:keys [status body]} (http/get models-dev-api-url |
|
280 | 282 | (defn ^:private fetch-provider-native-models |
281 | 283 | "Fetches models from provider's native /models endpoint. |
282 | 284 | Returns a map of model-id -> {} on success, nil on failure." |
283 | | - [{:keys [api-url auth-type api-key api-type provider]}] |
| 285 | + [{:keys [api-url auth-type api-key api-type provider extra-headers]}] |
284 | 286 | (when-let [models-path (provider-models-endpoint-path api-type)] |
285 | 287 | (let [url (shared/join-api-url api-url models-path) |
286 | 288 | rid (llm-util/gen-rid) |
287 | | - headers (models-endpoint-headers provider auth-type api-type api-key)] |
| 289 | + headers (models-endpoint-headers provider auth-type api-type api-key extra-headers)] |
288 | 290 | (try |
289 | 291 | (logger/debug logger-tag (format "[%s] Provider '%s': Fetching models from %s" rid provider url)) |
290 | 292 | (let [{:keys [status body]} (http/get url |
|
339 | 341 | :api-url api-url |
340 | 342 | :auth-type auth-type |
341 | 343 | :api-key api-key |
342 | | - :api-type api-type})))] |
| 344 | + :api-type api-type |
| 345 | + :extra-headers (:extraHeaders provider-config)})))] |
343 | 346 | (logger/debug logger-tag |
344 | 347 | (format "Provider '%s': Discovered %d models" |
345 | 348 | provider (count models))) |
|
0 commit comments