Skip to content

feat(generate): add language and instructions to mind maps#264

Open
voidborne-d wants to merge 2 commits intoteng-lin:mainfrom
voidborne-d:feat/mind-map-language-instructions-2
Open

feat(generate): add language and instructions to mind maps#264
voidborne-d wants to merge 2 commits intoteng-lin:mainfrom
voidborne-d:feat/mind-map-language-instructions-2

Conversation

@voidborne-d
Copy link
Copy Markdown
Contributor

@voidborne-d voidborne-d commented Apr 10, 2026

Summary

  • add language and instructions support to ArtifactsAPI.generate_mind_map()
  • expose generate mind-map [DESCRIPTION] --language ... in the CLI
  • cover the new payload and CLI behavior with unit tests

Closes #250

Testing

  • uv run pytest tests/unit/cli/test_generate.py -k mind_map
  • uv run pytest tests/unit/test_source_selection.py -k mind_map

Summary by CodeRabbit

  • New Features

    • Mind map generation supports language selection (default: English).
    • Custom instructions/descriptions can be supplied when generating mind maps.
    • CLI generate mind-map adds an optional description argument and a --language option.
  • Tests

    • Added unit tests for the CLI and API paths to verify language and instructions are passed in requests.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 10, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1dfcb79e-d08a-4ffd-a259-ab7eea79378f

📥 Commits

Reviewing files that changed from the base of the PR and between 885b1ec and a3f95c5.

📒 Files selected for processing (2)
  • src/notebooklm/cli/generate.py
  • tests/unit/test_source_selection.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/notebooklm/cli/generate.py

📝 Walkthrough

Walkthrough

Added language and instructions parameters to the ArtifactsAPI mind-map generation flow, updated the RPC payload to include those values, exposed a CLI description argument and --language option, and added unit tests verifying the new payload and CLI behavior.

Changes

Cohort / File(s) Summary
Core API Enhancement
src/notebooklm/_artifacts.py
Added language: str = "en" and instructions: str | None = None to ArtifactsAPI.generate_mind_map(); RPC payload now uses ["interactive_mindmap", [["[CONTEXT]", instructions or ""]], language]. Docstring updated.
CLI Command Update
src/notebooklm/cli/generate.py
generate mind-map command now accepts a positional description and an optional --language option. Command handler signature updated and calls client.artifacts.generate_mind_map(language=resolve_language(language), instructions=description or None).
Unit Tests
tests/unit/cli/test_generate.py, tests/unit/test_source_selection.py
Added CLI test ensuring --language is forwarded to artifacts.generate_mind_map. Added async test asserting RPC params[5] encodes the provided instructions and language.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through code with nimble paws,
I whispered languages and gentle laws,
Instructions tucked in every node,
Mind maps branch on paths we showed,
Hooray — new tongues on every clause!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat(generate): add language and instructions to mind maps' accurately describes the main change of adding language and instructions support to the mind map generation feature.
Linked Issues check ✅ Passed The PR implements all requirements from issue #250: adds language (default 'en') and instructions (default None) parameters to ArtifactsAPI.generate_mind_map, correctly places them in RPC payload at params[5][2] and params[5][1][0][1], and exposes CLI options --language and DESCRIPTION argument.
Out of Scope Changes check ✅ Passed All changes directly relate to adding language and instructions support to mind map generation: API method signature updates, CLI command modifications, and unit tests validating the new parameters.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the ability to specify an output language and optional generation instructions when creating mind maps. These changes affect the generate_mind_map API method and the CLI, which now includes a new positional argument for descriptions and a --language option. Unit tests have been updated to cover these new features. The review feedback suggests refactoring the CLI logic to resolve the language and instructions once before the conditional output block to avoid redundant processing and improve maintainability.

Comment on lines +1024 to +1032
language=resolve_language(language),
instructions=description or None,
)
else:
with console.status("Generating mind map..."):
result = await client.artifacts.generate_mind_map(
nb_id_resolved, source_ids=sources
nb_id_resolved,
source_ids=sources,
language=resolve_language(language),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logic for calling generate_mind_map is duplicated across the if json_output branches, including redundant calls to resolve_language(language) and description or None. Since resolve_language may involve reading the configuration file, it's more efficient to resolve these values once before the conditional block. This would also simplify the code and improve maintainability.

References
  1. To improve efficiency and clarity, avoid reading the same file multiple times within a single function. Instead, read the file once, store its contents in a variable, and reuse the variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mind map generation ignores language and instructions parameters

2 participants