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>
52 lines
1.7 KiB
C++
52 lines
1.7 KiB
C++
#pragma once
|
|
|
|
// Shared rig for the Cohere tests: a Platform over a MockTransport with a fake
|
|
// key. The mock only records the requests the real client builds; replies are
|
|
// the spec's documented examples (fixtures.h, verbatim) or minimal documents
|
|
// shaped from the OpenAPI schemas and labelled SHAPE where they appear. Nothing
|
|
// here verifies vendor behavior (see src/vendors/cohere/SPEC.md ## Unverified).
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
#include "clients/transports/mock_transport.h"
|
|
#include "fixtures.h"
|
|
#include "framework.h"
|
|
#include "vendors/cohere/platform.h"
|
|
|
|
namespace cohere_test {
|
|
|
|
using molo::clients::ClientResponse;
|
|
using molo::clients::HeaderMap;
|
|
using molo::clients::Method;
|
|
using molo::clients::transports::MockExpectation;
|
|
using molo::clients::transports::MockTransport;
|
|
using Json = molo::clients::body::Json;
|
|
|
|
inline ClientResponse reply(const std::string& body, int status = 200,
|
|
const std::string& type = "application/json") {
|
|
HeaderMap h;
|
|
h.set("Content-Type", type);
|
|
return ClientResponse(status, h, body);
|
|
}
|
|
|
|
inline ClientResponse sse(const std::string& body) { return reply(body, 200, "text/event-stream"); }
|
|
|
|
inline bool has(const std::string& hay, const std::string& needle) { return hay.find(needle) != std::string::npos; }
|
|
|
|
inline const char* kKey = "co-TESTKEY-DO-NOT-LEAK";
|
|
|
|
struct Rig {
|
|
MockTransport* mock = nullptr;
|
|
molo::cohere::Platform platform;
|
|
|
|
explicit Rig(const std::string& key = kKey) {
|
|
auto t = std::make_unique<MockTransport>();
|
|
mock = t.get();
|
|
platform = molo::cohere::Platform::with(std::move(t), key);
|
|
}
|
|
std::shared_ptr<molo::llm::ApiClient> client() const { return platform.client; }
|
|
};
|
|
|
|
} // namespace cohere_test
|