Entropic 2.11.1
Local-first agentic inference engine
Loading...
Searching...
No Matches
grammar_source.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
22#pragma once
23
24#include <string>
25
26namespace entropic {
27
32enum class GrammarSource {
33 none,
34 request,
35 tool_call,
36
42 count,
43};
44
58inline constexpr int grammar_source_count() {
59 return static_cast<int>(GrammarSource::count);
60}
61
80inline GrammarSource resolve_grammar_source(const std::string& request_grammar,
81 const std::string& tool_grammar) {
82 if (!request_grammar.empty()) { return GrammarSource::request; }
83 if (!tool_grammar.empty()) { return GrammarSource::tool_call; }
85}
86
96inline bool grammar_sources_collide(const std::string& request_grammar,
97 const std::string& tool_grammar) {
98 return !request_grammar.empty() && !tool_grammar.empty();
99}
100
101} // namespace entropic
Activate model on GPU (WARM → ACTIVE).
GrammarSource resolve_grammar_source(const std::string &request_grammar, const std::string &tool_grammar)
Resolve which grammar wins.
bool grammar_sources_collide(const std::string &request_grammar, const std::string &tool_grammar)
Whether both sources are active — a config error worth reporting.
GrammarSource
Which source, if any, constrains the decode.
@ request
GenerationParams::grammar (COMMON_GRAMMAR_TYPE_USER)
@ none
Unconstrained.
@ tool_call
Render-derived (COMMON_GRAMMAR_TYPE_TOOL_CALLS, needs prefill)
@ count
Sentinel — MUST remain last.
constexpr int grammar_source_count()
Number of declared grammar sources, sentinel excluded.