**New Feature: Summon a Genie 🧞♂️ (Function Decorator) to Generate Agent Powered Function in Runtime**
As a developer, have you ever dreamed about writing some definitions and annotation in code then "boom!" all in a sudden, some genies 🧞♂️ come out and make all your wishes happen? Notice that: **the genies do not write the code for you, instead they just _finish the work_ for you!**
Now Agently framework present a brand new feature **"agent auto function decorator"** for you in **version 3.1.4**! Use `<agent instance>.auto_func` to decorate your function and feel the magic!
Combining the tools-using abilities we enhanced the Agently agents recently in **version 3.1.2**, just open your mind and let's see how fantasy work you can let the agents help you to do.
**Demo Code:**
python
create a search agent
search_agent = (
Agently.create_agent()
.set_settings("model.OpenAI.auth", { "api_key": "" })
)
equip search agent with tool "search_definition"
search_agent.use_public_tools("search_definition")
define your function: input arguments, output data structure requirement, function purpose
then use decorator to call search agent to help
search_agent.auto_func
def find_definition(concept_keyword:str) -> {"source": ("String", ), "definition": ("String", )}:
"""Search your knowledge or the internet to find out the definition of {concept_keyword}."""
return
do not need to complete the function coding
just call it and get your result
result = find_definition("OpenAI")
**Result Example:**
python
{'source': 'Wikipedia', 'definition': "OpenAI is a U.S. artificial intelligence (AI) research organization founded in December 2015, researching artificial intelligence with the declared intention of developing 'safe and beneficial' artificial general intelligence."}
**[Visit Show Case Page to Explore What it Can Do More!](https://github.com/Maplemx/Agently/blob/main/playground/generate_agent_powered_function_in_runtime_using_decorator.ipynb)**
----
**新功能:召唤🧞♂️(代码装饰器)完成只给了定义和注释的函数指向的工作**
作为程序员,你是否曾经梦想着有一天,在编写代码的时候,你只需要写下一些定义和注释,然后就有某个神奇的精灵🧞♂️跳出来帮你把剩下的工作都完成了?注意哦,这里我们说的,并不是帮你把那些代码写完,而是**直接帮你把你定义的工作做完**哦!
现在,Agently框架在圆周率版本(3.1.4)为您推出了这样的全新功能:"agent智能函数装饰器",你只需要在写好定义和注释的空函数上方,使用`<agent instance>.auto_func`这样一个函数装饰器,就可以感受到魔法一般的效果啦!
结合Agently最近为agent添加的工具使用能力,思路打开🫴,看看我们能让agent帮助我们做哪些神奇的事情吧。
样例代码:
python
创建一个search_agent
search_agent = (
Agently.create_agent()
.set_settings("model.OpenAI.auth", { "api_key": "" })
)
给你的search_agent装备搜索工具
search_agent.use_public_tools("search_definition")
定义你的函数(输入参数、输出格式、函数的工作目标)
然后通过装饰器召唤你的search_agent来帮忙
search_agent.auto_func
def find_definition(concept_keyword:str) -> {"source": ("String", ), "definition": ("String", )}:
"""Search your knowledge or the internet to find out the definition of {concept_keyword}."""
return
直接运行就可以获得你想要的结果
result = find_definition("OpenAI")
**[点击查看相关Show Case案例页面,了解还有哪些场景可以使用](https://github.com/Maplemx/Agently/blob/main/playground/generate_agent_powered_function_in_runtime_using_decorator.ipynb)**