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:
2026-10-25 10:49:17 +01:00
co-authored by Claude Sonnet 5.5
parent 3db67fcf1f
commit f32947427b
36 changed files with 6045 additions and 3 deletions
+43
View File
@@ -0,0 +1,43 @@
#include "vendors/cohere/catalog.h"
#include "llm/error.h"
namespace molo::cohere {
namespace {
constexpr ModelName kModels[] = {
{"command-a-plus-05-2026", ModelKind::kChat, ModelStatus::kLive, "MoE, text and images, 128k context, 64k output"},
{"command-a-03-2025", ModelKind::kChat, ModelStatus::kLive, "text, 256k context, 8k output, tool use and RAG"},
{"command-a-reasoning-08-2025", ModelKind::kChat, ModelStatus::kLive, "reasoning model"},
{"command-a-vision-07-2025", ModelKind::kChat, ModelStatus::kLive, "image input"},
{"command-a-translate-08-2025", ModelKind::kChat, ModelStatus::kLive, "translation"},
{"command-r7b-12-2024", ModelKind::kChat, ModelStatus::kLive, "small, 128k context, 4k output"},
{"command-r-plus-08-2024", ModelKind::kChat, ModelStatus::kLive, "128k context, 4k output"},
{"command-r-08-2024", ModelKind::kChat, ModelStatus::kLive, "128k context, 4k output"},
{"command-r-03-2024", ModelKind::kChat, ModelStatus::kDeprecated, "deprecated Sept 15, 2025"},
{"command-r-plus-04-2024", ModelKind::kChat, ModelStatus::kDeprecated, "deprecated Sept 15, 2025"},
{"embed-v5.0-pro", ModelKind::kEmbed, ModelStatus::kLive, "text, images, mixed; dimensions 256..2048 (default 2048)"},
{"embed-v5.0-fast", ModelKind::kEmbed, ModelStatus::kLive, "faster, lighter embed-v5.0-pro"},
{"embed-v4.0", ModelKind::kEmbed, ModelStatus::kLive, "text and images"},
{"rerank-v5.0-pro", ModelKind::kRerank, ModelStatus::kLive, "highest quality, 32k context, calibrated scores"},
{"rerank-v5.0-fast", ModelKind::kRerank, ModelStatus::kLive, "low latency"},
{"rerank-v4.0-pro", ModelKind::kRerank, ModelStatus::kLive, "listed on the models page"},
{"rerank-v4.0-fast", ModelKind::kRerank, ModelStatus::kLive, "listed on the models page"},
{"rerank-v3.5", ModelKind::kRerank, ModelStatus::kLive, "multilingual, listed on the models page"},
};
} // namespace
std::size_t ModelCatalog::count() { return sizeof(kModels) / sizeof(kModels[0]); }
const ModelName& ModelCatalog::at(std::size_t index) {
if (index >= count()) throw llm::ApiError::invalid("cohere", "model index out of range");
return kModels[index];
}
ModelStatus ModelCatalog::status_of(const std::string& id) {
for (const ModelName& m : kModels)
if (id == m.id) return m.status;
return ModelStatus::kUnknown;
}
} // namespace molo::cohere