Skip to content

PromptParameter

Base classes

Name Children Inherits
BaseModel
pydantic.main
!!! abstract "Usage Documentation"

⋔ Inheritance diagram

graph TD
  3827621403["models.PromptParameter"]
  3879467795["main.BaseModel"]
  2751680898["builtins.object"]
  3879467795 --> 3827621403
  2751680898 --> 3879467795

🛈 DocStrings

Bases: BaseModel

Prompt argument with validation information.

Source code in src/llmling/prompts/models.py
class PromptParameter(BaseModel):
    """Prompt argument with validation information."""

    name: str
    """Name of the argument as used in the prompt."""

    description: str | None = None
    """Human-readable description of the argument."""

    required: bool = False
    """Whether this argument must be provided when formatting the prompt."""

    type_hint: ImportString = Field(default="str")
    """Type annotation for the argument, defaults to str."""

    default: Any | None = None
    """Default value if argument is optional."""

    completion_function: ImportString | None = Field(default=None)
    """Optional function to provide argument completions."""

    model_config = ConfigDict(use_attribute_docstrings=True)

    def to_mcp_argument(self) -> PromptArgument:
        """Convert to MCP PromptArgument."""
        from mcp.types import PromptArgument

        return PromptArgument(name=self.name, description=self.description, required=self.required)

completion_function class-attribute instance-attribute

completion_function: ImportString | None = Field(default=None)

Optional function to provide argument completions.

default class-attribute instance-attribute

default: Any | None = None

Default value if argument is optional.

description class-attribute instance-attribute

description: str | None = None

Human-readable description of the argument.

name instance-attribute

name: str

Name of the argument as used in the prompt.

required class-attribute instance-attribute

required: bool = False

Whether this argument must be provided when formatting the prompt.

type_hint class-attribute instance-attribute

type_hint: ImportString = Field(default='str')

Type annotation for the argument, defaults to str.

to_mcp_argument

to_mcp_argument() -> PromptArgument

Convert to MCP PromptArgument.

Source code in src/llmling/prompts/models.py
def to_mcp_argument(self) -> PromptArgument:
    """Convert to MCP PromptArgument."""
    from mcp.types import PromptArgument

    return PromptArgument(name=self.name, description=self.description, required=self.required)

:fa-brands-github: Show source on GitHub