38 lines
1.8 KiB
C++
38 lines
1.8 KiB
C++
// Routes: GET /ai/mistral (page), /status, /calls (no credential needed)
|
|||
|
|
#include <cstdlib>
|
||
|
|
|
||
|
|
#include "support/Assert.hpp"
|
||
|
|
|
||
|
|
using namespace molo::example::test;
|
||
|
|
|
||
|
|
int main() {
|
||
|
|
setenv("MOLO_ENV_FILES", "off", 1);
|
||
|
|
unsetenv("MISTRAL_API_KEY");
|
||
|
|
Fixture f;
|
||
|
|
auto page = f.client->get("/ai/mistral");
|
||
|
|
check(page.status == 200, "page 200");
|
||
|
|
check(contains(page.headers.get("Content-Type"), "text/html"), "html");
|
||
|
|
check(contains(page.body, "Mistral La Plateforme") && contains(page.body, "viewport"), "title and mobile viewport");
|
||
|
|
check(contains(page.body, "/embedded/ai_mistral.js"), "script wired");
|
||
|
|
check(f.client->post("/ai/mistral", "{}", "application/json").status == 405, "post page is 405");
|
||
|
|
|
||
|
|
auto st = f.client->get("/ai/mistral/status");
|
||
|
|
check(st.status == 200 && contains(st.body, "\"configured\":false"), "status without a key");
|
||
|
|
check(contains(st.body, "MISTRAL_API_KEY") && contains(st.body, "mistral-small-latest") &&
|
||
|
|
contains(st.body, "codestral-latest") && contains(st.body, "mistral-embed"),
|
||
|
|
"status names credential env and default models");
|
||
|
|
check(contains(st.body, "\"calls\":347"), "status counts the call table");
|
||
|
|
check(f.client->post("/ai/mistral/status", "{}", "application/json").status == 405, "post status is 405");
|
||
|
|
|
||
|
|
auto calls = f.client->get("/ai/mistral/calls");
|
||
|
|
check(calls.status == 200 && contains(calls.body, "/v1/chat/completions") &&
|
||
|
|
contains(calls.body, "/v1/fim/completions") && contains(calls.body, "/v1/ocr") &&
|
||
|
|
contains(calls.body, "/v1/batch/jobs"),
|
||
|
|
"call table listed");
|
||
|
|
auto chat_only = f.client->get("/ai/mistral/calls?area=chat");
|
||
|
|
check(chat_only.status == 200 && contains(chat_only.body, "/v1/chat/completions") &&
|
||
|
|
!contains(chat_only.body, "/v1/ocr"),
|
||
|
|
"call table filters by area");
|
||
|
|
return finish("ai/mistral/page");
|
||
|
|
}
|