Skip to main content

Generator Agents API

Generators are pure transformers: each exposes generate_character(data=None) and returns a character object. Generators do no file I/O — they do not read seed lists and do not save output. The generate CLI owns all I/O (loading seeds, driving the loop, and saving results).

Available Generators

GeneratorKeyDescription
AnnaAgentannaAgentMulti-session profiles with scales and memory states
CARScarsCBT resistance profiles from a CCD + seed statements
ClientCastclientCastProfiles from conversation excerpts via Big Five + clinical scales
DeprofiledeprofileClinical/social profile assembly with matched timelines and memory cards
PatientZeropatientZeroDisease-grounded synthetic patient records with sampled priors
PsychepsycheMFC psychiatric profiles for assessment training

Listing Available Generators

from patienthub.generators import GENERATORS, GENERATOR_CONFIG_REGISTRY

# List all generator types
print("Available generators:", list(GENERATORS.keys()))

# Get config class for a generator
config_class = GENERATOR_CONFIG_REGISTRY['psyche']
print(config_class)

Loading a Generator

from patienthub.generators import get_generator

generator = get_generator(agent_name='psyche', lang='en')

Loading a Generator with Custom Configuration

from omegaconf import OmegaConf
from patienthub.generators import get_generator

config = OmegaConf.create({
'agent_name': 'psyche',
'model_type': 'OPENAI',
'model_name': 'gpt-4o',
'temperature': 0.7,
'max_tokens': 8192,
'max_retries': 3,
'prompt_path': 'data/prompts/generator/psyche.yaml',
})

generator = get_generator(agent_name='psyche', configs=config, lang='en')

Generating a Character

Every generator exposes a single generate_character(data=None) method that runs the full pipeline and returns a character object. It performs no file I/O:

character = generator.generate_character(seed_record)

In normal use you do not call this directly — the generate CLI drives the loop and saves the returned characters, while each generator validates its own seed record first (see below).

Running Generation via the CLI

The generate CLI owns all I/O: it loads seed records, drives the loop, and saves the results. Each record is first validated against the generator's own seed schema via BaseGenerator.prepare_seed, then passed to generate_character().

# Item-driven: one character per record in an input JSON list
patienthub generate generator=clientCast input_path=data/seeds/clientCast.json

# Config-parameterized (no input list): one character built from config
patienthub generate generator=patientZero generator.disease_key=depression

# Several samples appended to the output bank
patienthub generate generator=patientZero num_samples=10

# Custom output location + parallel workers, with resume
patienthub generate generator=clientCast input_path=data/seeds/clientCast.json \
output_path=data/characters/clientCast.json num_workers=4 resume=true

CLI I/O Options

OptionTypeDefaultDescription
generatorstrrequiredGenerator to run (e.g. clientCast, psyche)
input_pathstr""Optional JSON list of seed records. When set, one character is produced per record, index-aligned
output_pathstrdata/characters/<agent_name>.jsonWhere the generated characters are saved
num_samplesint1Number of characters to generate when input_path is empty (appended to the output bank)
num_workersint1Parallel workers (each builds its own generator instance)
resumeboolfalseWith input_path: keep characters already in the output and only refill null (failed/pending) slots
langstr"en"Language code
verboseboolfalseEnable debug logging

With input_path: one character per seed record, index-aligned and resume-aware — failed or pending slots are saved as null and refilled on a later resume run. Each seed record is validated against the generator's seed schema before generation; a malformed record fails only that item.

Without input_path: num_samples characters are built from config and appended to the output bank. resume does not apply in this mode.

Seeds vs. Resources

PatientHub separates two kinds of generator input:

  • Seeds (data/seeds/<agent_name>.json) are the per-character generation inputs the CLI reads via input_path — a JSON list where each record produces one character. Each generator's seed record shape is defined by its seed schema (see the per-generator pages).
  • Resources (data/resources/) are shared reference knowledge a method consults during generation (event databases, symptom item definitions, disease priors, etc.). These are configured per generator (e.g. resource_dir) or shared as importable constants in patienthub.resources, and are not per-character.

Generated outputs are written to data/characters/.

Generator Configuration Options

Every generator inherits the shared model options; each also has method-specific fields documented on its own page.

OptionTypeDefaultDescription
agent_namestrrequiredGenerator identifier
model_typestr"OPENAI"Model provider key (used to read ${MODEL_TYPE}_API_KEY / ${MODEL_TYPE}_BASE_URL)
model_namestr"gpt-4o"Model identifier
temperaturefloat0.7Sampling temperature (0-1)
max_tokensint8192Max response tokens
max_retriesint3API retry attempts
prompt_pathstrvariesPath to generator prompts
langstr"en"Language code

See Also