hiyouga / LLaMA-Factory

Unify Efficient Fine-Tuning of 100+ LLMs
Apache License 2.0
25.26k stars 3.13k forks source link

请教多轮工具调用的数据格式 #4548

Closed lwj2001 closed 2 days ago

lwj2001 commented 3 days ago

Reminder

System Info

关于有调用次序的工具,这类数据的组成格式(也就是第二个工具执行需要第一个工具返回的结果),我有以下两种想法,请问哪种是更好的呢?

Reproduction

{
    "conversations": [
        {
            "from": "human",
            "value": "请帮我查询2024年1月20日,北京的天气情况,并根据天气推荐适合的户外活动"
        },
        {
            "from": "function_call",
            "value": "{\"name\": \"get_weather\", \"arguments\": {\"location\": \"北京\", \"date\": \"2024-01-20\"}}"
        },
        {
            "from": "observation",
            "value": "{\"weather\": \"晴,气温-5℃至5℃\"}"
        },
        {
            "from": "gpt",
            "value": "2024年1月20日,北京的天气情况为:晴,气温-5℃至5℃。"
        },
        {
            "from": "human",
            "value": "根据这个天气情况,有哪些适合的户外活动?"
        },
        {
            "from": "function_call",
            "value": "{\"name\": \"recommend_outdoor_activities\", \"arguments\": {\"weather\": \"晴,气温-5℃至5℃\"}}"
        },
        {
            "from": "observation",
            "value": "{\"activities\": [\"散步\", \"跑步\", \"骑自行车\"]}"
        },
        {
            "from": "gpt",
            "value": "根据2024年1月20日的天气情况,适合的户外活动包括:散步、跑步和骑自行车。"
        }
    ],
    "tools": "xxxx"
}
{
    "conversations":
    [
        {
            "from": "human",
            "value": "请帮我查询从2024年1月20日,从北京出发前往上海的航班,并给出对应的票价"
        },
        {
            "from": "function_call",
            "value": "{\"name\": \"get_flight_number\", \"arguments\": {\"departure\": \"北京\", \"destination\": \"上海\", \"date\": \"2024-01-20\"}}"
        },
        {
            "from": "observation",
            "value": "{\"flight_number\": \"1234\"}"
        },
        {
            "from": "function_call",
            "value": "{\"name\": \"get_ticket_price\", \"arguments\": {\"flight_number\": \"1234\", \"date\": \"2024-01-20\"}}"
        },
        {
            "from": "observation",
            "value": "{\"ticket_price\": \"1000\"}"
        },
        {
            "from": "gpt",
            "value": "航班1234在2024年1月20日的票价为1000元。"
        }
    ],
    "tools": "xxxx"
}

Expected behavior

No response

Others

No response