From 6622a5d9c36ab5c284af8824c65da20c2a338925 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 14 Jun 2026 04:42:40 +0000 Subject: [PATCH] Simplify transcribe/config-builder duplication Reuse split_csv in coerce_value's list branch instead of re-inlining the CSV split-and-strip, and extract the duplicated TransformOptions construction (batch + single run paths) into TranscribeOptions.transform_options(). --- aai_cli/app/transcribe/run.py | 14 ++++++++------ aai_cli/core/config_builder.py | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/aai_cli/app/transcribe/run.py b/aai_cli/app/transcribe/run.py index 3ec3d189..4b1d5c97 100644 --- a/aai_cli/app/transcribe/run.py +++ b/aai_cli/app/transcribe/run.py @@ -269,6 +269,12 @@ def flags(self, pii_policies: list[str] | None) -> dict[str, object]: flags.update(config_builder.auth_header_flags(self.webhook_auth_header)) return flags + def transform_options(self) -> TransformOptions: + """The post-transcription LLM transform spec built from the `--llm` flags.""" + return TransformOptions( + prompts=list(self.llm_prompt or []), model=self.model, max_tokens=self.max_tokens + ) + def _print_show_code(opts: TranscribeOptions, merged: dict[str, object]) -> None: """Print the equivalent SDK script and exit without transcribing or authenticating. @@ -340,9 +346,7 @@ def run_transcribe(opts: TranscribeOptions, state: AppState, *, json_mode: bool) transcription_config=config_builder.construct_transcription_config(merged), concurrency=opts.concurrency, force=opts.force, - transform=TransformOptions( - prompts=list(opts.llm_prompt or []), model=opts.model, max_tokens=opts.max_tokens - ), + transform=opts.transform_options(), json_mode=json_mode, quiet=state.quiet, ) @@ -376,9 +380,7 @@ def run_transcribe(opts: TranscribeOptions, state: AppState, *, json_mode: bool) out=opts.out, output_field=opts.output_field, chars_per_caption=opts.chars_per_caption, - transform=TransformOptions( - prompts=list(opts.llm_prompt or []), model=opts.model, max_tokens=opts.max_tokens - ), + transform=opts.transform_options(), json_mode=json_mode, quiet=state.quiet, ) diff --git a/aai_cli/core/config_builder.py b/aai_cli/core/config_builder.py index 5e72a641..d54038ed 100644 --- a/aai_cli/core/config_builder.py +++ b/aai_cli/core/config_builder.py @@ -200,7 +200,7 @@ def coerce_value(field: str, raw: str) -> object: """Coerce a string --config value to the type expected by `field`.""" kind = TRANSCRIBE_COERCE.get(field) or STREAM_COERCE.get(field, "str") if kind == "list": - return [part.strip() for part in raw.split(",") if part.strip()] + return split_csv(raw) or [] entry = _VALIDATORS.get(kind) if entry is None: # "str" and any unknown kind pass through raw return raw