Skip to content

Feature request: no way to control the output language of LLM-generated community labels #1824

Description

@jerp86

Version: 0.9.12

Problem: graphify label/cluster-only (with an LLM backend, e.g. claude-cli) names communities via label_communities() in llm.py. The prompt built in _label_batch_with_retry (llm.py, around line 2392) is a hardcoded English string with no language directive:

prompt = (
    "You are naming clusters in a knowledge graph. For each community below, "
    "return a concise 2-5 word plain-language name describing what it is about "
    "(e.g. \"Order Management\", \"Payment Flow\", \"Auth Middleware\"). "
    "Respond ONLY with a JSON object mapping the community id (as a string) to "
    "its name - no prose, no markdown fences.\n\n" + "\n".join(batch_lines)
)

There is no CLI flag or environment variable to pin the output language (checked cli.py's label/cluster-only arg parsing and llm.py for any GRAPHIFY_* env var touching labeling — none exists; the only --lang flag in the codebase is unrelated, for export callflow-html's HTML chrome language).

Impact: for non-English codebases/teams, re-running label/cluster-only across sessions produces inconsistent label language — the same community gets named in English in one relabel pass and in the team's natural language (e.g. Portuguese) in another, since the model infers language ambiently from the sampled node-label lines rather than an explicit instruction. This makes diffing/comparing labels across reclusters noisy and forces manual normalization.

Suggestion: add an explicit language instruction to the labeling prompt, controllable via a --label-language/--lang flag on label/cluster-only (or a GRAPHIFY_LABEL_LANGUAGE env var), defaulting to the current unconstrained behavior for backward compatibility.

Happy to test a patch if useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions