Archived
radiance 1.0.4
- oh-my-pi works unmodified on every Qwen model. Its requests carry a top-level
preserve_thinking, which was refused as an unknown field; it now reaches the chat template the
way enable_thinking does. Its task tool's `model` parameter is the `not` of every JSON type,
which the 1.0.1 fix did not cover: any `not` that excludes every value is now an argument no
call writes, under every chat template and Flash-Next's declared format.
- Command-line defaults and bounds for what a request leaves out. A flag left unset changes
nothing; /server_info reports the values under request_defaults.
- Sampling: --typical-p, --presence-penalty, --frequency-penalty, --repetition-penalty,
--repeat-last-n, --dry-multiplier, --dry-base, --dry-allowed-length, --dry-penalty-last-n,
--dry-sequence-breakers, --xtc-probability, --xtc-threshold.
- Requests: --default-max-tokens N|auto, --max-tokens-cap, --max-n, --max-queued-requests,
--max-stop-strings, --max-stop-bytes.
- Chat template: --chat-template-kwargs JSON|@FILE sets template variables a request's own
chat_template_kwargs override; --reasoning-format auto|none.
- HTTP: --http-threads, --read-timeout, --write-timeout, --keep-alive-timeout, --max-body-mib,
--retry-after, --no-cors.
- Media: --image-min-pixels, --image-max-pixels, --video-min-pixels, --video-max-pixels,
--video-fps, --video-min-frames, --video-max-frames, --video-max-frame-tokens,
--max-source-pixels.
- Under --reasoning-effort none or minimal, a request that sets enable_thinking true now thinks
instead of having the deployment default override it.
- --temp, --top-p, --min-p and --top-k refuse a value that is not a number instead of reading
it as 0.
This commit is contained in:
1 parent
d008fdb32b
commit
09fb41735b
23 files changed
+2478
-104
No files matched your search
Vendored
+16
@@ -99,6 +99,7 @@ vendor/llama/common/regex-partial.{h,cpp} <- llama.cpp common/*
|
||||
patches/0011-chat-add_bos-must-come-from-the-inputs.patch
|
||||
patches/0012-json-schema-a-schema-no-value-satisfies.patch
|
||||
patches/0013-json-schema-a-count-past-int-is-no-bound.patch
|
||||
patches/0014-json-schema-a-not-of-every-type-is-never.patch
|
||||
|
||||
On 0003: a `pattern` in a `response_format` reaches _visit_pattern() as client data, and three
|
||||
of its paths do not survive that. `front()`/`back()` run on an empty string; `seq.back()` runs
|
||||
@@ -444,3 +445,18 @@ PATCH SERIES
|
||||
long. A count that is negative or not a number is refused by name. A float count is
|
||||
truncated, where maxItems used to ignore one. The other half of the same report -- any count
|
||||
past 2000 refused -- was the GBNF parser's, and is fixed in core/sample/gbnf.cpp.
|
||||
|
||||
patches/0014-json-schema-a-not-of-every-type-is-never.patch
|
||||
|
||||
0012 recognised `never` only as `{"not": {}}`. oh-my-pi 18.6.0 sends its `task` tool's
|
||||
optional `model` as the `not` of a union of all six JSON types -- `{"not": {"anyOf":
|
||||
[{"type": "string"}, {"type": "number"}, {"type": "boolean"}, {"type": "object"},
|
||||
{"type": "array"}, {"type": "null"}]}}` -- so under every template that constrains tool
|
||||
arguments the request still failed with "Unsupported schema keyword \"not\"". A `not` is now
|
||||
`never` whenever what it negates accepts every value: `{}` or `true`, a type list naming all
|
||||
six types, or a union of bare types that between them name all six (an alternative that is
|
||||
itself universal settles it). Annotations may sit beside; any other keyword narrows the
|
||||
schema, an alternative that constrains more than its type is not counted, and `integer` does
|
||||
not stand for `number`, so a `not` is only read as `never` when it is. Every other `not` is
|
||||
refused as 0004 refuses it. The comment of 0012 above is_unsatisfiable, which 0013 had left
|
||||
above _schema_count, is back beside the function it describes.
|
||||
+65
-6
@@ -900,10 +900,6 @@ public:
|
||||
visit_refs(schema);
|
||||
}
|
||||
|
||||
// RADIANCE: the schema no value satisfies. JSON Schema spells it `false`, and `{"not": {}}` --
|
||||
// which is how TypeBox's Type.Never and Arktype's "never" are exported, the latter as an
|
||||
// optional property no call may set. A `not` of the empty schema makes its whole schema
|
||||
// unsatisfiable whatever sits beside it, so the sibling keywords do not matter.
|
||||
// RADIANCE: a count -- minLength, maxLength, minItems, maxItems -- as the int build_repetition
|
||||
// takes, or `dflt` where the schema has none. get<int>() casts, so a bound past INT_MAX wrapped:
|
||||
// Number.MAX_SAFE_INTEGER, a common way to write "no limit", came out as -1 and the grammar did
|
||||
@@ -924,11 +920,74 @@ public:
|
||||
return d >= (double) std::numeric_limits<int>::max() ? std::numeric_limits<int>::max() : (int) d;
|
||||
}
|
||||
|
||||
// RADIANCE: the schema every value satisfies, whose `not` is therefore the schema none does.
|
||||
// `{}` and `true` are it, and so is a type list, or a union of bare types, that between them
|
||||
// name all six JSON types -- the way Arktype exports the complement of `never` for an optional
|
||||
// property: {"not": {"anyOf": [{"type": "string"}, {"type": "number"}, {"type": "boolean"},
|
||||
// {"type": "object"}, {"type": "array"}, {"type": "null"}]}}. Annotations may sit beside; any
|
||||
// other keyword narrows the schema, and its `not` is a real complement, refused below. A union
|
||||
// alternative that constrains more than its type is not counted, so a union is only ever read
|
||||
// as universal when it is.
|
||||
static bool is_universal(const json & s) {
|
||||
if (s.is_boolean()) return s.get<bool>();
|
||||
if (!s.is_object()) return false;
|
||||
static const std::unordered_set<std::string> annotations = {
|
||||
"description", "title", "default", "examples", "$comment", "deprecated", "readOnly",
|
||||
"writeOnly",
|
||||
};
|
||||
// Whether every key of `o` is an annotation or `allowed`.
|
||||
auto only = [&](const json & o, const char * allowed) {
|
||||
for (auto it = o.begin(); it != o.end(); ++it) {
|
||||
if (annotations.count(it.key()) == 0 && (allowed == nullptr || it.key() != allowed)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
// The types a bare `type` names, into `out`; false for anything that is not one.
|
||||
auto types_of = [](const json & t, std::unordered_set<std::string> & out) {
|
||||
if (t.is_string()) {
|
||||
out.insert(t.get<std::string>());
|
||||
return true;
|
||||
}
|
||||
if (!t.is_array()) return false;
|
||||
for (const auto & e : t) {
|
||||
if (!e.is_string()) return false;
|
||||
out.insert(e.get<std::string>());
|
||||
}
|
||||
return true;
|
||||
};
|
||||
auto covers = [](const std::unordered_set<std::string> & ts) {
|
||||
for (const char * t : { "string", "number", "boolean", "object", "array", "null" }) {
|
||||
if (ts.count(t) == 0) return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
if (only(s, nullptr)) return true;
|
||||
std::unordered_set<std::string> ts;
|
||||
if (s.contains("type") && only(s, "type")) {
|
||||
return types_of(s["type"], ts) && covers(ts);
|
||||
}
|
||||
if (s.contains("anyOf") && only(s, "anyOf") && s["anyOf"].is_array()) {
|
||||
for (const auto & a : s["anyOf"]) {
|
||||
if (is_universal(a)) return true;
|
||||
if (a.is_object() && a.contains("type") && only(a, "type")) {
|
||||
types_of(a["type"], ts);
|
||||
}
|
||||
}
|
||||
return covers(ts);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// RADIANCE: the schema no value satisfies. JSON Schema spells it `false`, and TypeBox's
|
||||
// Type.Never and Arktype's "never" export it as a `not` of the universal schema above, the
|
||||
// latter for an optional property no call may set. Such a `not` makes its whole schema
|
||||
// unsatisfiable whatever sits beside it, so the sibling keywords do not matter.
|
||||
static bool is_unsatisfiable(const json & schema) {
|
||||
if (schema.is_boolean()) return !schema.get<bool>();
|
||||
if (!schema.is_object() || !schema.contains("not")) return false;
|
||||
const json & n = schema["not"];
|
||||
return (n.is_object() && n.empty()) || (n.is_boolean() && n.get<bool>());
|
||||
return is_universal(schema["not"]);
|
||||
}
|
||||
|
||||
static std::string _generate_constant_rule(const json & value) {
|
||||
|
||||
+2
-1
@@ -26,7 +26,8 @@ class common_schema_info {
|
||||
|
||||
void resolve_refs(nlohmann::ordered_json & schema);
|
||||
bool resolves_to_string(const nlohmann::ordered_json & schema);
|
||||
// RADIANCE: whether no value satisfies the schema -- `false`, or `{"not": {}}`.
|
||||
// RADIANCE: whether no value satisfies the schema -- `false`, or a `not` of a schema every
|
||||
// value satisfies (`{}`, or types naming all six JSON types).
|
||||
bool unsatisfiable(const nlohmann::ordered_json & schema) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
diff --git a/common/json-schema-to-grammar.cpp b/common/json-schema-to-grammar.cpp
|
||||
index 0bf2b72..12e2756 100644
|
||||
--- a/common/json-schema-to-grammar.cpp
|
||||
+++ b/common/json-schema-to-grammar.cpp
|
||||
@@ -900,10 +900,6 @@ public:
|
||||
visit_refs(schema);
|
||||
}
|
||||
|
||||
- // RADIANCE: the schema no value satisfies. JSON Schema spells it `false`, and `{"not": {}}` --
|
||||
- // which is how TypeBox's Type.Never and Arktype's "never" are exported, the latter as an
|
||||
- // optional property no call may set. A `not` of the empty schema makes its whole schema
|
||||
- // unsatisfiable whatever sits beside it, so the sibling keywords do not matter.
|
||||
// RADIANCE: a count -- minLength, maxLength, minItems, maxItems -- as the int build_repetition
|
||||
// takes, or `dflt` where the schema has none. get<int>() casts, so a bound past INT_MAX wrapped:
|
||||
// Number.MAX_SAFE_INTEGER, a common way to write "no limit", came out as -1 and the grammar did
|
||||
@@ -924,11 +920,74 @@ public:
|
||||
return d >= (double) std::numeric_limits<int>::max() ? std::numeric_limits<int>::max() : (int) d;
|
||||
}
|
||||
|
||||
+ // RADIANCE: the schema every value satisfies, whose `not` is therefore the schema none does.
|
||||
+ // `{}` and `true` are it, and so is a type list, or a union of bare types, that between them
|
||||
+ // name all six JSON types -- the way Arktype exports the complement of `never` for an optional
|
||||
+ // property: {"not": {"anyOf": [{"type": "string"}, {"type": "number"}, {"type": "boolean"},
|
||||
+ // {"type": "object"}, {"type": "array"}, {"type": "null"}]}}. Annotations may sit beside; any
|
||||
+ // other keyword narrows the schema, and its `not` is a real complement, refused below. A union
|
||||
+ // alternative that constrains more than its type is not counted, so a union is only ever read
|
||||
+ // as universal when it is.
|
||||
+ static bool is_universal(const json & s) {
|
||||
+ if (s.is_boolean()) return s.get<bool>();
|
||||
+ if (!s.is_object()) return false;
|
||||
+ static const std::unordered_set<std::string> annotations = {
|
||||
+ "description", "title", "default", "examples", "$comment", "deprecated", "readOnly",
|
||||
+ "writeOnly",
|
||||
+ };
|
||||
+ // Whether every key of `o` is an annotation or `allowed`.
|
||||
+ auto only = [&](const json & o, const char * allowed) {
|
||||
+ for (auto it = o.begin(); it != o.end(); ++it) {
|
||||
+ if (annotations.count(it.key()) == 0 && (allowed == nullptr || it.key() != allowed)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ return true;
|
||||
+ };
|
||||
+ // The types a bare `type` names, into `out`; false for anything that is not one.
|
||||
+ auto types_of = [](const json & t, std::unordered_set<std::string> & out) {
|
||||
+ if (t.is_string()) {
|
||||
+ out.insert(t.get<std::string>());
|
||||
+ return true;
|
||||
+ }
|
||||
+ if (!t.is_array()) return false;
|
||||
+ for (const auto & e : t) {
|
||||
+ if (!e.is_string()) return false;
|
||||
+ out.insert(e.get<std::string>());
|
||||
+ }
|
||||
+ return true;
|
||||
+ };
|
||||
+ auto covers = [](const std::unordered_set<std::string> & ts) {
|
||||
+ for (const char * t : { "string", "number", "boolean", "object", "array", "null" }) {
|
||||
+ if (ts.count(t) == 0) return false;
|
||||
+ }
|
||||
+ return true;
|
||||
+ };
|
||||
+ if (only(s, nullptr)) return true;
|
||||
+ std::unordered_set<std::string> ts;
|
||||
+ if (s.contains("type") && only(s, "type")) {
|
||||
+ return types_of(s["type"], ts) && covers(ts);
|
||||
+ }
|
||||
+ if (s.contains("anyOf") && only(s, "anyOf") && s["anyOf"].is_array()) {
|
||||
+ for (const auto & a : s["anyOf"]) {
|
||||
+ if (is_universal(a)) return true;
|
||||
+ if (a.is_object() && a.contains("type") && only(a, "type")) {
|
||||
+ types_of(a["type"], ts);
|
||||
+ }
|
||||
+ }
|
||||
+ return covers(ts);
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ // RADIANCE: the schema no value satisfies. JSON Schema spells it `false`, and TypeBox's
|
||||
+ // Type.Never and Arktype's "never" export it as a `not` of the universal schema above, the
|
||||
+ // latter for an optional property no call may set. Such a `not` makes its whole schema
|
||||
+ // unsatisfiable whatever sits beside it, so the sibling keywords do not matter.
|
||||
static bool is_unsatisfiable(const json & schema) {
|
||||
if (schema.is_boolean()) return !schema.get<bool>();
|
||||
if (!schema.is_object() || !schema.contains("not")) return false;
|
||||
- const json & n = schema["not"];
|
||||
- return (n.is_object() && n.empty()) || (n.is_boolean() && n.get<bool>());
|
||||
+ return is_universal(schema["not"]);
|
||||
}
|
||||
|
||||
static std::string _generate_constant_rule(const json & value) {
|
||||
diff --git a/common/json-schema-to-grammar.h b/common/json-schema-to-grammar.h
|
||||
index 86c78f3..8223dd4 100644
|
||||
--- a/common/json-schema-to-grammar.h
|
||||
+++ b/common/json-schema-to-grammar.h
|
||||
@@ -26,7 +26,8 @@ class common_schema_info {
|
||||
|
||||
void resolve_refs(nlohmann::ordered_json & schema);
|
||||
bool resolves_to_string(const nlohmann::ordered_json & schema);
|
||||
- // RADIANCE: whether no value satisfies the schema -- `false`, or `{"not": {}}`.
|
||||
+ // RADIANCE: whether no value satisfies the schema -- `false`, or a `not` of a schema every
|
||||
+ // value satisfies (`{}`, or types naming all six JSON types).
|
||||
bool unsatisfiable(const nlohmann::ordered_json & schema) const;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user