done_sequence_parser
langroid/agent/done_sequence_parser.py
Parser for done sequence DSL (Domain Specific Language).
Converts string patterns into DoneSequence objects for convenient task completion configuration.
Examples:
"T, A" -> Tool followed by Agent response "T[calculator], A" -> Specific tool 'calculator' followed by Agent response "L, T, A, L" -> LLM, Tool, Agent, LLM sequence "C[quit|exit]" -> Content matching regex pattern
parse_done_sequence(sequence)
¶
Parse a string pattern or return existing DoneSequence unchanged.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sequence
|
Union[str, DoneSequence]
|
Either a DoneSequence object or a string pattern to parse |
required |
Returns:
Type | Description |
---|---|
DoneSequence
|
DoneSequence object |
Raises:
Type | Description |
---|---|
ValueError
|
If the string pattern is invalid |
Source code in langroid/agent/done_sequence_parser.py
parse_done_sequences(sequences)
¶
Parse a list of mixed string patterns and DoneSequence objects.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sequences
|
List[Union[str, DoneSequence]]
|
List containing strings and/or DoneSequence objects |
required |
Returns:
Type | Description |
---|---|
List[DoneSequence]
|
List of DoneSequence objects |