Entropic 2.14.3
Local-first agentic inference engine
Loading...
Searching...
No Matches
generation_result.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
13#pragma once
14
17
18#include <string>
19#include <vector>
20
21namespace entropic {
22
43 std::string source = "none";
44
46 std::string key;
47
49 bool resolved = false;
50
54 std::string conflict_winner;
55};
56
65 std::string content;
66 std::string raw_content;
67 std::vector<ToolCall> tool_calls;
68 std::string finish_reason = "stop";
69 int token_count = 0;
70 double generation_time_ms = 0.0;
71
81
82 /* ── Orchestrator timing (populated by ModelOrchestrator) ── */
83 double routing_ms = 0.0;
84 double swap_ms = 0.0;
85 double total_ms = 0.0;
86
87 /* ── v1.9.7: Throughput + time cap metadata ── */
88
92 double throughput_tok_s = 0.0;
93
97 bool time_limited = false;
98
103
104 /* ── v1.9.13: Multi-sequence tracking ── */
105
110 int seq_id = 0;
111
112 /* ── gh#36 / gh#106: speculative-decode observability ── */
113
118 int n_drafted = 0;
119
123 int n_accepted = 0;
124
125 /* ── gh#154: grammar provenance ── */
126
132
133 /* ── Error state (for partial results on failure) ── */
135 std::string error_message;
136
143 bool ok() const { return error_code == ENTROPIC_OK; }
144};
145
165
175 rec.finish_reason = r.finish_reason;
176 rec.token_count = r.token_count;
177 rec.prefill_tokens = r.prefill_tokens;
178 rec.throughput_tok_s = r.throughput_tok_s;
179 rec.n_drafted = r.n_drafted;
180 rec.n_accepted = r.n_accepted;
181 rec.grammar = r.grammar;
182 return rec;
183}
184
185} // namespace entropic
Error types for cross-.so error reporting.
entropic_error_t
Error codes returned by all C API functions.
Definition error.h:37
@ ENTROPIC_OK
Success.
Definition error.h:38
Activate model on GPU (WARM → ACTIVE).
@ optional
optional: every escape asks the host's path approver
GenerationRecord make_generation_record(const GenerationResult &r)
Project a result down to the record kept for metrics.
One generation's metrics, without its text (gh#154).
double throughput_tok_s
Measured decode throughput.
int n_drafted
Speculative/MTP tokens proposed.
std::string finish_reason
"stop", "length", "error"
GrammarProvenance grammar
What constrained the decode.
int n_accepted
Of those, accepted by the target.
int token_count
Tokens generated.
int prefill_tokens
Prompt tokens actually decoded (gh#144)
Result of a single generation call.
bool time_limited
true if generation was terminated by time limit rather than EOS/stop sequence/max_tokens.
entropic_error_t error_code
Error code (ENTROPIC_OK if no error)
double swap_ms
Model swap time.
double routing_ms
Router classification time.
bool ok() const
True if generation completed without error.
double generation_time_ms
Wall-clock generation time.
int n_drafted
Tokens proposed by the draft/MTP head across all rounds.
int seq_id
Sequence identifier for multi-sequence backends.
double throughput_tok_s
Measured throughput for this generation (tok/s).
std::string raw_content
Raw model output before adapter processing.
std::string finish_reason
Finish reason: "stop", "length", "error".
int original_max_tokens
Original max_tokens before auto-adaptation reduced it.
std::string content
Generated text (cleaned by adapter)
int prefill_tokens
Prompt tokens actually pushed through llama_decode during this run's prefill (gh#144,...
std::vector< ToolCall > tool_calls
Tool calls parsed from content.
int n_accepted
Draft tokens the target accepted (≤ n_drafted).
std::string error_message
Error description (empty if no error)
int token_count
Generated token count.
GrammarProvenance grammar
What constrained this decode and who asked for it.
double total_ms
Total end-to-end time.
What constrained one decode, and what asked for it (gh#154).
std::string key
Registry key / frontmatter stem that was named ("" = none).
std::string source
"request" | "tier" | "tool_call" | "none".
bool resolved
true when a grammar text actually constrained this decode.
std::string conflict_winner
The winning source when two grammars collided ("" = no collision).
Tool call and tool result types.