feat(clients): cohere: whole API, CohereChatModel, spec checker, demo and tests
Package src/vendors/cohere (molo::cohere): Chat v2 with streaming, tools, thinking and citations; embed, rerank, classify, tokenize, detokenize, parse, transcription; datasets, embed jobs, batches, connectors, fine-tuning, models, check-api-key; legacy v1 chat/generate/summarize; CohereChatModel : ChatModel. All 42 operations of cohere-openapi.yaml are in one call table, verified by tools/check_spec.py. Demo routes under /ai/cohere, 51 unit tests and 2 route tests; live tests are opt-in. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
// Routes: GET /ai/cohere (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("COHERE_API_KEY");
|
||||
unsetenv("CO_API_KEY");
|
||||
Fixture f;
|
||||
auto page = f.client->get("/ai/cohere");
|
||||
check(page.status == 200, "page 200");
|
||||
check(contains(page.headers.get("Content-Type"), "text/html"), "html");
|
||||
check(contains(page.body, "Cohere API") && contains(page.body, "viewport"), "title and mobile viewport");
|
||||
check(contains(page.body, "/embedded/ai_cohere.js"), "script wired");
|
||||
check(f.client->post("/ai/cohere", "{}", "application/json").status == 405, "post page is 405");
|
||||
|
||||
auto st = f.client->get("/ai/cohere/status");
|
||||
check(st.status == 200 && contains(st.body, "\"configured\":false"), "status without a key");
|
||||
check(contains(st.body, "COHERE_API_KEY") && contains(st.body, "command-a-03-2025") &&
|
||||
contains(st.body, "embed-v4.0") && contains(st.body, "rerank-v3.5"),
|
||||
"status names credential env and models");
|
||||
check(f.client->post("/ai/cohere/status", "{}", "application/json").status == 405, "post status is 405");
|
||||
|
||||
auto calls = f.client->get("/ai/cohere/calls");
|
||||
check(calls.status == 200 && contains(calls.body, "/v2/chat") && contains(calls.body, "/v2/embed") &&
|
||||
contains(calls.body, "/v1/check-api-key") && contains(calls.body, "/v2/batches/{id}:cancel"),
|
||||
"call table listed");
|
||||
check(f.client->post("/ai/cohere/calls", "{}", "application/json").status == 405, "post calls is 405");
|
||||
return finish("ai/cohere/page");
|
||||
}
|
||||
Reference in New Issue
Block a user