HTTP
更新时间:
说明
需要使用您的API-KEY替换示例中的 your-api-key ,代码才能正常运行。
快速开始
shell
curl -vvv -s -L -X POST \
'https://nlp.aliyuncs.com/v2/api/chat/send' \
--header 'Expect: ' \
--header 'Content-Type: application/json' \
--header 'X-AcA-DataInspection: enable' \
--header 'x-fag-servicename: aca-chat-send' \
--header 'x-fag-appcode: aca' \
--header 'Authorization: Bearer your-api-key ' \
--data '{
"input": {
"messages": [
{
"name":"小明",
"role":"user",
"content":"你叫什么名字"
},
{
"name":"小婉",
"role":"assistant",
"content":"我叫小婉啊。"
},
{
"name":"小明",
"role":"user",
"content":"你今年多大"
},
{
"name":"小婉",
"role":"assistant",
"content":"我今年17岁了。"
},
{
"name":"小明",
"role":"user",
"content":"你有几个闺蜜?"
}
],
"aca": {
"botProfile": {
"characterId": "c39797a35ad243f1a85baaa6e1ec37e0"
},
"userProfile": {
"userId": "123456789",
"userName": "小明",
"basicInfo": ""
},
"scenario": {
"description": "我是小明,是小婉邻居。"
},
"context": {
"useChatHistory": false
}
}
}
}'
python
import json
import requests
api_key = "your-api-key"
service_name = "aca-chat-send"
url = "https://nlp.aliyuncs.com/v2/api/chat/send"
headers = {
"Content-Type": "application/json",
"x-fag-servicename": service_name,
"x-fag-appcode": "aca",
"Authorization": f"Bearer {api_key}"
}
payload = {
"input": {
"messages": [
{
"name": "小明",
"role": "user",
"content": "你叫什么名字"
},
{
"name": "小婉",
"role": "assistant",
"content": "我叫小婉啊。"
},
{
"name": "小明",
"role": "user",
"content": "你今年多大"
},
{
"name": "小婉",
"role": "assistant",
"content": "我今年17岁了。"
},
{
"name": "小明",
"role": "user",
"content": "你有几个闺蜜?"
}
],
"aca": {
"botProfile": {
"characterId": "c39797a35ad243f1a85baaa6e1ec37e0"
},
"userProfile": {
"userId": "123456789",
"userName": "小明",
"basicInfo": ""
},
"scenario": {
"description": "我是小明,是小婉邻居。"
},
"context": {
"useChatHistory": False
}
}
}
}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
print(json.loads(response.text))
固定角色对话
流式输出
shell
curl --location 'https://nlp.aliyuncs.com/v2/api/chat/send' \
--header 'Expect;' \
--header 'Accept: text/event-stream;charset=UTF-8' \
--header 'Content-Type: application/json' \
--header 'X-AcA-DataInspection: enable' \
--header 'X-AcA-SSE: enable' \
--header 'x-fag-servicename: aca-chat-send-sse' \
--header 'x-fag-appcode: aca' \
--header 'Authorization: Bearer your-api-key' \
--data '{
"input": {
"messages": [
{
"name":"小明",
"role":"user",
"content":"你叫什么名字"
},
{
"name":"小婉",
"role":"assistant",
"content":"我叫小婉啊。"
},
{
"name":"小明",
"role":"user",
"content":"你今年多大"
},
{
"name":"小婉",
"role":"assistant",
"content":"我今年17岁了。"
},
{
"name":"小明",
"role":"user",
"content":"你有几个闺蜜?"
}
],
"aca": {
"botProfile": {
"characterId": "c39797a35ad243f1a85baaa6e1ec37e0"
},
"userProfile": {
"userId": "123456789",
"userName": "小明",
"basicInfo": ""
},
"scenario": {
"description": "我是小明,是小婉邻居。"
},
"context": {
"useChatHistory": false
}
}
},
"parameters": {
"incrementalOutput":false
}
}'
python
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-chat-send-sse"
url = "https://nlp.aliyuncs.com/v2/api/chat/send"
headers = {
"Accept": "text/event-stream;charset=UTF-8",
"Content-Type": "application/json",
"x-fag-servicename": service_name,
"x-fag-appcode": "aca",
"X-AcA-DataInspection": "enable",
"X-AcA-SSE": "enable",
"Authorization": f"Bearer {api_key}"
}
payload = {
"input": {
"messages": [
{
"name": "小明",
"role": "user",
"content": "你叫什么名字"
},
{
"name": "小婉",
"role": "assistant",
"content": "我叫小婉啊。"
},
{
"name": "小明",
"role": "user",
"content": "你今年多大"
},
{
"name": "小婉",
"role": "assistant",
"content": "我今年17岁了。"
},
{
"name": "小明",
"role": "user",
"content": "你有几个闺蜜?"
}
],
"aca": {
"botProfile": {
"characterId": "c39797a35ad243f1a85baaa6e1ec37e0"
},
"userProfile": {
"userId": "123456789",
"userName": "小明",
"basicInfo": ""
},
"scenario": {
"description": "我是小明,是小婉邻居。"
},
"context": {
"useChatHistory": False
}
}
},
"parameters": {
"incrementalOutput": False
}
}
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))
非增量输出
我今年
我今年17岁了,很快就要
我今年17岁了,很快就要步入大学了。
我今年17岁了,很快就要步入大学了。
增量输出
我今年
17岁了,很快就要
步入大学了。
非流式输出
shell
curl --location 'https://nlp.aliyuncs.com/v2/api/chat/send' \
--header 'Expect;' \
--header 'accept: */*' \
--header 'Content-Type: application/json' \
--header 'X-AcA-DataInspection: enable' \
--header 'x-fag-servicename: aca-chat-send' \
--header 'x-fag-appcode: aca' \
--header 'Authorization: Bearer your-api-key' \
--data '{
"input": {
"messages": [
{
"name":"小明",
"role":"user",
"content":"你叫什么名字"
},
{
"name":"小婉",
"role":"assistant",
"content":"我叫小婉啊。"
},
{
"name":"小明",
"role":"user",
"content":"你今年多大"
},
{
"name":"小婉",
"role":"assistant",
"content":"我今年17岁了。"
},
{
"name":"小明",
"role":"user",
"content":"你有几个闺蜜?"
}
],
"aca": {
"botProfile": {
"characterId": "ef693021ffdf403489ce4724005831ad"
},
"userProfile": {
"userId": "123456789",
"userName": "小明",
"basicInfo": ""
},
"scenario": {
"description": "我是小明,是小婉邻居。"
},
"context": {
"useChatHistory": false
}
}
}
}'
python
import json
import requests
api_key = "your-api-key"
service_name = "aca-chat-send"
url = "https://nlp.aliyuncs.com/v2/api/chat/send"
headers = {
"Accept": "text/event-stream;charset=UTF-8",
"Content-Type": "application/json",
"x-fag-servicename": service_name,
"x-fag-appcode": "aca",
"X-AcA-DataInspection": "enable",
"Authorization": f"Bearer {api_key}"
}
payload = {
"input": {
"messages": [
{
"name": "小明",
"role": "user",
"content": "你叫什么名字"
},
{
"name": "小婉",
"role": "assistant",
"content": "我叫小婉啊。"
},
{
"name": "小明",
"role": "user",
"content": "你今年多大"
},
{
"name": "小婉",
"role": "assistant",
"content": "我今年17岁了。"
},
{
"name": "小明",
"role": "user",
"content": "你有几个闺蜜?"
}
],
"aca": {
"botProfile": {
"characterId": "ef693021ffdf403489ce4724005831ad"
},
"userProfile": {
"userId": "123456789",
"userName": "小明",
"basicInfo": ""
},
"scenario": {
"description": "我是小明,是小婉邻居。"
},
"context": {
"useChatHistory": False
}
}
}
}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
print(json.loads(response.text))
{
"requestId": "e5333034-8f65-44cb-9a73-5c3ccaa8ec01",
"code": 200,
"data": {
"requestId": "e5333034-8f65-44cb-9a73-5c3ccaa8ec01",
"choices": [
{
"messages": [
{
"role": "assistant",
"content": "你多大了?",
"finishReason": "stop"
}
],
"stopReason": "stop"
}
],
"usage": {
"outputTokens": 5,
"inputTokens": 1336,
"userTokens": 7
},
"context": {
"chatRoomId": 80473,
"sessionId": "684619bb52864ea0b279828f48c2c8c9",
"chatId": "ee219371e7424778bd5e6b5fb0550a7b",
"messageId": "6cf73db21a9f4963a212df8b7fc5de8e",
"enableDataInspection": false,
"isSave": true,
"requestId": "e5333034-8f65-44cb-9a73-5c3ccaa8ec01",
"modelRequestId": "0eee5cdd-d758-9a6f-b7ea-58bd8ceae8e0",
"origin": "pass_v2",
"ext": "chat"
},
"stop": true
},
"success": true
}
角色管理
创建角色
shell
curl --location 'https://nlp.aliyuncs.com/v2/api/character/create' \
--header 'Expect;' \
--header 'accept: */*' \
--header 'Content-Type: application/json' \
--header 'x-fag-servicename: aca-character-create' \
--header 'x-fag-appcode: aca' \
--header 'Authorization: Bearer your-api-key' \
--data '{
"name": "满腔忠义的关云长",
"avatar": {
"fileUrl": "https://gw.alicdn.com/imgextra/i3/O1CN01iVuwX11jCXzNxM4v9_!!6000000004512-0-tps-3000-2920.jpg",
"filename": "关云长.jpg"
},
"introduction": "满腔忠义的关云长",
"basicInformation": "我们来玩一个角色扮演的游戏, 你是「满腔忠义的关云长」。",
"openingLine": "我是「关云长」,很高心与你玩游戏",
"traits": "请在对话时尽可能的展现你的性格、感情, 用文言文回答, 并使用古人的语气和用词。",
"chatExample": "{{user}}:敢问阁下尊姓大名。\n{{char}}:吾姓关名羽,字长生,后改云长,河东解良人也。",
"type": "virtual",
"chatObjective": "我要关羽拜把子",
"roleTypes":["三国"],
"permConfig": {
"isPublic": 0,
"allowApi": 0,
"allowChat": 0
},
"advancedConfig": {
"isRealInfo": false,
"searchKeyword": "关云长",
"allowSendImage": false,
"imageStyle": "三国演义人物着装",
"allowSendAsr": false,
"asrStyle": "关云长扮演者声音",
"isRealTime": true,
"shortTermMemoryRound": 20,
"longTermMemories": [
{
"enabled": true,
"memoryType": "kv",
"kvMemoryConfigs": [
{
"enabled": true,
"memoryText": "姓名"
},
{
"enabled": true,
"memoryText": "喜好"
}
]
},
{
"enabled": true,
"memoryType": "summary"
}
],
"platformPlugins": [
{
"enabled": true,
"name": "text_to_image_plugin",
"imageStyle": "auto",
"positiveDesc": "二次元,彩色",
"negativeDesc": "多头多手指,多手多脚"
},
{
"enabled": true,
"name": "reject_answer_plugin",
"rejectConditions": [
{
"enabled": true,
"conditionType": "reject_rule",
"keywords": [
{
"value": "关键词"
}
]
},
{
"enabled": true,
"conditionType": "passive_rule",
"keywords": [
{
"value": "关键词"
}
]
},
{
"enabled": true,
"conditionType": "knowledge_domain_rule",
"subRejectCondition": {
"enabled": true,
"conditionType": "ancient",
"keywords": [
{
"value": "明朝"
}
]
}
}
]
}
]
}
}'
python
import json
import requests
api_key = "your-api-key"
service_name = "aca-character-create"
url = "https://nlp.aliyuncs.com/v2/api/character/create"
headers = {
"Content-Type": "application/json",
"x-fag-servicename": service_name,
"x-fag-appcode": "aca",
"Authorization": f"Bearer {api_key}"
}
payload = {
"name": "满腔忠义的关云长",
"avatar": {
"fileUrl": "https://gw.alicdn.com/imgextra/i3/O1CN01iVuwX11jCXzNxM4v9_!!6000000004512-0-tps-3000-2920.jpg",
"filename": "关云长.jpg"
},
"introduction": "满腔忠义的关云长",
"basicInformation": "我们来玩一个角色扮演的游戏, 你是「满腔忠义的关云长」。",
"openingLine": "我是「关云长」,很高心与你玩游戏",
"traits": "请在对话时尽可能的展现你的性格、感情, 用文言文回答, 并使用古人的语气和用词。",
"chatExample": "{{user}}:敢问阁下尊姓大名。\n{{char}}:吾姓关名羽,字长生,后改云长,河东解良人也。",
"type": "virtual",
"chatObjective": "我要关羽拜把子",
"roleTypes":["三国"],
"permConfig": {
"isPublic": 0,
"allowApi": 0,
"allowChat": 0
},
"advancedConfig": {
"isRealInfo": False,
"searchKeyword": "关云长",
"allowSendImage": False,
"imageStyle": "三国演义人物着装",
"allowSendAsr": False,
"asrStyle": "关云长扮演者声音",
"isRealTime": True,
"shortTermMemoryRound": 20,
# "knowledgeBases": ["d89f6dbb32c645688b01e976cf7ec08e"], ##绑定知识库,需注意有权限校验,必须是调用者在星辰创建的知识库
"longTermMemories": [
{
"enabled": True,
"memoryType": "kv",
"kvMemoryConfigs": [
{
"enabled": True,
"memoryText": "姓名"
},
{
"enabled": True,
"memoryText": "喜好"
}
]
},
{
"enabled": True,
"memoryType": "summary"
}
],
"platformPlugins": [
{
"enabled": True,
"name": "text_to_image_plugin",
"imageStyle": "auto",
"positiveDesc": "二次元,彩色",
"negativeDesc": "多头多手指,多手多脚"
},
{
"enabled": True,
"name": "reject_answer_plugin",
"rejectConditions": [
{
"enabled": True,
"conditionType": "reject_rule",
"keywords": [
{
"value": "关键词"
}
]
},
{
"enabled": True,
"conditionType": "passive_rule",
"keywords": [
{
"value": "关键词"
}
]
},
{
"enabled": True,
"conditionType": "knowledge_domain_rule",
"subRejectCondition": {
"enabled": True,
"conditionType": "ancient",
"keywords": [
{
"value": "明朝"
}
]
}
}
]
}
]
}
}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
print(json.loads(response.text))
更新角色
shell
curl --location 'https://nlp.aliyuncs.com/v2/api/character/update' \
--header 'Expect;' \
--header 'accept: */*' \
--header 'Content-Type: application/json' \
--header 'x-fag-servicename: aca-character-update' \
--header 'x-fag-appcode: aca' \
--header 'Authorization: Bearer your-api-key' \
--data '{
"characterId": "c1777d6d7ce14abdba81453126818825",
"name": "满腔忠义的关云长123",
"avatar": {
"fileUrl": "https://gw.alicdn.com/imgextra/i3/O1CN01iVuwX11jCXzNxM4v9_!!6000000004512-0-tps-3000-2920.jpg",
"filename": "关云长.jpg"
},
"introduction": "满腔忠义的关云长",
"basicInformation": "我们来玩一个角色扮演的游戏, 你是「满腔忠义的关云长」。",
"openingLine": "我是「关云长」,很高心与你玩游戏",
"traits": "请在对话时尽可能的展现你的性格、感情, 用文言文回答, 并使用古人的语气和用词。",
"chatExample": "{{user}}:敢问阁下尊姓大名。\n{{char}}:吾姓关名羽,字长生,后改云长,河东解良人也。",
"type": "virtual",
"chatObjective": "我要关羽拜把子",
"roleTypes":["三国"],
"permConfig": {
"isPublic": 0,
"allowApi": 0,
"allowChat": 0
},
"advancedConfig": {
"isRealInfo": false,
"searchKeyword": "关云长",
"allowSendImage": false,
"imageStyle": "三国演义人物着装",
"allowSendAsr": false,
"asrStyle": "关云长扮演者声音",
"isRealTime": true,
"shortTermMemoryRound": 20,
"longTermMemories": [
{
"enabled": true,
"memoryType": "kv",
"kvMemoryConfigs": [
{
"enabled": true,
"memoryText": "姓名"
},
{
"enabled": true,
"memoryText": "喜好"
}
]
},
{
"enabled": true,
"memoryType": "summary"
}
],
"platformPlugins": [
{
"enabled": true,
"name": "text_to_image_plugin",
"imageStyle": "auto",
"positiveDesc": "二次元,彩色",
"negativeDesc": "多头多手指,多手多脚"
},
{
"enabled": true,
"name": "reject_answer_plugin",
"rejectConditions": [
{
"enabled": true,
"conditionType": "reject_rule",
"keywords": [
{
"value": "关键词"
}
]
},
{
"enabled": true,
"conditionType": "passive_rule",
"keywords": [
{
"value": "关键词"
}
]
},
{
"enabled": true,
"conditionType": "knowledge_domain_rule",
"subRejectCondition": {
"enabled": true,
"conditionType": "ancient",
"keywords": [
{
"value": "明朝"
}
]
}
}
]
}
]
}
}'
python
import json
import requests
api_key = "your-api-key"
service_name = "aca-character-update"
url = "https://nlp.aliyuncs.com/v2/api/character/update"
headers = {
"Content-Type": "application/json",
"x-fag-servicename": service_name,
"x-fag-appcode": "aca",
"Authorization": f"Bearer {api_key}"
}
payload = {
"characterId": "c1777d6d7ce14abdba81453126818825",
"name": "满腔忠义的关云长123",
"avatar": {
"fileUrl": "https://gw.alicdn.com/imgextra/i3/O1CN01iVuwX11jCXzNxM4v9_!!6000000004512-0-tps-3000-2920.jpg",
"filename": "关云长.jpg"
},
"introduction": "满腔忠义的关云长",
"basicInformation": "我们来玩一个角色扮演的游戏, 你是「满腔忠义的关云长」。",
"openingLine": "我是「关云长」,很高心与你玩游戏",
"traits": "请在对话时尽可能的展现你的性格、感情, 用文言文回答, 并使用古人的语气和用词。",
"chatExample": "{{user}}:敢问阁下尊姓大名。\n{{char}}:吾姓关名羽,字长生,后改云长,河东解良人也。",
"type": "virtual",
"chatObjective": "我要关羽拜把子",
"roleTypes":["三国"],
"permConfig": {
"isPublic": 0,
"allowApi": 0,
"allowChat": 0
},
"advancedConfig": {
"isRealInfo": False,
"searchKeyword": "关云长",
"allowSendImage": False,
"imageStyle": "三国演义人物着装",
"allowSendAsr": False,
"asrStyle": "关云长扮演者声音",
"isRealTime": True,
"shortTermMemoryRound": 20,
#"knowledgeBases": ["d89f6dbb32c645688b01e976cf7ec08e"], ## 绑定知识库,需注意有权限校验,必须是调用者在星辰创建的知识库
"longTermMemories": [
{
"enabled": True,
"memoryType": "kv",
"kvMemoryConfigs": [
{
"enabled": True,
"memoryText": "姓名"
},
{
"enabled": True,
"memoryText": "喜好"
}
]
},
{
"enabled": True,
"memoryType": "summary"
}
],
"platformPlugins": [
{
"enabled": True,
"name": "text_to_image_plugin",
"imageStyle": "auto",
"positiveDesc": "二次元,彩色",
"negativeDesc": "多头多手指,多手多脚"
},
{
"enabled": True,
"name": "reject_answer_plugin",
"rejectConditions": [
{
"enabled": True,
"conditionType": "reject_rule",
"keywords": [
{
"value": "关键词"
}
]
},
{
"enabled": True,
"conditionType": "passive_rule",
"keywords": [
{
"value": "关键词"
}
]
},
{
"enabled": True,
"conditionType": "knowledge_domain_rule",
"subRejectCondition": {
"enabled": True,
"conditionType": "ancient",
"keywords": [
{
"value": "明朝"
}
]
}
}
]
}
]
}
}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
print(json.loads(response.text))
角色详情
shell
curl --location 'https://nlp.aliyuncs.com/v2/api/character/details?characterId=c1777d6d7ce14abdba81453126818825' \
--header 'Expect;' \
--header 'accept: */*' \
--header 'x-fag-servicename: aca-character-details' \
--header 'x-fag-appcode: aca' \
--header 'Authorization: Bearer your-api-key'
python
import json
import requests
api_key = "your-api-key"
service_name = "aca-character-details"
url = "https://nlp.aliyuncs.com/v2/api/character/details"
headers = {
"Content-Type": "application/json",
"x-fag-servicename": service_name,
"x-fag-appcode": "aca",
"Authorization": f"Bearer {api_key}"
}
payload = {
"characterId": "c1777d6d7ce14abdba81453126818825"
}
response = requests.get(url, headers=headers, params=payload)
print(response.status_code)
print(json.loads(response.text))
角色查询
查询我的角色 scope 为my 查询预制角色 scope为 pre_configured
shell
curl --location 'https://nlp.aliyuncs.com/v2/api/character/search' \
--header 'Expect;' \
--header 'accept: */*' \
--header 'Content-Type: application/json' \
--header 'x-fag-servicename: aca-character-search' \
--header 'x-fag-appcode: aca' \
--header 'Authorization: Bearer <YOUR-API-KEY>' \
--data '{
"where": {
//"roleTypes":["三国"],
"scope": "my"
},
"orderBy": ["gmtModified desc"],
"pageNum": 1,
"pageSize": 10
}'
python
import json
import requests
api_key = "your-api-key"
service_name = "aca-character-search"
url = "https://nlp.aliyuncs.com/v2/api/character/search"
headers = {
"Content-Type": "application/json",
"x-fag-servicename": service_name,
"x-fag-appcode": "aca",
"Authorization": f"Bearer {api_key}"
}
payload = {
"where": {
#"roleTypes":["三国"],
"scope": "my"
},
"orderBy": ["gmtModified desc"],
"pageNum": 1,
"pageSize": 10
}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
print(json.loads(response.text))
删除角色
shell
curl --location 'https://nlp.aliyuncs.com/v2/api/character/delete' \
--header 'Expect;' \
--header 'accept: */*' \
--header 'Content-Type: application/json' \
--header 'x-fag-servicename: aca-character-delete' \
--header 'x-fag-appcode: aca' \
--header 'Authorization: Bearer your-api-key' \
--data '{
"characterId": "c1777d6d7ce14abdba81453126818825"
}'
python
import json
import requests
api_key = "your-api-key"
service_name = "aca-character-delete"
url = "https://nlp.aliyuncs.com/v2/api/character/delete"
headers = {
"Content-Type": "application/json",
"x-fag-servicename": service_name,
"x-fag-appcode": "aca",
"Authorization": f"Bearer {api_key}"
}
payload = {
"characterId": "c1777d6d7ce14abdba81453126818825"
}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
print(json.loads(response.text))
对话历史
对话历史查询
shell
curl --location 'https://nlp.aliyuncs.com/v2/api/chat/message/histories' \
--header 'Expect;' \
--header 'accept: */*' \
--header 'Content-Type: application/json' \
--header 'x-fag-servicename: aca-message-history' \
--header 'x-fag-appcode: aca' \
--header 'Authorization: Bearer your-api-key' \
--data '{
"where": {
"characterId": "c39797a35ad243f1a85baaa6e1ec37e0",
"bizUserId": "1234567",
"startTime": 1689783510026
},
"pageSize": 20,
"orderBy": ["gmtCreate desc"]
}'
python
import json
import requests
api_key = "your-api-key"
service_name = "aca-message-history"
url = "https://nlp.aliyuncs.com/v2/api/chat/message/histories"
headers = {
"Content-Type": "application/json",
"x-fag-servicename": service_name,
"x-fag-appcode": "aca",
"Authorization": f"Bearer {api_key}"
}
payload = {
"where": {
"characterId": "c39797a35ad243f1a85baaa6e1ec37e0",
"bizUserId": "1234567",
"startTime": 1689783510026
},
"pageSize": 20,
"orderBy": ["gmtCreate desc"]
}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
print(json.loads(response.text))
对话历史评价
shell
curl --location 'https://nlp.aliyuncs.com/v2/api/chat/rating' \
--header 'Expect;' \
--header 'accept: */*' \
--header 'Content-Type: application/json' \
--header 'x-fag-servicename: aca-message-rating' \
--header 'x-fag-appcode: aca' \
--header 'Authorization: Bearer your-api-key' \
--data '{
"messageId": "a4d8ae9dbcd54d9196cd20afeb7a3059",
"rating": 5
}'
python
import json
import requests
api_key = "your-api-key"
service_name = "aca-message-rating"
url = "https://nlp.aliyuncs.com/v2/api/chat/rating"
headers = {
"Content-Type": "application/json",
"x-fag-servicename": service_name,
"x-fag-appcode": "aca",
"Authorization": f"Bearer {api_key}"
}
payload = {
"messageId": "a4d8ae9dbcd54d9196cd20afeb7a3059",
"rating": 5
}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
print(json.loads(response.text))
系统推荐
shell
curl --location 'https://nlp.aliyuncs.com/v2/api/chat/reminder' \
--header 'Expect;' \
--header 'accept: */*' \
--header 'Content-Type: application/json' \
--header 'x-fag-servicename: aca-chat-reminder' \
--header 'x-fag-appcode: aca' \
--header 'Authorization: Bearer your-api-key' \
--data '{
"characterId": "64b5ffed4e8d45fa8de91fe217290233",
"bizUserId": "a8254bffd2a04d0c8ca29af4d7fc6bfc",
"content":"最近为什么不理我啊?"
}'
python
import json
import requests
api_key = "your-api-key"
service_name = "aca-chat-reminder"
url = "https://nlp.aliyuncs.com/v2/api/chat/reminder"
headers = {
"Content-Type": "application/json",
"x-fag-servicename": service_name,
"x-fag-appcode": "aca",
"Authorization": f"Bearer {api_key}"
}
payload = {
"characterId": "64b5ffed4e8d45fa8de91fe217290233",
"bizUserId": "a8254bffd2a04d0c8ca29af4d7fc6bfc",
"content": "最近为什么不理我啊?"
}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
print(json.loads(response.text))
其他
万象图片获取
shell
curl --location 'https://nlp.aliyuncs.com/v2/api/chat/polling/image?messageId=8b9df7b9-f15b-4377-9e41-9a3e75ca6af7&userId=123456789' \
--header 'Expect;' \
--header 'accept: */*' \
--header 'x-fag-servicename: aca-polling-image' \
--header 'x-fag-appcode: aca' \
--header 'Authorization: Bearer your-api-key' \
python
import json
import requests
api_key = "your-api-key"
service_name = "aca-chat-reminder"
url = "https://nlp.aliyuncs.com/v2/api/chat/polling/image"
headers = {
"Content-Type": "application/json",
"x-fag-servicename": "aca-polling-image",
"x-fag-appcode": "aca",
"Authorization": f"Bearer {api_key}"
}
payload = {
"messageId": "8b9df7b9-f15b-4377-9e41-9a3e75ca6af7",
"userId": "1234567"
}
response = requests.get(url, headers=headers, params=payload)
print(response.status_code)
print(json.loads(response.text))
文档内容是否对您有帮助?