We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 5bbb17f + cb090a8 commit dc42260Copy full SHA for dc42260
1 file changed
fastcore/imports.py
@@ -108,9 +108,14 @@ def is_usable_tool(func:callable):
108
109
__llmtools__ = set()
110
111
-def llmtool(f):
112
- assert is_usable_tool(f), f"Function {f.__name__} is not usable as a tool"
113
- __llmtools__.add(f.__name__)
114
- f.__llmtool__ = True
115
- return f
+def llmtool(f=None, **tmpls):
+ "Decorator to mark a function as an LLM tool. Pass `**tmpls` to format the docstring."
+ def decorator(fn):
+ assert is_usable_tool(fn), f"Function {fn.__name__} is not usable as a tool"
+ if fn.__doc__ and tmpls: fn.__doc__ = fn.__doc__.format(**tmpls)
116
+ __llmtools__.add(fn.__name__)
117
+ fn.__llmtool__ = True
118
+ return fn
119
+ if f: return decorator(f)
120
+ return decorator
121
0 commit comments