teff.tool.registry¶
teff.tool.registry
¶
Tool registry and decorator.
Classes:
| Name | Description |
|---|---|
ToolRegistry |
Registry mapping tool names to tool classes. |
Functions:
| Name | Description |
|---|---|
tool |
Decorator that registers a function as a tool. |
ToolRegistry
¶
Registry mapping tool names to tool classes.
Methods:
| Name | Description |
|---|---|
create |
Instantiate a tool by name. |
list |
Return all registered tool names. |
register |
Register a tool class. |
Source code in teff/tool/registry.py
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 | |
create
¶
create(name, config=None)
Instantiate a tool by name.
If config is provided, it is passed to the tool's constructor as a
dict when the constructor accepts one (a leading config
parameter); otherwise the config keys are passed as keyword
arguments, and if the constructor rejects them the values are
assigned as attributes on an argument-less instance.
Raises:
| Type | Description |
|---|---|
KeyError
|
If the name is not registered. |
Source code in teff/tool/registry.py
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 | |
list
¶
list()
Return all registered tool names.
Source code in teff/tool/registry.py
69 70 71 | |
register
¶
register(tool_cls)
Register a tool class.
Raises:
| Type | Description |
|---|---|
ValueError
|
If the class has no non-empty name attribute. |
Source code in teff/tool/registry.py
29 30 31 32 33 34 35 36 37 38 39 | |
tool
¶
tool(tool_name, description=None)
Decorator that registers a function as a tool.
The decorated function can be sync or async. An async function
gets both run (with asyncio.run) and arun; a sync function
gets only run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_name
|
str
|
Unique tool name. |
required |
description
|
str | None
|
Optional description (falls back to docstring). |
None
|
Source code in teff/tool/registry.py
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 | |