running
Class info¶
Classes¶
Name | Children | Inherits |
---|---|---|
NodeFunction llmling_agent.running.discovery Metadata for a function that uses nodes. |
||
NodeInjectionError llmling_agent.running.injection Raised when agent injection fails. |
🛈 DocStrings¶
Decorator auto-injection / run package.
NodeFunction
dataclass
¶
Metadata for a function that uses nodes.
Source code in src/llmling_agent/running/discovery.py
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 |
|
default_inputs
class-attribute
instance-attribute
¶
Default parameter values.
depends_on
class-attribute
instance-attribute
¶
Names of functions this one depends on.
name
class-attribute
instance-attribute
¶
Function name (from function.name).
__post_init__
¶
__post_init__()
Set name and validate dependencies.
Source code in src/llmling_agent/running/discovery.py
40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
NodeInjectionError
¶
Bases: Exception
Raised when agent injection fails.
Source code in src/llmling_agent/running/injection.py
41 42 |
|
execute_functions
async
¶
execute_functions(
functions: list[NodeFunction],
pool: AgentPool,
inputs: dict[str, Any] | None = None,
parallel: bool = False,
) -> dict[str, Any]
Execute discovered functions in the right order.
Source code in src/llmling_agent/running/executor.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
|
execute_single
async
¶
execute_single(
func: NodeFunction,
pool: AgentPool,
available_results: dict[str, Any],
inputs: dict[str, Any] | None = None,
) -> tuple[str, Any]
Execute a single function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func
|
NodeFunction
|
Function to execute |
required |
pool
|
AgentPool
|
Agent pool for injection |
required |
available_results
|
dict[str, Any]
|
Results from previous functions |
required |
inputs
|
dict[str, Any] | None
|
Optional input overrides |
None
|
Returns:
Type | Description |
---|---|
tuple[str, Any]
|
Tuple of (function name, result) |
Raises:
Type | Description |
---|---|
ExecutionError
|
If execution fails |
Source code in src/llmling_agent/running/executor.py
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 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
|
node_function
¶
node_function(
func: Callable | None = None,
*,
deps: Any | None = None,
depends_on: str | Sequence[str | Callable] | Callable | None = None,
) -> Callable
Mark a function for automatic node execution.
Can be used as simple decorator or with arguments:
@node_function async def func(): ...
@node_function(order=1, depends_on="other_func") async def func(): ...
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func
|
Callable | None
|
Function to mark |
None
|
deps
|
Any | None
|
Dependencies to inject into all Agent parameters |
None
|
depends_on
|
str | Sequence[str | Callable] | Callable | None
|
Names of functions this one depends on |
None
|
Returns:
Type | Description |
---|---|
Callable
|
Decorated function |
Source code in src/llmling_agent/running/discovery.py
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 |
|
run_nodes_async
async
¶
run_nodes_async(
config: JoinablePathLike | AgentsManifest,
*,
module: str | None = None,
functions: list[str] | None = None,
inputs: dict[str, Any] | None = None,
parallel: bool = False,
) -> dict[str, Any]
Execute node functions with dependency handling.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
JoinablePathLike | AgentsManifest
|
Node configuration (path or manifest) |
required |
module
|
str | None
|
Optional module to discover functions from |
None
|
functions
|
list[str] | None
|
Optional list of function names to run (auto-discovers if None) |
None
|
inputs
|
dict[str, Any] | None
|
Optional input values for function parameters |
None
|
parallel
|
bool
|
Whether to run independent functions in parallel |
False
|
Returns:
Type | Description |
---|---|
dict[str, Any]
|
Dict mapping function names to their results |
Example
@node_function
async def analyze(analyzer: Agent) -> str:
return await analyzer.run("...")
results = await run_nodes_async("agents.yml")
print(results["analyze"])
Source code in src/llmling_agent/running/run_nodes.py
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 |
|
with_nodes
¶
with_nodes(
pool: AgentPool, func: Callable[P, Awaitable[T]] | None = None
) -> (
Callable[P, Awaitable[T]]
| Callable[[Callable[P, Awaitable[T]]], Callable[P, Awaitable[T]]]
)
Inject nodes into function parameters.
Source code in src/llmling_agent/running/decorators.py
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 |
|