Skip to main content

StateMachineInput

StateMachineInput defines the input TokenSets for a state machine instruction. It has the same structure and requirements as InstructionInput, but is required when the protocol is created with state_machine=True.

StateMachineInput Parameters

class StateMachineInput:
def __init__(self, tokensets: List[TokenSet]):
  • tokensets: A required list of TokenSets that define the input patterns. The number of TokenSets must match the protocol's inputs parameter.

Creating a StateMachineInput

# Create TokenSets for input patterns
question_tokenset = mtp.TokenSet(tokens=(question, context))
detail_tokenset = mtp.TokenSet(tokens=(detail, context))

# Create StateMachineInput
state_machine_input = mtp.StateMachineInput(
tokensets=[question_tokenset, detail_tokenset]
)

The number of TokenSets must be consistent across all state machine samples, and must match the protocol's inputs value.