Skip to content

Commit 8cda455

Browse files
authored
Merge pull request #14 from speechmatics/remove-template-id-restriction
Removed choices from assistant cli argument to support arbitrary strings
2 parents 695cfc9 + f58b60a commit 8cda455

File tree

7 files changed

+22
-8
lines changed

7 files changed

+22
-8
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

7+
## [0.1.2] - 2025-03-28
8+
9+
### Changed
10+
11+
- Removed `choices` from `--assistant` cli argument to support arbitrary strings
12+
- Implemented case-insensitive lookup for predefined template names
13+
714
## [0.1.1] - 2025-03-26
815

916
### Changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.1
1+
0.1.2

speechmatics_flow/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
PlaybackSettings,
2727
DebugMode,
2828
)
29-
from speechmatics_flow.templates import TemplateOptions
29+
from speechmatics_flow.templates import TEMPLATE_NAME_TO_ID
3030

3131
LOGGER = logging.getLogger(__name__)
3232

@@ -116,7 +116,7 @@ def get_conversation_config(
116116

117117
# Command line arguments override values from config file
118118
if assistant := args.get("assistant"):
119-
config["template_id"] = TemplateOptions.get(assistant)
119+
config["template_id"] = TEMPLATE_NAME_TO_ID.get(assistant.lower(), assistant)
120120

121121
return ConversationConfig(**config)
122122

speechmatics_flow/cli_parser.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import argparse
66
import logging
77

8-
from speechmatics_flow.templates import TemplateOptions
9-
108
LOGGER = logging.getLogger(__name__)
119

1210

@@ -150,7 +148,6 @@ def get_arg_parser():
150148
"--assistant",
151149
default=None,
152150
type=str,
153-
choices=[k for k in TemplateOptions.keys()],
154151
help="Choose your assistant.",
155152
)
156153
parser.add_argument(

speechmatics_flow/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class ConnectionSettings:
7979
class ConversationConfig:
8080
"""Defines configuration parameters for conversation requests."""
8181

82-
template_id: TemplateID = "default"
82+
template_id: Union[TemplateID, str] = "default"
8383
"""Name of a predefined template."""
8484

8585
template_variables: Optional[Dict[str, str]] = None

speechmatics_flow/templates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ class Template(Enum):
1717
]
1818

1919
# Map user-friendly name to full TemplateID
20-
TemplateOptions = {t.name: t.value for t in Template}
20+
TEMPLATE_NAME_TO_ID = {member.name.lower(): member.value for member in Template}

tests/test_cli.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,21 @@
2323
{"template_id": Template.amelia.value},
2424
id="assistant amelia",
2525
),
26+
param(
27+
["--assistant=AMELIA"],
28+
{"template_id": Template.amelia.value},
29+
id="assistant AMELIA",
30+
),
2631
param(
2732
["--assistant=humphrey"],
2833
{"template_id": Template.humphrey.value},
2934
id="assistant humphrey",
3035
),
36+
param(
37+
["--assistant=demo-assistant"],
38+
{"template_id": "demo-assistant"},
39+
id="assistant demo",
40+
),
3141
param(
3242
["--config-file=tests/data/conversation_config.json"],
3343
{

0 commit comments

Comments
 (0)