fabricatio_tagging.capabilities.tagging

Tagging capabilities module.

This module provides functionality for generating tags from text content using AI models through the Tagging class.

Classes

Tagging

A class for generating tags from text content using AI models.

Module Contents

class fabricatio_tagging.capabilities.tagging.Tagging(/, **data: Any)

Bases: fabricatio_core.capabilities.propose.Propose

A class for generating tags from text content using AI models.

This class extends the Propose capability to provide tagging functionality for both individual text strings and lists of text strings.

async tagging(text: str, requirement: str = '', k: int = 0, **kwargs: Unpack[fabricatio_core.models.kwargs_types.LLMKwargs]) List[str] | None
async tagging(text: List[str], requirement: str = '', k: int = 0, **kwargs: Unpack[fabricatio_core.models.kwargs_types.LLMKwargs]) List[List[str]]

Generate tags for text content.

This method can handle both single text strings and lists of text strings, generating appropriate tags based on the provided requirements.

Parameters:
  • text – The input text(s) to generate tags for. Can be a single string or a list of strings.

  • requirement – Additional requirements or constraints for tag generation. Defaults to empty string.

  • k – Maximum number of tags to generate (0 for no limit). Defaults to 0.

  • **kwargs – Additional generation parameters passed to the underlying AI model.

Returns:

A list of generated tags or None if generation fails. For multiple text input: A list of tag lists, one for each input text.

Return type:

For single text input

Raises:

TypeError – If text is neither a string nor a list of strings.