Base backend
actantial.backends.base.LLMBackend
Bases: ABC
Abstract base class for all LLM backends in the actantial pipeline.
Concrete backends (Anthropic, OpenAI, HuggingFace) inherit from this class
and implement generate. Shared template utilities are defined here
so they are available to all backends.
__init__(model_name, **kwargs)
Set the model name and store any extra backend-specific config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
Model identifier used by the underlying LLM service or framework (e.g. an API model name or a HuggingFace path). |
required |
**kwargs
|
Any
|
Backend-specific configuration stored in |
{}
|
generate(prompt, **kwargs)
abstractmethod
Generate text from a prompt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
The input prompt string. |
required |
**kwargs
|
Any
|
Generation parameters (e.g. |
{}
|
Returns:
| Type | Description |
|---|---|
str
|
The generated text string, excluding the input prompt. |
list_templates(templates_dir=Path(__file__).parent.parent / 'templates')
List the prompt templates available for this backend's model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
templates_dir
|
Union[str, Path]
|
Root directory containing per-model template
subdirectories and the shared |
parent / 'templates'
|
Returns:
| Type | Description |
|---|---|
dict[str, list[str]]
|
A dict with keys |
show_template(template, templates_dir=Path(__file__).parent.parent / 'templates')
Print the raw source of a prompt template.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template
|
str
|
Name of the template to display, with or without
the |
required |
templates_dir
|
Union[str, Path]
|
Root directory containing per-model template
subdirectories and the shared |
parent / 'templates'
|
cleanup()
Clean up resources (unload model, close connections, etc.). No-op by default.