Utils

Some functions to help with development

pydantic_to_markdown_table

 pydantic_to_markdown_table (model_class:Type[pydantic.main.BaseModel])

*Convert a Pydantic model class to a markdown table and display it in Jupyter notebook.

Args: model_class: A Pydantic model class (subclass of BaseModel)*

Example usage

class DummyChild(BaseModel):
    """A simple dataclass model"""
    model_name: str = Field(..., description="Name or path of the model to use") # Name
    provider: str = Field(default="huggingface", description="Model provider (huggingface, openai, etc)")
    api_key_env_var: Optional[str] = Field(default=None, description="Environment variable name for API key")
    api_base_url: Optional[str] = Field(default=None, description="Base URL for API reqeuest")
    temperature: float = Field(default=0.7, description="Temperature for generation")
class DummyParent(BaseModel):
    """Main configuration for a chat application"""
    app_name: str = Field(..., description="Name of the application")
    description: str = Field(default="", description="Description of the application")
    system_prompt: str = Field(..., description="System prompt for the LLM")
    model: DummyChild
    show_system_prompt: bool = Field(default=True, description="Whether to show system prompt in UI")
    show_context: bool = Field(default=True, description="Whether to show context in UI")
pydantic_to_markdown_table(DummyParent)

DummyParent

Main configuration for a chat application | Variable | Type | Default | Details | |—|—|—|—| | app_name | str | PydanticUndefined | Name of the application | | description | str | ’’ | Description of the application | | system_prompt | str | PydanticUndefined | System prompt for the LLM | | model | DummyChild | PydanticUndefined | (see DummyChild table) | | show_system_prompt | bool | True | Whether to show system prompt in UI | | show_context | bool | True | Whether to show context in UI |