The LLM class serves as the primary interface for prompting Large Language Models in Curator. It provides a flexible and extensible way to generate synthetic data using various LLM providers. Returns CuratorResponse which holds dataset, statistics (performance, token usage, cost etc) attributes.
from pydantic import BaseModel
class RecipeResponse(BaseModel):
title: str
ingredients: List[str]
instructions: List[str]
class RecipeGenerator(LLM):
response_format = RecipeResponse
class Cuisines(BaseModel):
"""A list of cuisines."""
cuisines_list: List[str] = Field(description="A list of cuisines.")
class CuisineGenerator(curator.LLM):
"""A cuisine generator that generates diverse cuisines."""
response_format = Cuisines
def prompt(self, input: dict) -> str:
"""Generate a prompt for the cuisine generator."""
return "Generate 10 diverse cuisines."
def parse(self, input: dict, response: Cuisines) -> dict:
"""Parse the model response along with the input to the model into the desired output format.."""
return [{"cuisine": t} for t in response.cuisines_list]