hbllmutils.meta.datamodel.task

This module provides functionality for creating LLM tasks that generate prompts for datamodels.

The module facilitates the creation of specialized LLM tasks designed to generate prompts based on datamodel classes and their related classes. It integrates with the LLM history and model components to produce structured prompt generation tasks.

create_datamodel_prompt_generation_task

hbllmutils.meta.datamodel.task.create_datamodel_prompt_generation_task(model: str | LLMModel, datamodel_class: type, related_datamodel_classes: List[type] | None = None) LLMTask[source]

Create an LLM task for generating prompts based on a datamodel class.

This function creates a specialized LLM task that generates prompts for a given datamodel class. It constructs a meta-prompt based on the datamodel class and optionally related datamodel classes, then wraps it in an LLM task with appropriate history context.

Parameters:
  • model (LLMModelTyping) – The LLM model to use for the task. Can be a model instance, model name, or any valid LLMModelTyping value.

  • datamodel_class (type) – The datamodel class for which to generate prompts.

  • related_datamodel_classes (Optional[List[type]]) – Optional list of related datamodel classes to include in the prompt generation context. Defaults to None.

Returns:

An LLM task configured for datamodel prompt generation.

Return type:

LLMTask

Example::
>>> from dataclasses import dataclass
>>> @dataclass
... class MyDataModel:
...     name: str
...     age: int
>>> task = create_datamodel_prompt_generation_task('gpt-4', MyDataModel)
>>> # task is now ready to be executed