Skip to content

lang_tools.llm.topics

TopicSuggestionChain: generate practice topics for a language.

Classes:

Functions:

TopicSuggestionInput

Bases: BaseModelKwargs

Inputs to TopicSuggestionChain.

Attributes:

  • language (str) –

    ISO 639-1 target language code.

  • difficulty_level (str) –

    "beginner" / "intermediate" / "advanced".

  • num_topics (int) –

    How many topics to return.

  • exclude_topics (list[str]) –

    Topics to avoid (de-duplication).

TopicSuggestionOutput

Bases: BaseModel

Outputs from TopicSuggestionChain.

Attributes:

  • topics (list[str]) –

    List of topic strings.

build_topic_suggestion_chain

build_topic_suggestion_chain(
    chat_config: ChatConfig,
    *,
    base_prompt_fol: Path | None = None,
    version: str = "auto",
) -> StructuredLLMChain[
    TopicSuggestionInput, TopicSuggestionOutput
]

Build a topic suggestion chain wired to chat_config.

Source code in src/lang_tools/llm/topics.py
def build_topic_suggestion_chain(
    chat_config: ChatConfig,
    *,
    base_prompt_fol: Path | None = None,
    version: str = "auto",
) -> StructuredLLMChain[TopicSuggestionInput, TopicSuggestionOutput]:
    """Build a topic suggestion chain wired to `chat_config`."""
    return StructuredLLMChain(
        chat_config=chat_config,
        prompt_str=load_prompt(
            "topic_suggestion",
            base_prompt_fol=base_prompt_fol,
            version=version,
        ),
        input_model=TopicSuggestionInput,
        output_model=TopicSuggestionOutput,
    )