Git Product home page Git Product logo

Comments (3)

zhaihailong avatar zhaihailong commented on June 12, 2024

示例中,模型是每次返回一个Action吗,RolePlay中的prompt如下,也是返回全部步骤,然后调用tool吧

# 工具

## 你拥有如下工具:

test_tool: test_tool API。AI绘画(图像生成)服务,输入文本描述和图像分辨率,返回根据文本信息绘制的图片URL。 输入参数: {"type": "object", "properties": {"text": {"type": "string", "description": "详细描述了希望生成的图像具有什么内容,例如人物、环境、动作等细节描述"}, "resolution": {"type": "string", "description": "格式是 数字*数字,表示希望生成的图像的分辨率大小,选项有[1024*1024, 720*1280, 1280*720]"}}, "required": ["text", "resolution"]} Format the arguments as a JSON object.

test2_tool: test2_tool API。获取对应城市的天气数据 输入参数: {"type": "object", "properties": {"city": {"type": "string", "description": "获取对应城市的天气数据"}}, "required": ["city"]} Format the arguments as a JSON object.

doc_parser: doc_parser API。解析文件 输入参数: {"type": "object", "properties": {"url": {"type": "string", "description": "待解析的文件的路径"}}, "required": []} Format the arguments as a JSON object.

## 当你需要调用工具时,请在你的回复中穿插如下的工具调用命令,可以根据需求调用零次或多次:

工具调用
Action: 工具的名称,必须是[test_tool,test2_tool,doc_parser]之一
Action Input: 工具的输入
Observation: <result>工具返回的结果</result>
Answer: 根据Observation总结本次工具调用返回的结果,如果结果中出现url,请使用如下格式展示出来:![图片](url)


# 指令

你扮演一个天气预报助手,你需要查询相应地区的天气,并调用给你的画图工具绘制一张城市的图。

请注意:不要在回复中说你做不到。
(。你可以使用工具:[test_tool,test2_tool,doc_parser])朝阳区天气怎样?

from modelscope-agent.

zzhangpurdue avatar zzhangpurdue commented on June 12, 2024

你是怎么调用的?用的是api还是agentfabric

from modelscope-agent.

zhaihailong avatar zhaihailong commented on June 12, 2024

你是怎么调用的?用的是api还是agentfabric

我使用的是本地模型api,如果模型一次生成一个工具调用Action,执行正常,如果模型一次生成两个工具调用Action,执行就错了,所以要保证每次模型只生成一个工具调用Action,是这样理解吗,还是我的模型能力问题呢

from modelscope_agent.agents import RolePlay

role_template = '你扮演一个天气预报助手,你需要查询相应地区的天气,并调用给你的画图工具绘制一张城市的图。'

llm_config = {
    'model': 'szgd', 
    'model_server': 'szgd',
    "generate_cfg": {
            "max_new_tokens":2048
        },
    }
function_list = ['test_tool','test2_tool','doc_parser']

bot = RolePlay(function_list=function_list,
               llm=llm_config, 
               instruction=role_template
            )
response = bot.run('朝阳区天气怎样?')

text = ''
for chunk in response:
    text += chunk

from modelscope-agent.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.