Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tool Nonimplementation Error #468

Open
2 of 3 tasks
kbzh2558 opened this issue Jun 4, 2024 · 2 comments
Open
2 of 3 tasks

Tool Nonimplementation Error #468

kbzh2558 opened this issue Jun 4, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@kbzh2558
Copy link

kbzh2558 commented Jun 4, 2024

Initial Checks

  • I have searched GitHub for a duplicate issue and I'm sure this is something new
  • I have read and followed the docs & demos and still think this is a bug
  • I am confident that the issue is with modelscope-agent (not my code, or another library in the ecosystem)

What happened + What you expected to happen

您好,

我在建立一个多agent framework,按照单agent的方法把一些本地写的tools写在了上面 (@register_tool('get-index-info')
class GetIndexTool(BaseTool):)但是当运行脚本时出现报错说tools import false:

File "C:\Users\kbzh\folder\modelscope-agent\FRAMEWORK_agent\modelscope_agent\agent.py", line 120, in _register_tool
raise NotImplementedError
NotImplementedError

大概的framework结构和example给出的chatroom类似。我想知道这类示例下tool registration具体应该如何做。

谢谢!

Versions / Dependencies

python 3.11.0

agent

import logging
import time
import json
import ray
from modelscope_agent import create_component
from modelscope_agent.agents import RolePlay
from modelscope_agent.multi_agents_utils.executors.ray import RayTaskExecutor
from modelscope_agent.task_center import TaskCenter

Reproduction script

其中一个implementation如下:

llm_config = {
'model': 'GLM-4',
'model_server': 'zhipu'
}

input tool name

function_list = ['get-index-info','get-index-data','get-index-weight',
'get-industry-info','get-company-info','get-st-history',
'get-stock-data','get-fundamental-data','get-economic-indicator-data']

empty_func_list = []

planner_agent = create_component(
RolePlay,
name='计划者',
remote=REMOTE_MODE,
llm=llm_config,
function_list=empty_func_list,
instruction=PLANNER_INSTRUCTION_PROMPT)

roles = [planner_agent , ....]

def receive_input():
# Function to receive input from the user
question = input("Please input your question: ")
return question

def check_completion():
# Function to check if all tasks are completed
for role in roles:
if not role.task_complete:
return False
return True

def generate_answer(question):
# Function to pass the question to the agent framework and monitor completion
planner_agent.input_text(question)
while not check_completion():
time.sleep(1)
return expresser_agent.output_text

def main():
question = receive_input()
answer = generate_answer(question)
output = {
'action': 'output the plan and completion status',
'answer': answer
}
print(json.dumps(output))

if name == "main":
ray.get(task_center.add_agents.remote(roles))
ray.get(task_center.add_agents.remote([output_agent]))

main()

Issue Severity

High: It blocks me from completing my task.

@kbzh2558 kbzh2558 added the bug Something isn't working label Jun 4, 2024
@zzhangpurdue zzhangpurdue assigned mushenL and unassigned zzhangpurdue and suluyana Jun 5, 2024
@mushenL
Copy link
Collaborator

mushenL commented Jun 5, 2024

您好,从报错上看似乎是没有正确注册,您可以参考https://github.com/modelscope/modelscope-agent/blob/master/docs/contributing/tool_contribution_guide_CN.md 这个文档的流程进行,建议您可以先检查一下modelscope_agent/tools/base.py 中的register_map和您tool文件对应的__init__.py文件中的_import_structure是否正确设置了您的tool,同时您的tool文件中还需要@register_tool()来修饰您的工具,可以先检查一下以上操作是否已经完成

@kbzh2558
Copy link
Author

kbzh2558 commented Jun 5, 2024

您好,

谢谢您的帮助。问题基本解决。请问我若是想要查看每次访问消耗的token数量应该如何操作呢?谢谢。我用的是ZHIPU的模型

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants