Skip to content

SourceResource

Base classes

Name Children Inherits
BaseResource
llmling.config.models
Base class for all resource types.

⋔ Inheritance diagram

graph TD
  2910433429["models.SourceResource"]
  1028592330["models.BaseResource"]
  330168112["schema.Schema"]
  3879467795["main.BaseModel"]
  2751680898["builtins.object"]
  1028592330 --> 2910433429
  330168112 --> 1028592330
  3879467795 --> 330168112
  2751680898 --> 3879467795

🛈 DocStrings

Bases: BaseResource

Resource from Python source code.

Source code in src/llmling/config/models.py
class SourceResource(BaseResource):
    """Resource from Python source code."""

    type: Literal["source"] = Field(default="source", init=False)
    """Discriminator field identifying this as a source code resource."""

    import_path: str
    """Dotted import path to the Python module or object."""

    recursive: bool = False
    """Whether to include submodules recursively."""

    include_tests: bool = False
    """Whether to include test files and directories."""

    @model_validator(mode="after")
    def validate_import_path(self) -> SourceResource:
        """Validate that the import path is properly formatted."""
        if not all(part.isidentifier() for part in self.import_path.split(".")):
            msg = f"Invalid import path: {self.import_path}"
            raise ValueError(msg)
        return self

import_path instance-attribute

import_path: str

Dotted import path to the Python module or object.

include_tests class-attribute instance-attribute

include_tests: bool = False

Whether to include test files and directories.

recursive class-attribute instance-attribute

recursive: bool = False

Whether to include submodules recursively.

type class-attribute instance-attribute

type: Literal['source'] = Field(default='source', init=False)

Discriminator field identifying this as a source code resource.

validate_import_path

validate_import_path() -> SourceResource

Validate that the import path is properly formatted.

Source code in src/llmling/config/models.py
@model_validator(mode="after")
def validate_import_path(self) -> SourceResource:
    """Validate that the import path is properly formatted."""
    if not all(part.isidentifier() for part in self.import_path.split(".")):
        msg = f"Invalid import path: {self.import_path}"
        raise ValueError(msg)
    return self

:fa-brands-github: Show source on GitHub