Entropic 2.3.8
Local-first agentic inference engine
Loading...
Searching...
No Matches
i_inference_callbacks.h File Reference

Function pointer types for core-to-inference communication. More...

#include <stddef.h>
Include dependency graph for i_inference_callbacks.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef int(* entropic_generate_fn) (const char *messages_json, const char *params_json, char **result_json, void *user_data)
 Generate a response (batch mode).
 
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)
 Generate a response with streaming.
 
typedef int(* entropic_route_fn) (const char *messages_json, char **result_json, void *user_data)
 Route messages to determine tier.
 
typedef int(* entropic_complete_fn) (const char *prompt, const char *params_json, char **result_json, void *user_data)
 Raw text completion without chat template.
 
typedef int(* entropic_parse_tool_calls_fn) (const char *raw_content, char **cleaned_content, char **tool_calls_json, void *user_data)
 Parse tool calls from raw model output.
 
typedef int(* entropic_is_response_complete_fn) (const char *content, const char *tool_calls_json, void *user_data)
 Check if a response is complete (no pending work).
 
typedef void(* entropic_inference_free_fn) (void *ptr)
 Free a string allocated by the inference layer.
 
typedef int(* entropic_get_tool_prompt_fn) (const char *tier, char **result, void *user_data)
 Get formatted tool prompt for a tier.
 

Detailed Description

Function pointer types for core-to-inference communication.

Core does not #include any inference headers. These function pointer types define the contract. The facade (librentropic.so) wires them to the actual InferenceBackend at engine creation time.

Memory ownership
  • result_json outputs are allocated by the callee. Caller must free with the callee's free function (e.g., entropic_inference_free).
  • Input strings (messages_json, params_json, prompt) are borrowed for the duration of the call only.
Version
1.8.4

Definition in file i_inference_callbacks.h.

Typedef Documentation

◆ entropic_complete_fn

typedef int(* entropic_complete_fn) (const char *prompt, const char *params_json, char **result_json, void *user_data)

Raw text completion without chat template.

Parameters
promptRaw prompt string (no chat formatting).
params_jsonGeneration parameters JSON.
[out]result_jsonOutput: JSON result string. Caller must free.
user_dataOpaque pointer to backend instance.
Returns
0 on success, error code on failure. @callback
Version
1.8.4

Definition at line 87 of file i_inference_callbacks.h.

◆ entropic_generate_fn

typedef int(* entropic_generate_fn) (const char *messages_json, const char *params_json, char **result_json, void *user_data)

Generate a response (batch mode).

Parameters
messages_jsonJSON array of messages.
params_jsonGeneration parameters JSON.
[out]result_jsonOutput: JSON result string. Caller must free.
user_dataOpaque pointer to backend instance.
Returns
0 on success, error code on failure. @callback
Version
1.8.4

Definition at line 37 of file i_inference_callbacks.h.

◆ entropic_generate_streaming_fn

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)

Generate a response with streaming.

Parameters
messages_jsonJSON array of messages.
params_jsonGeneration parameters JSON.
on_tokenCallback invoked per token.
token_user_dataOpaque pointer for on_token callback.
cancelPointer to atomic cancel flag (1 = cancel).
user_dataOpaque pointer to backend instance.
Returns
0 on success, error code on failure. @callback
Version
1.8.4

Definition at line 55 of file i_inference_callbacks.h.

◆ entropic_get_tool_prompt_fn

typedef int(* entropic_get_tool_prompt_fn) (const char *tier, char **result, void *user_data)

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
tierTier name (e.g., "lead", "researcher").
[out]resultOutput: formatted tool prompt string. Caller frees.
user_dataOpaque pointer (facade context).
Returns
0 on success, non-zero if tier has no tools. @callback
Version
2.0.4

Definition at line 145 of file i_inference_callbacks.h.

◆ entropic_inference_free_fn

typedef void(* entropic_inference_free_fn) (void *ptr)

Free a string allocated by the inference layer.

Parameters
ptrPointer to free. NULL is a safe no-op. @callback
Version
1.8.4

Definition at line 129 of file i_inference_callbacks.h.

◆ entropic_is_response_complete_fn

typedef int(* entropic_is_response_complete_fn) (const char *content, const char *tool_calls_json, void *user_data)

Check if a response is complete (no pending work).

Parameters
contentResponse content string.
tool_calls_jsonJSON array of tool calls (may be "[]").
user_dataOpaque pointer to adapter.
Returns
1 if complete, 0 if not. @callback
Version
1.8.4

Definition at line 118 of file i_inference_callbacks.h.

◆ entropic_parse_tool_calls_fn

typedef int(* entropic_parse_tool_calls_fn) (const char *raw_content, char **cleaned_content, char **tool_calls_json, void *user_data)

Parse tool calls from raw model output.

Parameters
raw_contentRaw model output string.
[out]cleaned_contentOutput: cleaned content. Caller must free.
[out]tool_calls_jsonOutput: JSON array of tool calls. Caller must free.
user_dataOpaque pointer to adapter.
Returns
0 on success. @callback
Version
1.8.4

Definition at line 103 of file i_inference_callbacks.h.

◆ entropic_route_fn

typedef int(* entropic_route_fn) (const char *messages_json, char **result_json, void *user_data)

Route messages to determine tier.

Parameters
messages_jsonJSON array of messages.
[out]result_jsonOutput: JSON routing result. Caller must free.
user_dataOpaque pointer to orchestrator.
Returns
0 on success. @callback
Version
1.8.4

Definition at line 72 of file i_inference_callbacks.h.