Skip to content

fix: add language and instructions parameters to generate_mind_map()#268

Open
octo-patch wants to merge 2 commits intoteng-lin:mainfrom
octo-patch:fix/issue-250-mind-map-language-instructions
Open

fix: add language and instructions parameters to generate_mind_map()#268
octo-patch wants to merge 2 commits intoteng-lin:mainfrom
octo-patch:fix/issue-250-mind-map-language-instructions

Conversation

@octo-patch
Copy link
Copy Markdown

@octo-patch octo-patch commented Apr 11, 2026

Fixes #250

Problem

generate_mind_map() does not accept language or instructions parameters, unlike every other artifact generation method (audio, video, report, slides, infographic, etc.). The payload contained hardcoded static values:

["interactive_mindmap", [["[CONTEXT]", ""]], ""]

This means mind maps were always generated in English with no custom instructions, ignoring the configured language or any user-provided instructions.

Solution

Added language and instructions parameters to generate_mind_map() in _artifacts.py, matching the signature of other generation methods:

  • language: str = "en" — passed to params[5][2]
  • instructions: str | None = None — passed to params[5][1][0][1]

Updated the CLI generate mind-map command in cli/generate.py to expose --language and --instructions flags, using the same resolve_language() helper as other generate commands.

Testing

  • Added integration test in tests/integration/test_artifacts.py: test_generate_mind_map_language_and_instructions — verifies that the language and instructions values are correctly placed in the RPC payload
  • All existing tests continue to pass (2016 passed)

Summary by CodeRabbit

  • New Features

    • Mind map generation supports language selection (default: English) and an optional instructions text to guide output.
  • CLI

    • Added --language and --instructions flags to mind-map generation commands.
  • Tests

    • Added integration tests validating language and instructions are passed to mind map generation.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 11, 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: fc351223-0595-4b64-b37a-292ccc33d2ca

📥 Commits

Reviewing files that changed from the base of the PR and between 9256231 and 590c296.

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

📝 Walkthrough

Walkthrough

Added optional language and instructions parameters to ArtifactsAPI.generate_mind_map, updated the RPC payload to include them, exposed --language and --instructions in the CLI, and added an integration test asserting the RPC receives the new values.

Changes

Cohort / File(s) Summary
API Parameter Enhancement
src/notebooklm/_artifacts.py
Added language: str = "en" and `instructions: str
CLI Option Addition
src/notebooklm/cli/generate.py
Added --language and --instructions options, updated the command callback signature to accept them, resolved language via resolve_language(...), and forwarded both values to client.artifacts.generate_mind_map(...) for JSON and console flows.
Integration Test
tests/integration/test_artifacts.py
Added test_generate_mind_map_language_and_instructions which patches client.artifacts._core.rpc_call, invokes generate_mind_map(language="ja", instructions="Focus on key relationships"), and asserts the RPC params include the provided language and instructions at the expected indices.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I nibbled code and found a way,
To tell the map the words to say,
Flags for language, notes to show,
Now mind maps speak where rabbits go,
Hooray for clearer paths today! 🌿🗺️

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% 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 title clearly and concisely describes the main change: adding language and instructions parameters to the generate_mind_map() method.
Linked Issues check ✅ Passed The pull request fully implements all coding requirements from issue #250: adds language and instructions parameters to generate_mind_map() [#250], updates the CLI with --language and --instructions flags [#250], and includes integration test validation of payload structure [#250].
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the requirements in issue #250; no out-of-scope modifications are present.

✏️ 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 a language and custom instructions when generating mind maps. The generate_mind_map function in the artifacts module and the CLI command have been updated to support these parameters, and a new integration test verifies the RPC payload. Feedback suggests refactoring the CLI logic to eliminate duplicate calls to the generation method by using a helper closure.

I am having trouble creating individual review comments. Click here to see my feedback.

src/notebooklm/cli/generate.py (1017-1025)

medium

The call to client.artifacts.generate_mind_map is duplicated inside and outside the console.status block. This redundancy makes the code harder to maintain and deviates from the pattern used in other generation commands. It is better to define the call once using a closure or by preparing the arguments.

            async def _generate():
                return await client.artifacts.generate_mind_map(
                    nb_id_resolved, 
                    source_ids=sources, 
                    language=resolved_language, 
                    instructions=instructions
                )

            if json_output:
                result = await _generate()
            else:
                with console.status("Generating mind map..."):
                    result = await _generate()

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

1 participant