Pathways.required()method

Specify required information for the current state to be considered complete.

USAGE

Pathways.required(info_types)

Use to define what must be obtained before the state can transition to the next step. The LLM will focus on gathering this information before proceeding. Can be used in any order within the state configuration.

Parameters

info_types : Union[str, List[str]]

Essential information that must be collected or established. Can be a single string or a list of strings. Be specific and measurable.

Returns

Pathways

Self for method chaining, allowing combination with other pathway building methods to create comprehensive conversation flows.

Integration Notes

  • State Progression: state cannot progress until required items are addressed
  • Type Inference: infers state type as "collect" if not explicitly set
  • Specificity: be specific and concrete for clear guidance
  • Complementary Use: pair with .optional() for nice-to-have information
  • Completion Criteria: use .success_condition() to define when requirements are truly met
  • Systematic Collection: ensures thorough data gathering before progression

The .required() method ensures the LLM won’t proceed until essential information is collected, preventing incomplete processes and ensuring thorough data gathering.

Examples


Complete pathway showing .required() defining essential information:

import talk_box as tb

# Creating a loan application pathway
pathway = (
    tb.Pathways(
        title="Loan Application Process",
        desc="guide customers through loan application requirements",
        activation="customer wants to apply for a loan"
    )
    # === STATE: personal_info ===
    .state("personal info: gather basic applicant information")

    # .required() ensures critical data is collected ---
    .required(["applicant's full name", "current employment status"])

    .next_state("financial_details")
    # === STATE: financial_details ===
    .state("financial details: collect financial information")

    # .required() can specify multiple essential items ---

    .required([
        "verified annual income amount",
        "detailed monthly expenses breakdown",
        "complete existing debt information",
        "authorization to check credit score"
    ])

    .success_condition("All financial data verified")
    .next_state("review")
    # === STATE: review ===
    .state("review: review application completeness")

    # .required() works with single items too ---
    .required("applicant's legal signature and consent")

    .success_condition("application ready for processing")
)

# See the pathway with required information highlighted
print(pathway)
**Loan Application Process**
Purpose: guide customers through loan application requirements
Activate when:
- customer wants to apply for a loan
Flow guidance:
- PERSONAL_INFO (collect): personal info: gather basic applicant information
  Required: (1) applicant's full name, (2) current employment status
- FINANCIAL_DETAILS (collect): financial details: collect financial information
  Required: (1) verified annual income amount, (2) detailed monthly expenses breakdown,
            (3) complete existing debt information, (4) authorization to check credit score
  Success: All financial data verified
- REVIEW (collect): review: review application completeness
  Required: applicant's legal signature and consent
  Success: application ready for processing
Follow as flexible guidance, adapting to user conversation patterns while ensuring key objectives
are addressed.