auto_func 函数接口
auto_func 允许你把一个普通函数“映射成模型接口”:
- 函数签名 → 输入结构
- docstring → 指令说明
- return 注解 → 输出结构
这样你可以像调用函数一样调用模型。
基础示例
python
from agently import Agently
agent = Agently.create_agent()
@agent.auto_func
def calculate(formula: str) -> int:
"""
Return result of {formula}.
MUST USE TOOLS TO ENSURE THE ANSWER IS ACTUAL NO MATTER WHAT.
"""
...
result = calculate("3333+6666=?")
print(result)异步函数
如果原函数是 async,会返回 async 版本:
python
@agent.auto_func
async def plan(task: str) -> dict:
"""Return a plan for {task}."""
...
result = await plan("Launch a feature")注意事项
auto_func不支持生成器函数- return 注解会被当作输出 schema