lang_tools.llm.word_generator
¶
WordGeneratorChain: generate themed vocabulary on demand.
Classes:
-
GeneratedWord–One LLM-generated vocabulary item.
-
WordGeneratorInput–Inputs to
WordGeneratorChain. -
WordGeneratorOutput–Outputs from
WordGeneratorChain.
Functions:
-
build_word_generator_chain–Build a word generator chain wired to
chat_config.
GeneratedWord
¶
Bases: BaseModel
One LLM-generated vocabulary item.
Attributes:
-
text(str) –The word in the target language.
-
translation(str) –English translation.
-
part_of_speech(str) –Word class label.
-
example_sentence(str) –Example sentence in the target language.
-
example_translation(str) –English translation of the example sentence.
WordGeneratorInput
¶
Bases: BaseModelKwargs
Inputs to WordGeneratorChain.
Attributes:
-
language(str) –ISO 639-1 target language code.
-
topic(str) –Theme to draw vocabulary from.
-
num_words(int) –How many words to produce.
-
difficulty(str) –"beginner"/"intermediate"/"advanced". -
require_accents(bool) –If True, only return words containing accented chars.
WordGeneratorOutput
¶
Bases: BaseModel
Outputs from WordGeneratorChain.
Attributes:
-
words(list[GeneratedWord]) –Generated vocabulary list.
build_word_generator_chain
¶
build_word_generator_chain(
chat_config: ChatConfig,
*,
base_prompt_fol: Path | None = None,
version: str = "auto",
) -> StructuredLLMChain[
WordGeneratorInput, WordGeneratorOutput
]
Build a word generator chain wired to chat_config.