Entropic 2.3.8
Local-first agentic inference engine
Loading...
Searching...
No Matches
stream_think_filter.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
14#pragma once
15
16#include <cstddef>
17#include <string>
18
19namespace entropic {
20
25using TokenCallback = void (*)(const char*, size_t, void*);
26
37public:
44 StreamThinkFilter(TokenCallback cb, void* ud);
45
52 void set_raw_callback(TokenCallback cb, void* ud);
53
60 void on_token(const char* chunk, size_t len);
61
70 void flush();
71
72private:
73 TokenCallback cb_;
74 void* ud_;
75 TokenCallback raw_cb_ = nullptr;
76 void* raw_ud_ = nullptr;
77 bool in_think_ = false;
78 std::string tag_buf_;
79 std::string utf8_buf_;
80
87 void emit_utf8_safe(const char* data, size_t len);
88
94 void process_byte(char c);
95};
96
97} // namespace entropic
Streaming filter that removes <think> blocks from output.
void set_raw_callback(TokenCallback cb, void *ud)
Set optional raw callback (receives ALL tokens unfiltered).
void on_token(const char *chunk, size_t len)
Process a chunk of tokens.
void flush()
Flush any buffered partial tag content.
Activate model on GPU (WARM → ACTIVE).
void(*)(const char *, size_t, void *) TokenCallback
Token callback type matching the C API signature.