[Feature]: 请问如何用agentscope studio以托拽的形式 实现agent通过代码调用外部接口?
请问如何在agentscope studio中 添加tool。以及如何用agentscope studio以托拽的形式 实现agent通过代码调用外部接口?
"在agentscope studio中添加tool"指的是?是说workstation添加新的工具么
Adding external tools potentially means that the workflow execution engine may run untrusted code, which is a relatively risky operation, and therefore is not currently supported on our maintained website. We will consider adding this feature in the local version ASAP.
"在agentscope studio中添加tool"指的是?是说workstation添加新的工具么
在tool中添加reactagent可用的service 我已经用代码实现了由agent访问LLM再调用注册好的service 想请问您怎么在studio中利用拖拽的形式 实现这一点呢? 谢谢🙏
Adding external tools potentially means that the workflow execution engine may run untrusted code, which is a relatively risky operation, and therefore is not currently supported on our maintained website. We will consider adding this feature in the local version ASAP.
thx!!! but can I make it happen in local agentscope studio? cause I already made it on code level, my leader told me to achieve on studio.
@Wjc0323
⚠️Warning Invoking external code or tools through an agent may involve relatively risky operations.
Here, we take BingServiceTest as an example to show how to add a new service. You can refer to the steps below.
FrontEnd
- Add souce html of
BingServiceTestto diretorysrc/agentscope/studio/static/html-drag-components, here we can copy fromservice-bing-search.htmland rename the related data class toBingSearchServiceTest. - add
BingServiceTestto the sidebar of workstation insrc/agentscope/studio/templates/workstation.html
<li class="workstation-sidebar-dragitem unselectable-text"
data-node="BingSearchServiceTest"
draggable="true" ondragstart="drag(event)">
Bing Search Test
</li>
- Add Drag-Event to workstation in
src/agentscope/studio/static/js/workstation.js
// add mapping
let nameToHtmlFile ={
...
'BingSearchServiceTest': 'service-bing-search_test.html',
}
....
// add drag event
case 'BingSearchServiceTest':
editor.addNode('BingSearchServiceTest', 0, 0,
pos_x, pos_y, 'BingSearchServiceTest', {
"args": {
"api_key": "",
"num_results": 3,
}
}, htmlSourceCode);
break;
BackEnd
- Add
BingServiceTestNodeto workstation insrc/agentscope/web/workstation/workflow_node.py. In the new node, you need to call your customized service function.
# add nodes mapping
NODE_NAME_MAPPING = {
....
"BingSearchServiceTest": BingSearchServiceTestNode,
}
# source code
class BingSearchServiceTestNode(WorkflowNode):
"""
Bing Search Test Node
"""
node_type = WorkflowNodeType.SERVICE
def __init__(
self,
node_id: str,
opt_kwargs: dict,
source_kwargs: dict,
dep_opts: list,
) -> None:
super().__init__(node_id, opt_kwargs, source_kwargs, dep_opts)
self.service_func = partial(bing_search, **self.opt_kwargs)
def compile(self) -> dict:
return {
"imports": "from agentscope.service import ServiceToolkit\n"
"from functools import partial\n"
"from agentscope.service import bing_search",
"inits": f"{self.var_name} = partial(bing_search,"
f" {kwarg_converter(self.opt_kwargs)})",
"execs": "",
}