llm_tools
Class info¶
Classes¶
| Name | Children | Inherits |
|---|---|---|
| LLMTools llmling.config.llm_tools Contains wrapped RuntimeConfig methods for better usage by LLMs. |
🛈 DocStrings¶
Wrapper for tools supplied to the LLM.
LLMTools
¶
Contains wrapped RuntimeConfig methods for better usage by LLMs.
Adapts docstrings and return types.
Source code in src/llmling/config/llm_tools.py
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
get_resources
¶
Discover what resources are available for loading.
WHEN TO USE THIS TOOL: - At the start of a task to understand available resources - When you need to find specific types of content - When you're unsure what resources exist - Before using load_resource to verify resource exists
DO NOT USE THIS TOOL: - When you already know the resource exists - Repeatedly for the same information - Just to check if a single resource exists
Returns:
| Type | Description |
|---|---|
list[dict]
|
List of available resources with their descriptions |
Example
resources = await get_resources()
Returns: [¶
{"name": "main.py", "description": "Main application code"},¶
{"name": "docs/guide.md", "description": "User guide"}¶
]¶
Source code in src/llmling/config/llm_tools.py
install_package
async
¶
Install a Python package for future tool functionality.
WHEN TO USE THIS TOOL: - When registering a tool that requires a specific package - When you need functionality from a standard Python package - Before registering tools that have dependencies
DO NOT USE THIS TOOL: - For untrusted or unknown packages - When the package is already installed - For packages with complex system requirements - When you're unsure if the package is needed
NOTE: Installed packages only become available for tools in future interactions, not in the current one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
package
|
str
|
Package specification (e.g. "requests>=2.28.0") |
required |
Example
await install_package("beautifulsoup4>=4.12.0")
Source code in src/llmling/config/llm_tools.py
load_resource
async
¶
Load and access content from available resources.
WHEN TO USE THIS TOOL: - When you need to read or analyze existing content - When you need to access documentation or code files - When you need reference material for a task
DO NOT USE THIS TOOL: - When you already have the content in your context - When you're unsure if a resource exists - For writing or modifying content
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of an available resource to load |
required |
Examples:
-
Loading a Python file: result = await load_resource("main.py")
-
Loading documentation: docs = await load_resource("python_style_guide")
Source code in src/llmling/config/llm_tools.py
register_code_tool
async
¶
Register new tool functionality from Python code.
WHEN TO USE THIS TOOL: - When you need custom functionality not available in existing tools - When you need to optimize a specific operation - When you need to combine multiple operations into one tool
DO NOT USE THIS TOOL: - For simple operations that existing tools can handle - When the operation is only needed once - When you're unsure about the code's safety or correctness - For code that requires external dependencies
NOTE: The tool will only be available in future interactions. The code must be self-contained and define a single main function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name for the new tool |
required |
code
|
str
|
Python code implementing the tool |
required |
description
|
str | None
|
Optional description of what the tool does |
None
|
Example
await register_code_tool( name="word_count", code=''' def word_count(text: str) -> dict[str, int]: words = text.split() return {"total": len(words)} ''', description="Count total words in text" )
Source code in src/llmling/config/llm_tools.py
register_tool
async
¶
Register an importable function as a tool for future interactions.
WHEN TO USE THIS TOOL: - When you identify a need for repeated functionality - When you find a Python function that would be useful as a tool - To make commonly used operations available as tools
DO NOT USE THIS TOOL: - For one-off operations - When unsure about function safety - For functions that require complex setup - When similar tool already exists
NOTE: Registered tools become available only in future interactions, not in the current one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
function
|
str
|
Import path to the function (e.g. "json.dumps") |
required |
name
|
str
|
Optional custom name for the tool |
required |
description
|
str | None
|
Optional description of what the tool does |
None
|
Example
await register_tool( "textwrap.dedent", name="format_code", description="Remove common leading whitespace from code" )