日本熟妇hd丰满老熟妇,中文字幕一区二区三区在线不卡 ,亚洲成片在线观看,免费女同在线一区二区

HTTP

更新時間:

Shell

工具調(diào)用請求示例

curl --location 'https://nlp.aliyuncs.com/v2/api/completions' \
--header 'Content-Type: application/json' \
--header 'X-AcA-DataInspection: enable' \
--header 'x-fag-servicename: aca-completion' \
--header 'x-fag-appcode: aca' \
--header 'Authorization: Bearer {YOUR_API_KEY}' \
--data '{
            "model": "xingchen-plus-v2",
            "user": "tester01",
            "max_tokens": 100,
            "stream": true,
            "messages":
            [
                {
                    "name": "小義",
                    "role": "system",
                    "content": "你是一個對話Agent,你可以訪問以下API,請自動規(guī)劃當前最必要的API調(diào)用,盡你所能為用戶提供幫助。"
                },
                {
                    "role": "user",
                    "content": "今天杭州天氣怎么樣"
                }
            ],
            "tools":
            [
                {
                    "id": "001",
                    "type": "function",
                    "function":
                    {
                        "name": "weather",
                        "description": "通過調(diào)用天氣預報API獲取當?shù)靥鞖忸A報信息通過調(diào)用天氣預報API獲取當?shù)靥鞖忸A報信息",
                        "parameters":
                        {
                            "type": "object",
                            "properties":
                            {
                                "location":
                                {
                                    "type": "string",
                                    "description": "地點"
                                },
                                "format":
                                {
                                    "type": "string",
                                    "enum":
                                    [
                                        "celsius",
                                        "fahrenheit"
                                    ],
                                    "description": "溫度單位"
                                }
                            },
                            "required":
                            [
                                "location",
                                "format"
                            ]
                        }
                    }
                }
            ]
        }'

工具調(diào)用響應示例

{
    "id": "414add7c-8c15-42e8-a53c-8bdfe80e2bd6",
    "created": 1715160819,
    "model": "xingchen-plus-v2",
    "choices":
    [
        {
            "index": 1,
            "finish_reason": "stop",
            "message":
            {
                "role": "assistant",
                "content": "",
                "tool_calls":
                [
                    {
                        "id": "001",
                        "type": "function",
                        "function":
                        {
                            "name": "weather",
                            "arguments": "{\"format\":\"celsius\",\"location\":\"杭州\"}"
                        }
                    }
                ]
            }
        }
    ],
    "usage":
    {
        "prompt_tokens": 0,
        "completion_tokens": 304,
        "total_tokens": 304
    },
    "stop": true
}

工具生成結(jié)果對話請求示例

curl --location 'https://nlp.aliyuncs.com/v2/api/completions' \
--header 'Content-Type: application/json' \
--header 'X-AcA-DataInspection: enable' \
--header 'x-fag-servicename: aca-completion' \
--header 'x-fag-appcode: aca' \
--header 'Authorization: Bearer {YOUR_API_KEY}' \
--data '{
            "model": "xingchen-plus-v2",
            "user": "tester01",
            "max_tokens": 100,
            "stream": true,
            "messages":
            [
                {
                    "name": "小義",
                    "role": "system",
                    "content": "你是一個對話Agent,你可以訪問以下API,請自動規(guī)劃當前最必要的API調(diào)用,盡你所能為用戶提供幫助。"
                },
                {
                    "role": "user",
                    "content": "今天杭州天氣怎么樣"
                },
                {
                    "role": "assistant",
                    "content": "",
                    "tool_calls":
                    [
                        {
                            "id": "weather",
                            "type": "function",
                            "function":
                            {
                                "name": "weather",
                                "arguments": "{\"format\":\"celsius\",\"location\":\"杭州\"}"
                            }
                        }
                    ]
                },
                {
                    "tool_call_id":"001",
                    "role": "tool",
                    "content": "{\"location\": \"杭州\", \"temperature\": \"25\", \"unit\": \"celsius\", \"forecast\": \"sunny\"}"
                }
            ],
            "tools":
            [
                {
                    "id": "001",
                    "type": "function",
                    "function":
                    {
                        "name": "weather",
                        "description": "通過調(diào)用天氣預報API獲取當?shù)靥鞖忸A報信息通過調(diào)用天氣預報API獲取當?shù)靥鞖忸A報信息",
                        "parameters":
                        {
                            "type": "object",
                            "properties":
                            {
                                "location":
                                {
                                    "type": "string",
                                    "description": "地點"
                                },
                                "format":
                                {
                                    "type": "string",
                                    "enum":
                                    [
                                        "celsius",
                                        "fahrenheit"
                                    ],
                                    "description": "溫度單位"
                                }
                            },
                            "required":
                            [
                                "location",
                                "format"
                            ]
                        }
                    }
                }
            ]
        }'

