API Reference
This page documents all public functions, classes, and behaviors in VRBM‑AI.
Global Settings
HEADER_VISIBLEDEFAULT_MODELTEMPERATUREALIVE_TIME
Loaded from vrbm_config if present.
Exceptions
VRBMError
Base class for all vrbm‑AI errors.
InvalidOutputTypeError
Raised when the user requests an unsupported output type.
OllamaConnectionError
Raised when vrbm‑AI cannot reach the Ollama server.
ModelDownloadError
Raised when a model cannot be downloaded.
Functions*
*only generate() is exposed
load_config()
Reads the vrbm_config file and updates global settings.
ollama_chat(model, messages, temp)
Low‑level wrapper around Ollama’s /api/chat.
Returns the raw JSON response.
ollama_list()
Returns a list of installed Ollama models.
ollama_pull(model)
Downloads a model if not installed.
ensure_model(model_name)
Checks if a model exists; downloads it if missing.
parse_output(output)
Attempts to parse model output using:
ast.literal_evaljson.loadsraw string fallback
validate_output(value, expected_type)
Ensures the returned value matches the requested type. Returns:
Noneif valid- error message string if invalid
generate(prompt, output_type="unspecified", model=DEFAULT_MODEL, temperature=TEMPERATURE, parse=True)
Main user‑facing function.
Behavior:
- Ensures model is installed
- Sends system + user messages
- Parses output
- Validates type
- Retries up to 3 times
- Returns Python value or
None
Parameters:
prompt: user textoutput_type: Python type namemodel: Ollama modeltemperature: floatparse: whether to parse output
Returns:
- Python value
- or
Noneon failure
Constants
SYSTEM_PROMPT
Strict instructions sent to Ollama to enforce Python literal output.
VALID_TYPES
Mapping of type names → Python classes.
| < prev. | home |