The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Correct the Mistral whitelisted-id docstring and test the alias match (#84269)
Paolo Rascunà2b2edb5a2478
diff --git a/src/metabase/metabot/self/mistral.clj b/src/metabase/metabot/self/mistral.cljindex 264a8f71f90..912a0d11578 100644--- a/src/metabase/metabot/self/mistral.clj+++ b/src/metabase/metabot/self/mistral.clj@@ -54,11 +54,11 @@(defn- whitelisted-id"The [[supported-models]] id that a `/models` catalog entry resolves to, or nil when unsupported.- Each catalog entry has one `:id` and a list of `:aliases`- (https://docs.mistral.ai/openapi.yaml, `BaseModelCard`). One model can have several names: Mistral Medium 3.5- has `mistral-medium-3-5`, `mistral-medium-3` and `mistral-medium-latest`- (https://docs.mistral.ai/models/mistral-medium-3-5-26-04). The whitelisted id can be the `:id` or an alias, so- this checks both."+ Each catalog entry has one `:id` and a list of `:aliases` (https://docs.mistral.ai/openapi.yaml, `BaseModelCard`).+ One model can have several names, and the catalog can list one entry for each name. Each of these entries gives+ the other names of the model in `:aliases` (`GET /v1/models`, probed 2026-10-13). Thus the whitelisted id can be+ the `:id` or an alias, and this function checks both. Several entries can resolve to the same id, and [[list-models]]+ removes the duplicates."[{:keys [id aliases]}](some #(when (contains? supported-models %) %)(cons id aliases)))diff --git a/test/metabase/metabot/self/mistral_test.clj b/test/metabase/metabot/self/mistral_test.cljindex d260b7f64ec..13f50ff4656 100644--- a/test/metabase/metabot/self/mistral_test.clj+++ b/test/metabase/metabot/self/mistral_test.clj@@ -476,7 +476,15 @@(mistral/list-models {:credentials byok-credentials}))))))(deftest list-models-matches-aliases-and-dedupes-test- (testing "a catalog entry whose alias is whitelisted resolves to the whitelisted id, deduped across entries"+ (testing "a catalog entry whose alias is whitelisted resolves to the whitelisted id"+ ;; No entry has the whitelisted id as its :id, so only the alias match can find it.+ (mt/with-dynamic-fn-redefs [http/request (fn [_]+ {:status 200+ :body {:data [{:id "mistral-medium-latest"+ :aliases ["mistral-medium-3-5"]}]}})]+ (is (= {:models [{:id "mistral-medium-3-5" :display_name "Mistral Medium 3.5"}]}+ (mistral/list-models {:credentials byok-credentials})))))+ (testing "entries that resolve to the same whitelisted id give one listing item"(mt/with-dynamic-fn-redefs [http/request (fn [_]{:status 200:body {:data [{:id "mistral-medium-latest"