41 lines
1.8 KiB
C++
41 lines
1.8 KiB
C++
#pragma once
|
|
|
|
// Local validation shared by every request builder. A failed check throws
|
|
// llm::ApiError::invalid("meta", ...) before any network traffic, naming the
|
|
// field. Rules come from the docs (error-handling, protocols/*, reasoning,
|
|
// tool-calling, structured-output); each cites its page in the SPEC.
|
|
|
|
#include <initializer_list>
|
|
#include <string>
|
|
|
|
namespace molo::meta {
|
|
|
|
class Check {
|
|
public:
|
|
[[noreturn]] static void fail(const std::string& message);
|
|
|
|
static void non_empty(const char* field, const std::string& value);
|
|
static void max_bytes(const char* field, const std::string& value, std::size_t cap);
|
|
static void range(const char* field, double value, double lo, double hi);
|
|
static void one_of(const char* field, const std::string& value,
|
|
std::initializer_list<const char*> allowed);
|
|
// 1..kMaxModelBytes of [A-Za-z0-9._:-].
|
|
static void model_id(const std::string& model);
|
|
// Response / file / model ids: one safe path segment.
|
|
static void segment(const char* what, const std::string& id);
|
|
// Function tool names: [A-Za-z0-9_.-]+, at most one dot (docs: tool-calling).
|
|
static void function_name(const std::string& name);
|
|
// Reasoning effort for a model: the documented values; "none" is rejected
|
|
// by Muse models; "max" only where the catalog says so.
|
|
static void reasoning_effort(const std::string& model, const std::string& effort);
|
|
// call_id / tool_call_id: 1..64 bytes.
|
|
static void call_id(const std::string& id);
|
|
static void top_p(double value); // 0 < p <= 1
|
|
static void temperature(double value); // 0..2
|
|
static void penalty(const char* field, double value); // -2..2
|
|
static void safety_identifier(const std::string& value);
|
|
static void prompt_cache_retention(const std::string& value); // in_memory | 24h
|
|
};
|
|
|
|
} // namespace molo::meta
|