工具調(diào)用結(jié)果對話回復

{
    "id": "4feaf99f-61b1-4824-85bf-f9a4265c6e13",
    "created": 1715166710,
    "model": "xingchen-plus-v2",
    "choices":
    [
        {
            "index": 1,
            "finish_reason": "stop",
            "message":
            {
                "role": "assistant",
                "content": "今天的杭州天氣格外晴朗,溫度是25攝氏度,真是個出門游玩的好日子呢!",
                "tool_calls":
                []
            }
        }
    ],
    "usage":
    {
        "prompt_tokens": 222,
        "completion_tokens": 23,
        "total_tokens": 275
    },
    "stop": true
}

Python

工具調(diào)用請求示例

import json

import requests


def handle_stream(response: requests.Response):
    is_error = False
    for line in response.iter_lines():
        if line:
            line = line.decode('utf8').rstrip('\n').rstrip('\r')
            if line.startswith('event:error'):
                is_error = True
            elif line.startswith('data:'):
                line = line[len('data:'):]
                yield is_error, line
                if is_error:
                    break


api_key = "{YOUR_API_KEY}"
service_name = "aca-completion"

url = "https://nlp.aliyuncs.com/v2/api/completions"
headers = {
    "Content-Type": "application/json",
    "X-AcA-DataInspection": "enable",
    "x-fag-servicename": service_name,
    "x-fag-appcode": "aca",
    "Authorization": "Bearer " + api_key
}
payload = {
    "model": "xingchen-plus-v2",
    "user": "tester01",
    "max_tokens": 100,
    "stream": True,
    "messages":
        [
            {
                "name": "小義",
                "role": "system",
                "content": "你是一個對話Agent,你可以訪問以下API,請自動規(guī)劃當前最必要的API調(diào)用,盡你所能為用戶提供幫助。"
            },
            {
                "role": "user",
                "content": "今天杭州天氣怎么樣"
            }
        ],
    "tools":
        [
            {
                "id": "001",
                "type": "function",
                "function":
                    {
                        "name": "weather",
                        "description": "通過調(diào)用天氣預報API獲取當?shù)靥鞖忸A報信息通過調(diào)用天氣預報API獲取當?shù)靥鞖忸A報信息",
                        "parameters":
                            {
                                "type": "object",
                                "properties":
                                    {
                                        "location":
                                            {
                                                "type": "string",
                                                "description": "地點"
                                            },
                                        "format":
                                            {
                                                "type": "string",
                                                "enum":
                                                    [
                                                        "celsius",
                                                        "fahrenheit"
                                                    ],
                                                "description": "溫度單位"
                                            }
                                    },
                                "required":
                                    [
                                        "location",
                                        "format"
                                    ]
                            }
                    }
            }
        ]
}

response = requests.post(url, headers=headers, json=payload, stream=True)

for is_error, resp in handle_stream(response):
    if is_error:
        break
    print(json.loads(resp))
    

工具調(diào)用結(jié)果示例

{'id': 'bde6e7facdc604cc29a6f0041f1a42a7', 'created': 1715237728, 'model': 'xingchen-plus', 'choices': [{'index': 1, 'finish_reason': 'stop', 'message': {'role': 'assistant', 'content': '', 'tool_calls': [{'id': '001', 'type': 'function', 'function': {'name': 'weather', 'arguments': '{"format":"celsius","location":"杭州"}'}}]}}], 'usage': {'prompt_tokens': 0, 'completion_tokens': 297, 'total_tokens': 297}, 'stop': True}

工具生成結(jié)果對話請求示例

import json

import requests


def handle_stream(response: requests.Response):
    is_error = False
    for line in response.iter_lines():
        if line:
            line = line.decode('utf8').rstrip('\n').rstrip('\r')
            if line.startswith('event:error'):
                is_error = True
            elif line.startswith('data:'):
                line = line[len('data:'):]
                yield is_error, line
                if is_error:
                    break


api_key = "{YOUR_API_KEY}"
service_name = "aca-completion"

