Recollect.ExtractionProvider behaviour (recollect v0.5.1)

Copy Markdown View Source

Behaviour for LLM-powered entity/relation extraction.

The host app provides an llm_fn that makes the actual LLM call. Recollect handles prompting, parsing, and validation.

Summary

Callbacks

Extract entities and relations from text.

Types

entity_map()

@type entity_map() :: %{
  name: String.t(),
  entity_type: String.t(),
  description: String.t()
}

extraction_result()

@type extraction_result() :: %{entities: [entity_map()], relations: [relation_map()]}

relation_map()

@type relation_map() :: %{
  from: String.t(),
  to: String.t(),
  relation_type: String.t(),
  weight: float()
}

Callbacks

extract(text, opts)

@callback extract(text :: String.t(), opts :: keyword()) ::
  {:ok, extraction_result()} | {:error, term()}

Extract entities and relations from text.

Returns {:ok, %{entities: [...], relations: [...]}} or {:error, reason}.