Foresight.LLM behaviour (Foresight v0.1.0)

Copy Markdown View Source

Seam behaviour for LLM completion.

Implementations supply structured completion (complete_structured/4, complete_json_schema/4) and, optionally, native tool-calling (complete_with_tools/2 — omit it and the agentic reflect loop falls back to the fixed structured pipeline). supports_tool_calling?/1 detects which kind of backend a module is.

Summary

Callbacks

Tool-calling send used by the agentic reflect loop (C6): given a message list and tools: in opts, return the raw provider response carrying tool_calls. Optional — providers/fakes that cannot do native tool-calling omit it, and the reflect path falls back to the fixed structured pipeline.

Functions

Whether llm implements native tool-calling (drives the agentic-vs-fixed reflect dispatch).

Callbacks

complete_json_schema(term, list, map, keyword)

@callback complete_json_schema(term(), [term()], map(), keyword()) ::
  {:ok, map()} | {:error, term()}

complete_structured(term, list, module, keyword)

@callback complete_structured(term(), [term()], module(), keyword()) ::
  {:ok, term()} | {:error, term()}

complete_with_tools(list, keyword)

(optional)
@callback complete_with_tools(
  [term()],
  keyword()
) :: {:ok, term()} | {:error, term()}

Tool-calling send used by the agentic reflect loop (C6): given a message list and tools: in opts, return the raw provider response carrying tool_calls. Optional — providers/fakes that cannot do native tool-calling omit it, and the reflect path falls back to the fixed structured pipeline.

Functions

supports_tool_calling?(llm)

@spec supports_tool_calling?(module()) :: boolean()

Whether llm implements native tool-calling (drives the agentic-vs-fixed reflect dispatch).