Skip to content

knowledge

Class info

Classes

Name Children Inherits
Knowledge
llmling_agent.models.knowledge
Collection of context sources for an agent.

    🛈 DocStrings

    Knowledge

    Bases: BaseModel

    Collection of context sources for an agent.

    Supports both simple paths and rich resource types for content loading, plus LLMling's prompt system for dynamic content generation.

    Source code in src/llmling_agent/models/knowledge.py
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    class Knowledge(BaseModel):
        """Collection of context sources for an agent.
    
        Supports both simple paths and rich resource types for content loading,
        plus LLMling's prompt system for dynamic content generation.
        """
    
        paths: list[str] = Field(default_factory=list)
        """Quick access to files and URLs."""
    
        resources: list[Resource] = Field(default_factory=list)
        """Rich resource definitions supporting:
        - PathResource: Complex file patterns, watching
        - TextResource: Raw content
        - CLIResource: Command output
        - RepositoryResource: Git repos
        - SourceResource: Python source
        - CallableResource: Function results
        """
    
        prompts: list[PromptType] = Field(default_factory=list)
        """Prompts for dynamic content generation:
        - StaticPrompt: Fixed message templates
        - DynamicPrompt: Python function-based
        - FilePrompt: File-based with template support
        """
    
        convert_to_markdown: bool = False
        """Whether to convert content to markdown when possible."""
    
        model_config = ConfigDict(frozen=True, use_attribute_docstrings=True, extra="forbid")
    
        def get_resources(self) -> list[Resource | PromptType | str]:
            """Get all resources."""
            return self.resources + self.prompts + self.paths
    

    convert_to_markdown class-attribute instance-attribute

    convert_to_markdown: bool = False
    

    Whether to convert content to markdown when possible.

    paths class-attribute instance-attribute

    paths: list[str] = Field(default_factory=list)
    

    Quick access to files and URLs.

    prompts class-attribute instance-attribute

    prompts: list[PromptType] = Field(default_factory=list)
    

    Prompts for dynamic content generation: - StaticPrompt: Fixed message templates - DynamicPrompt: Python function-based - FilePrompt: File-based with template support

    resources class-attribute instance-attribute

    resources: list[Resource] = Field(default_factory=list)
    

    Rich resource definitions supporting: - PathResource: Complex file patterns, watching - TextResource: Raw content - CLIResource: Command output - RepositoryResource: Git repos - SourceResource: Python source - CallableResource: Function results

    get_resources

    get_resources() -> list[Resource | PromptType | str]
    

    Get all resources.

    Source code in src/llmling_agent/models/knowledge.py
    40
    41
    42
    def get_resources(self) -> list[Resource | PromptType | str]:
        """Get all resources."""
        return self.resources + self.prompts + self.paths