Skip to content

BaseResource

Sub classes

Name Children Inherits
PathResource
llmling.config.models
Resource loaded from a file or URL.
    TextResource
    llmling.config.models
    Raw text resource.
      CLIResource
      llmling.config.models
      Resource from CLI command execution.
        RepositoryResource
        llmling.config.models
        Git repository content.
          SourceResource
          llmling.config.models
          Resource from Python source code.
            CallableResource
            llmling.config.models
            Resource from executing a Python callable.

              Base classes

              Name Children Inherits
              Schema
              schemez.schema
              Base class for configuration models.

              ⋔ Inheritance diagram

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

              🛈 DocStrings

              Bases: Schema

              Base class for all resource types.

              Source code in src/llmling/config/models.py
              class BaseResource(Schema):
                  """Base class for all resource types."""
              
                  type: str = Field(init=False)
                  """Type identifier for this resource."""
              
                  description: str = ""
                  """Human-readable description of the resource."""
              
                  uri: str | None = None
                  """Canonical URI for this resource, set during registration if unset."""
              
                  processors: list[ProcessingStep] = Field(default_factory=list)
                  """Processing steps to apply when loading this resource."""
              
                  watch: WatchConfig | None = None
                  """Configuration for file system watching, if supported."""
              
                  name: str | None = Field(None, exclude=True)
                  """Technical identifier (automatically set from config key during registration)."""
              
                  # TODO: proper extra="forbid" for all subclasses.
                  model_config = ConfigDict(frozen=True)
              
                  def validate_resource(self) -> list[str]:
                      """Validate resource at runtime.
              
                      This validation is intentionally separated from Pydantic's model validation
                      to handle:
                      - Remote resources and URLs
                      - Template/placeholder paths that don't exist during config loading
                      - Resources that may become available after config loading
                      - Validation of actual resource availability separate from config structure
              
                      Returns:
                          List of validation warnings (empty if all valid)
                      """
                      return []
              
                  @property
                  def supports_watching(self) -> bool:
                      """Whether this resource instance supports watching."""
                      return False
              
                  def is_watched(self) -> bool:
                      """Tell if this resource should be watched."""
                      return self.supports_watching and self.watch is not None and self.watch.enabled
              
                  def is_templated(self) -> bool:
                      """Whether this resource supports URI templates."""
                      return False  # Default: resources are static
              
                  def get_watch_path(self) -> str | None:
                      """Get the path to watch if this resource supports watching."""
                      return None
              
                  @property
                  def mime_type(self) -> str:
                      """Get the MIME type for this resource.
              
                      This should be overridden by subclasses that can determine
                      their MIME type. Default is text/plain.
                      """
                      return "text/plain"
              

              description class-attribute instance-attribute

              description: str = ''
              

              Human-readable description of the resource.

              mime_type property

              mime_type: str
              

              Get the MIME type for this resource.

              This should be overridden by subclasses that can determine their MIME type. Default is text/plain.

              name class-attribute instance-attribute

              name: str | None = Field(None, exclude=True)
              

              Technical identifier (automatically set from config key during registration).

              processors class-attribute instance-attribute

              processors: list[ProcessingStep] = Field(default_factory=list)
              

              Processing steps to apply when loading this resource.

              supports_watching property

              supports_watching: bool
              

              Whether this resource instance supports watching.

              type class-attribute instance-attribute

              type: str = Field(init=False)
              

              Type identifier for this resource.

              uri class-attribute instance-attribute

              uri: str | None = None
              

              Canonical URI for this resource, set during registration if unset.

              watch class-attribute instance-attribute

              watch: WatchConfig | None = None
              

              Configuration for file system watching, if supported.

              get_watch_path

              get_watch_path() -> str | None
              

              Get the path to watch if this resource supports watching.

              Source code in src/llmling/config/models.py
              def get_watch_path(self) -> str | None:
                  """Get the path to watch if this resource supports watching."""
                  return None
              

              is_templated

              is_templated() -> bool
              

              Whether this resource supports URI templates.

              Source code in src/llmling/config/models.py
              def is_templated(self) -> bool:
                  """Whether this resource supports URI templates."""
                  return False  # Default: resources are static
              

              is_watched

              is_watched() -> bool
              

              Tell if this resource should be watched.

              Source code in src/llmling/config/models.py
              def is_watched(self) -> bool:
                  """Tell if this resource should be watched."""
                  return self.supports_watching and self.watch is not None and self.watch.enabled
              

              validate_resource

              validate_resource() -> list[str]
              

              Validate resource at runtime.

              This validation is intentionally separated from Pydantic's model validation to handle: - Remote resources and URLs - Template/placeholder paths that don't exist during config loading - Resources that may become available after config loading - Validation of actual resource availability separate from config structure

              Returns:

              Type Description
              list[str]

              List of validation warnings (empty if all valid)

              Source code in src/llmling/config/models.py
              def validate_resource(self) -> list[str]:
                  """Validate resource at runtime.
              
                  This validation is intentionally separated from Pydantic's model validation
                  to handle:
                  - Remote resources and URLs
                  - Template/placeholder paths that don't exist during config loading
                  - Resources that may become available after config loading
                  - Validation of actual resource availability separate from config structure
              
                  Returns:
                      List of validation warnings (empty if all valid)
                  """
                  return []
              

              :fa-brands-github: Show source on GitHub