Skip to content

tools

Class info

Classes

Name Children Inherits
TestTool
llmling.testing.tools

    🛈 DocStrings

    analyze_ast async

    analyze_ast(code: str) -> dict[str, int]
    

    Analyze Python code AST.

    Parameters:

    Name Type Description Default
    code str

    Python source code to analyze

    required

    Returns:

    Type Description
    dict[str, int]

    Dictionary with analysis results

    Source code in src/llmling/testing/tools.py
    async def analyze_ast(code: str) -> dict[str, int]:
        """Analyze Python code AST.
    
        Args:
            code: Python source code to analyze
    
        Returns:
            Dictionary with analysis results
        """
        tree = ast.parse(code)
        return {
            "classes": len([n for n in ast.walk(tree) if isinstance(n, ast.ClassDef)]),
            "functions": len([n for n in ast.walk(tree) if isinstance(n, ast.FunctionDef)]),
        }
    

    example_tool async

    example_tool(text: str, repeat: int = 1) -> str
    

    Example tool that repeats text.

    Parameters:

    Name Type Description Default
    text str

    Text to repeat

    required
    repeat int

    Number of times to repeat

    1

    Returns:

    Type Description
    str

    The repeated text

    Source code in src/llmling/testing/tools.py
    async def example_tool(text: str, repeat: int = 1) -> str:
        """Example tool that repeats text.
    
        Args:
            text: Text to repeat
            repeat: Number of times to repeat
    
        Returns:
            The repeated text
        """
        return text * repeat
    

    failing_tool async

    failing_tool(text: str) -> str
    

    Tool that always fails.

    Source code in src/llmling/testing/tools.py
    5
    6
    7
    8
    async def failing_tool(text: str) -> str:
        """Tool that always fails."""
        msg = "Intentional failure"
        raise ValueError(msg)