Add blueprint generation CLI#378
Conversation
📝 WalkthroughWalkthroughA new ChangesBlueprint Generation CLI Feature
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/test_cli_synthetic.py (1)
93-122: ⚡ Quick winAssert the full CLI-to-request mapping here.
This test only locks down the two model names. The new command also maps providers, temperatures, domains, settings, and
--no-grounding, so a wiring regression in those flags would still pass.Possible test expansion
[ "generate-blueprints", "Generate anticoagulation decision cases.", "--count", "1", + "--domain", + "cardiovascular", + "--setting", + "outpatient", "--planner-provider", "openrouter", "--planner-model", "planner-model", + "--planner-temperature", + "0.25", "--blueprint-provider", "openrouter", "--blueprint-model", "blueprint-model", + "--blueprint-temperature", + "0.4", + "--no-grounding", ], ) @@ assert captured[0][0].target_count == 1 + assert captured[0][0].domains == ["cardiovascular"] + assert captured[0][0].settings == ["outpatient"] + assert captured[0][0].required_grounding is False + assert captured[0][0].policy_for(GenerationRole.PLANNER).provider == "openrouter" assert captured[0][0].policy_for(GenerationRole.PLANNER).model == "planner-model" + assert captured[0][0].policy_for(GenerationRole.PLANNER).temperature == 0.25 assert ( + captured[0][0].policy_for(GenerationRole.BLUEPRINT_GENERATOR).provider + == "openrouter" + ) + assert ( captured[0][0].policy_for(GenerationRole.BLUEPRINT_GENERATOR).model == "blueprint-model" ) + assert ( + captured[0][0].policy_for(GenerationRole.BLUEPRINT_GENERATOR).temperature + == 0.4 + )🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/test_cli_synthetic.py` around lines 93 - 122, The test currently only asserts planner/blueprint model names; extend the assertions on the captured request (captured[0][0]) to verify the full CLI->request mapping: assert planner provider and blueprint provider values, any temperature fields for planner and blueprint, the domain/intent flag, any settings dict or options passed, and that the no-grounding flag maps to the request.no_grounding (or equivalent) boolean; keep the existing checks for target_count, policy_for(GenerationRole.PLANNER).model and policy_for(GenerationRole.BLUEPRINT_GENERATOR).model and the DatasetStore type to ensure complete coverage of the new flags and wiring.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/casecrawler/cli.py`:
- Around line 967-998: Move the construction of the BlueprintGenerationRequest
into the try/except block so any validation errors raised while building the
request are caught and converted to a click.ClickException; specifically, wrap
the instantiation of BlueprintGenerationRequest (the req variable) together with
DatasetStore() creation and the call to
blueprint_pipeline_module.BlueprintPipeline().generate(...) inside the existing
try, and leave the except ValueError as exc: raise
click.ClickException(str(exc)) from exc to preserve user-facing CLI error
handling.
---
Nitpick comments:
In `@tests/test_cli_synthetic.py`:
- Around line 93-122: The test currently only asserts planner/blueprint model
names; extend the assertions on the captured request (captured[0][0]) to verify
the full CLI->request mapping: assert planner provider and blueprint provider
values, any temperature fields for planner and blueprint, the domain/intent
flag, any settings dict or options passed, and that the no-grounding flag maps
to the request.no_grounding (or equivalent) boolean; keep the existing checks
for target_count, policy_for(GenerationRole.PLANNER).model and
policy_for(GenerationRole.BLUEPRINT_GENERATOR).model and the DatasetStore type
to ensure complete coverage of the new flags and wiring.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: ace66915-098e-469c-b58b-74f7ad6cf847
📒 Files selected for processing (2)
src/casecrawler/cli.pytests/test_cli_synthetic.py
| req = BlueprintGenerationRequest( | ||
| request=request_text, | ||
| target_count=count, | ||
| domains=list(domains), | ||
| settings=list(settings), | ||
| required_grounding=not no_grounding, | ||
| role_policies=[ | ||
| GenerationRolePolicy( | ||
| role=GenerationRole.PLANNER, | ||
| provider=planner_provider, | ||
| model=planner_model, | ||
| temperature=planner_temperature, | ||
| ), | ||
| GenerationRolePolicy( | ||
| role=GenerationRole.BLUEPRINT_GENERATOR, | ||
| provider=blueprint_provider, | ||
| model=blueprint_model, | ||
| temperature=blueprint_temperature, | ||
| ), | ||
| ], | ||
| ) | ||
| try: | ||
| store = DatasetStore() | ||
| result = asyncio.run( | ||
| blueprint_pipeline_module.BlueprintPipeline().generate( | ||
| req, | ||
| dataset_id=resolved_dataset_id, | ||
| store=store, | ||
| ) | ||
| ) | ||
| except ValueError as exc: | ||
| raise click.ClickException(str(exc)) from exc |
There was a problem hiding this comment.
Wrap request validation in the ClickException boundary.
Lines 967-987 build BlueprintGenerationRequest before the try, so any model-validation failure there escapes as a raw exception instead of the user-facing CLI error this command uses for the pipeline call.
Proposed fix
- resolved_dataset_id = dataset_id or f"blueprint-ds-{uuid4()}"
- req = BlueprintGenerationRequest(
- request=request_text,
- target_count=count,
- domains=list(domains),
- settings=list(settings),
- required_grounding=not no_grounding,
- role_policies=[
- GenerationRolePolicy(
- role=GenerationRole.PLANNER,
- provider=planner_provider,
- model=planner_model,
- temperature=planner_temperature,
- ),
- GenerationRolePolicy(
- role=GenerationRole.BLUEPRINT_GENERATOR,
- provider=blueprint_provider,
- model=blueprint_model,
- temperature=blueprint_temperature,
- ),
- ],
- )
+ resolved_dataset_id = dataset_id or f"blueprint-ds-{uuid4()}"
try:
+ req = BlueprintGenerationRequest(
+ request=request_text,
+ target_count=count,
+ domains=list(domains),
+ settings=list(settings),
+ required_grounding=not no_grounding,
+ role_policies=[
+ GenerationRolePolicy(
+ role=GenerationRole.PLANNER,
+ provider=planner_provider,
+ model=planner_model,
+ temperature=planner_temperature,
+ ),
+ GenerationRolePolicy(
+ role=GenerationRole.BLUEPRINT_GENERATOR,
+ provider=blueprint_provider,
+ model=blueprint_model,
+ temperature=blueprint_temperature,
+ ),
+ ],
+ )
store = DatasetStore()
result = asyncio.run(
blueprint_pipeline_module.BlueprintPipeline().generate(📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| req = BlueprintGenerationRequest( | |
| request=request_text, | |
| target_count=count, | |
| domains=list(domains), | |
| settings=list(settings), | |
| required_grounding=not no_grounding, | |
| role_policies=[ | |
| GenerationRolePolicy( | |
| role=GenerationRole.PLANNER, | |
| provider=planner_provider, | |
| model=planner_model, | |
| temperature=planner_temperature, | |
| ), | |
| GenerationRolePolicy( | |
| role=GenerationRole.BLUEPRINT_GENERATOR, | |
| provider=blueprint_provider, | |
| model=blueprint_model, | |
| temperature=blueprint_temperature, | |
| ), | |
| ], | |
| ) | |
| try: | |
| store = DatasetStore() | |
| result = asyncio.run( | |
| blueprint_pipeline_module.BlueprintPipeline().generate( | |
| req, | |
| dataset_id=resolved_dataset_id, | |
| store=store, | |
| ) | |
| ) | |
| except ValueError as exc: | |
| raise click.ClickException(str(exc)) from exc | |
| try: | |
| req = BlueprintGenerationRequest( | |
| request=request_text, | |
| target_count=count, | |
| domains=list(domains), | |
| settings=list(settings), | |
| required_grounding=not no_grounding, | |
| role_policies=[ | |
| GenerationRolePolicy( | |
| role=GenerationRole.PLANNER, | |
| provider=planner_provider, | |
| model=planner_model, | |
| temperature=planner_temperature, | |
| ), | |
| GenerationRolePolicy( | |
| role=GenerationRole.BLUEPRINT_GENERATOR, | |
| provider=blueprint_provider, | |
| model=blueprint_model, | |
| temperature=blueprint_temperature, | |
| ), | |
| ], | |
| ) | |
| store = DatasetStore() | |
| result = asyncio.run( | |
| blueprint_pipeline_module.BlueprintPipeline().generate( | |
| req, | |
| dataset_id=resolved_dataset_id, | |
| store=store, | |
| ) | |
| ) | |
| except ValueError as exc: | |
| raise click.ClickException(str(exc)) from exc |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/casecrawler/cli.py` around lines 967 - 998, Move the construction of the
BlueprintGenerationRequest into the try/except block so any validation errors
raised while building the request are caught and converted to a
click.ClickException; specifically, wrap the instantiation of
BlueprintGenerationRequest (the req variable) together with DatasetStore()
creation and the call to
blueprint_pipeline_module.BlueprintPipeline().generate(...) inside the existing
try, and leave the except ValueError as exc: raise
click.ClickException(str(exc)) from exc to preserve user-facing CLI error
handling.
Summary
casecrawler generate-blueprintsfor model-driven BlueprintGenerationRequest workflowsTests
Summary by CodeRabbit
generate-blueprintsCLI command to generate clinical blueprints with customizable parameters including request text, generation count, dataset persistence, domains, settings, model providers/models/temperatures, and optional grounding control.