include/entropic/interfaces/i_inference_callbacks.h¶
include/entropic/interfaces/i_inference_callbacks.h
Types
typedef int(* entropic_generate_fn) (const char *messages_json, const char *params_json, char **result_json, void *user_data) hook point
Generate a response (batch mode).
- Parameters
messages_json— JSON array of messages.params_json— Generation parameters JSON.result_jsonout — Output: JSON result string. Caller must free.user_data— Opaque pointer to backend instance.
- Returns
- 0 on success, error code on failure.
typedef int(* entropic_generate_with_cancel_fn) (const char *messages_json, const char *params_json, char **result_json, int *cancel, void *user_data) hook point
Generate a response with cancellation support.
(gh#81, v2.4.2) Batch-shaped (single result, no per-token callback) but accepts a cancel_flag like the streaming variant — closes the gh#81 60s-lag gap where the non-streaming engine path had no way to honor an interrupt mid-decode.
- Parameters
messages_json— JSON array of messages.params_json— Generation parameters JSON.result_jsonout — Output: JSON result string. Caller must free.cancel— Optional pointer; setting *cancel to non-zero stops the decode within ~10ms + one token.user_data— Opaque pointer to backend instance.
- Returns
- 0 on success, ENTROPIC_ERROR_CANCELLED on cancellation, error code otherwise.
typedef int(* entropic_generate_streaming_fn) (const char *messages_json, const char *params_json, void(*on_token)(const char *token, size_t len, void *user_data), void *token_user_data, int *cancel, void *user_data) hook point
Generate a response with streaming.
- Parameters
messages_json— JSON array of messages.params_json— Generation parameters JSON.on_token— Callback invoked per token.token_user_data— Opaque pointer for on_token callback.cancel— Pointer to atomic cancel flag (1 = cancel).user_data— Opaque pointer to backend instance.
- Returns
- 0 on success, error code on failure.
typedef int(* entropic_route_fn) (const char *messages_json, char **result_json, void *user_data) hook point
Route messages to determine tier.
- Parameters
messages_json— JSON array of messages.result_jsonout — Output: JSON routing result. Caller must free.user_data— Opaque pointer to orchestrator.
- Returns
- 0 on success.
typedef int(* entropic_complete_fn) (const char *prompt, const char *params_json, char **result_json, void *user_data) hook point
Raw text completion without chat template.
- Parameters
prompt— Raw prompt string (no chat formatting).params_json— Generation parameters JSON.result_jsonout — Output: JSON result string. Caller must free.user_data— Opaque pointer to backend instance.
- Returns
- 0 on success, error code on failure.
typedef int(* entropic_parse_tool_calls_fn) (const char *raw_content, char **cleaned_content, char **tool_calls_json, void *user_data) hook point
Parse tool calls from raw model output.
- Parameters
raw_content— Raw model output string.cleaned_contentout — Output: cleaned content. Caller must free.tool_calls_jsonout — Output: JSON array of tool calls. Caller must free.user_data— Opaque pointer to adapter.
- Returns
- 0 on success.
typedef int(* entropic_is_response_complete_fn) (const char *content, const char *tool_calls_json, void *user_data) hook point
Check if a response is complete (no pending work).
- Parameters
content— Response content string.tool_calls_json— JSON array of tool calls (may be "[]").user_data— Opaque pointer to adapter.
- Returns
- 1 if complete, 0 if not.
typedef void(* entropic_inference_free_fn) (void *ptr) hook point
Free a string allocated by the inference layer.
- Parameters
ptr— Pointer to free. NULL is a safe no-op.
typedef int(* entropic_get_tool_prompt_fn) (const char *tier, char **result, void *user_data) hook point
Get formatted tool prompt for a tier.
Returns the adapter-formatted tool definitions filtered by the tier's allowed_tools. The caller must free the result with the interface's free_fn.
- Parameters
tier— Tier name (e.g., "lead", "researcher").resultout — Output: formatted tool prompt string. Caller frees.user_data— Opaque pointer (facade context).
- Returns
- 0 on success, non-zero if tier has no tools.