Textual Types

Hypster provides string parameter configuration through text and multi_text methods. These methods handle string values without additional validation.

Function Signatures

def text(
    default: str,
    *,
    name: str
) -> str

def multi_text(
    default: List[str] = [],
    *,
    name: str
) -> List[str]

Usage Examples

Single Text Values

from hypster import HP, instantiate

def llm_config(hp: HP):
    # Single text parameters with defaults
    model_name = hp.text("gpt-4", name="model_name")
    prompt_prefix = hp.text("You are a helpful assistant.", name="prompt_prefix")

    return {
        "model_name": model_name,
        "prompt_prefix": prompt_prefix,
    }

# Usage with overrides
cfg = instantiate(llm_config, values={
    "model_name": "claude-3",
    "prompt_prefix": "You are an expert programmer."
})
# cfg -> {"model_name": "claude-3", "prompt_prefix": "You are an expert programmer."}

Multiple Text Values

Required Name Parameter

Last updated

Was this helpful?