url = "https://nlp.aliyuncs.com/v2/api/completions"
headers = {
    "Content-Type": "application/json",
    "X-AcA-DataInspection": "enable",
    "x-fag-servicename": service_name,
    "x-fag-appcode": "aca",
    "Authorization": "Bearer " + api_key
}
payload = {
    "model": "xingchen-plus-v2",
    "user": "tester01",
    "max_tokens": 100,
    "stream": True,
    "messages":
        [
            {
                "name": "小義",
                "role": "system",
                "content": "你是一個對話Agent,你可以訪問以下API,請自動規(guī)劃當前最必要的API調(diào)用,盡你所能為用戶提供幫助。"
            },
            {
                "role": "user",
                "content": "今天杭州天氣怎么樣"
            },
            {
                "role": "assistant",
                "content": "",
                "tool_calls":
                    [
                        {
                            "id": "weather",
                            "type": "function",
                            "function":
                                {
                                    "name": "weather",
                                    "arguments": "{\"format\":\"celsius\",\"location\":\"杭州\"}"
                                }
                        }
                    ]
            },
            {
                "tool_call_id": "001",
                "role": "tool",
                "content": "{\"location\": \"杭州\", \"temperature\": \"25\", \"unit\": \"celsius\", \"forecast\": \"sunny\"}"
            }
        ],
    "tools":
        [
            {
                "id": "001",
                "type": "function",
                "function":
                    {
                        "name": "weather",
                        "description": "通過調(diào)用天氣預報API獲取當?shù)靥鞖忸A報信息通過調(diào)用天氣預報API獲取當?shù)靥鞖忸A報信息",
                        "parameters":
                            {
                                "type": "object",
                                "properties":
                                    {
                                        "location":
                                            {
                                                "type": "string",
                                                "description": "地點"
                                            },
                                        "format":
                                            {
                                                "type": "string",
                                                "enum":
                                                    [
                                                        "celsius",
                                                        "fahrenheit"
                                                    ],
                                                "description": "溫度單位"
                                            }
                                    },
                                "required":
                                    [
                                        "location",
                                        "format"
                                    ]
                            }
                    }
            }
        ]
}

response = requests.post(url, headers=headers, json=payload,stream=True)

for is_error, resp in handle_stream(response):
    if is_error:
        break
    print(json.loads(resp))

工具調(diào)用結(jié)果對話回復

{'id': 'ab391320db822b8756f745c5b35681a3', 'created': 1715237801, 'model': 'xingchen-plus-v2', 'choices': [{'index': 1, 'finish_reason': 'null', 'message': {'role': 'assistant', 'content': '您好', 'tool_calls': []}}], 'usage': {'prompt_tokens': 0, 'completion_tokens': 0, 'total_tokens': 0}, 'stop': False}
{'id': 'ab391320db822b8756f745c5b35681a3', 'created': 1715237801, 'model': 'xingchen-plus-v2', 'choices': [{'index': 1, 'finish_reason': 'null', 'message': {'role': 'assistant', 'content': '您好啊', 'tool_calls': []}}], 'usage': {'prompt_tokens': 0, 'completion_tokens': 0, 'total_tokens': 0}, 'stop': False}
{'id': 'ab391320db822b8756f745c5b35681a3', 'created': 1715237801, 'model': 'xingchen-plus-v2', 'choices': [{'index': 1, 'finish_reason': 'null', 'message': {'role': 'assistant', 'content': '您好啊,', 'tool_calls': []}}], 'usage': {'prompt_tokens': 0, 'completion_tokens': 0, 'total_tokens': 0}, 'stop': False}
{'id': 'ab391320db822b8756f745c5b35681a3', 'created': 1715237801, 'model': 'xingchen-plus-v2', 'choices': [{'index': 1, 'finish_reason': 'null', 'message': {'role': 'assistant', 'content': '您好啊,今天杭州的天氣很不錯', 'tool_calls': []}}], 'usage': {'prompt_tokens': 0, 'completion_tokens': 0, 'total_tokens': 0}, 'stop': False}
{'id': 'ab391320db822b8756f745c5b35681a3', 'created': 1715237801, 'model': 'xingchen-plus-v2', 'choices': [{'index': 1, 'finish_reason': 'null', 'message': {'role': 'assistant', 'content': '您好啊,今天杭州的天氣很不錯呢,氣溫是25攝氏', 'tool_calls': []}}], 'usage': {'prompt_tokens': 0, 'completion_tokens': 0, 'total_tokens': 0}, 'stop': False}
{'id': 'ab391320db822b8756f745c5b35681a3', 'created': 1715237802, 'model': 'xingchen-plus-v2', 'choices': [{'index': 1, 'finish_reason': 'null', 'message': {'role': 'assistant', 'content': '您好啊,今天杭州的天氣很不錯呢,氣溫是25攝氏度,晴朗的天氣讓人感覺', 'tool_calls': []}}], 'usage': {'prompt_tokens': 0, 'completion_tokens': 0, 'total_tokens': 0}, 'stop': False}
{'id': 'ab391320db822b8756f745c5b35681a3', 'created': 1715237802, 'model': 'xingchen-plus-v2', 'choices': [{'index': 1, 'finish_reason': 'stop', 'message': {'role': 'assistant', 'content': '您好啊,今天杭州的天氣很不錯呢,氣溫是25攝氏度,晴朗的天氣讓人感覺很舒服。', 'tool_calls': []}}], 'usage': {'prompt_tokens': 222, 'completion_tokens': 27, 'total_tokens': 279}, 'stop': True}