1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
<?php return [
'version' => '1.0',
'info' => ['style' => 'ROA', 'product' => 'EMRASSISTANT', 'version' => '2025-07-23'],
'directories' => ['ChatCompletion'],
'components' => [
'schemas' => [],
],
'apis' => [
'ChatCompletion' => [
'summary' => 'EMR AI 助手对话补全接口。接收用户的对话消息,调用 EMR 智能助手进行推理,以 SSE 流式方式逐 token 返回助手回复。支持多轮会话(通过 sessionId 续接上下文)。',
'path' => '/v1/chat/completions',
'methods' => ['post'],
'schemes' => ['https', 'sse'],
'security' => [
[
'AK' => [],
],
],
'consumes' => ['application/json'],
'produces' => ['application/octet-stream'],
'operationType' => 'readAndWrite',
'deprecated' => false,
'systemTags' => ['operationType' => 'none', 'riskType' => 'none', 'chargeType' => 'free', 'autoTest' => true, 'tenantRelevance' => 'tenant'],
'parameters' => [
[
'name' => 'stream',
'in' => 'query',
'schema' => ['description' => '是否是流式输出', 'type' => 'boolean', 'required' => false, 'example' => 'true'],
],
[
'name' => 'messages',
'in' => 'query',
'schema' => ['description' => '消息数据明细结构', 'type' => 'any', 'required' => false, 'example' => 'OpenAI Style: [{"role":"user","content":"hello"}]'],
],
[
'name' => 'sessionId',
'in' => 'query',
'schema' => ['description' => '本次对话的唯一标识', 'type' => 'string', 'required' => false, 'example' => 's-1234567'],
],
[
'name' => 'model',
'in' => 'query',
'schema' => ['description' => 'SDK 调用请忽略这个参数', 'type' => 'string', 'required' => false, 'example' => 'NONE'],
],
[
'name' => 'context',
'in' => 'query',
'schema' => ['description' => 'SDK 调用请忽略这个参数', 'type' => 'any', 'required' => false, 'example' => 'NONE'],
],
],
'responses' => [
200 => [
'schema' => ['description' => 'SSE 事件', 'type' => 'any', 'example' => 'data: {"type":"run_started","sessionId":"s-47bd30f48dfa4e9b","messageId":"7a2d3fe019184261931a5d1d62e2ecc0","RequestId":"6ACCA254-2E83-1B5A-AF65-7C8FC7F3A275"}'."\n"],
],
],
'staticInfo' => ['returnType' => 'synchronous'],
'title' => '发起对话',
'description' => '**请确保在使用该接口前,已充分了解EMR AI助手的[收费方式](https://help.aliyun.com/zh/emr/emr-on-ecs/product-overview/emr-ai)和价格。**'."\n"
."\n"
.'本接口为 流式(SSE / Server-Sent Events) 接口,响应 Content-Type: text/event-stream,以 chunked 编码持续推送事件,直到本轮回复结束。'."\n"
.'调用方需按 SSE 方式读取流(逐事件解析),不能当成一次性 JSON 响应处理。'."\n"
.'单次请求最长 300 秒(网关后端超时)。',
'requestParamsDescription' => '```json'."\n"
.'{'."\n"
.' "stream": true,'."\n"
.' "messages": ['."\n"
.' { "role": "user", "content": "EMR AI 助手能为我做什么" }'."\n"
.' ],'."\n"
.' "sessionId": "",'."\n"
.' "model": "",'."\n"
.' "context": {}'."\n"
.'}'."\n"
.'```',
'responseParamsDescription' => '```json'."\n"
.'HTTP/1.1 200 OK'."\n"
.'Content-Type: text/event-stream; charset=utf-8'."\n"
.'Transfer-Encoding: chunked'."\n"
.'Cache-Control: no-cache'."\n"
.'x-acs-request-id: 6ACCA254-2E83-1B5A-AF65-7C8FC7F3A275'."\n"
.'data: {"type":"run_started","sessionId":"s-47bd30f48dfa4e9b","messageId":"7a2d3fe019184261931a5d1d62e2ecc0","RequestId":"6ACCA254-2E83-1B5A-AF65-7C8FC7F3A275"}'."\n"
.'data: {"type":"text","messageId":"7a2d3fe019184261931a5d1d62e2ecc0","text":"您好,欢迎使用EMR智能服务。请告诉我您需要咨询或处理的具体问题,我会为您提供精准支持。\\n\\n","RequestId":"6ACCA254-2E83-1B5A-AF65-7C8FC7F3A275"}'."\n"
.'data: {"type":"text","messageId":"7a2d3fe019184261931a5d1d62e2ecc0","text":"!我是阿里","RequestId":"6ACCA254-2E83-1B5A-AF65-7C8FC7F3A275"}'."\n"
.'data: {"type":"text","messageId":"7a2d3fe019184261931a5d1d62e2ecc0","text":"云EMR","RequestId":"6ACCA254-2E83-1B5A-AF65-7C8FC7F3A275"}'."\n"
.'... (后续 text 事件逐段拼接为完整回复)'."\n"
.'```',
'changeSet' => [],
'responseDemo' => '[{"errorExample":"","example":"\\"data: {\\\\\\"type\\\\\\":\\\\\\"run_started\\\\\\",\\\\\\"sessionId\\\\\\":\\\\\\"s-47bd30f48dfa4e9b\\\\\\",\\\\\\"messageId\\\\\\":\\\\\\"7a2d3fe019184261931a5d1d62e2ecc0\\\\\\",\\\\\\"RequestId\\\\\\":\\\\\\"6ACCA254-2E83-1B5A-AF65-7C8FC7F3A275\\\\\\"}\\\\n\\"","type":"json"}]',
],
],
'endpoints' => [
['regionId' => 'cn-wulanchabu', 'regionName' => '华北6(乌兰察布)', 'areaId' => 'asiaPacific', 'areaName' => '亚太', 'public' => 'emrassistant.cn-wulanchabu.aliyuncs.com', 'endpoint' => 'emrassistant.cn-wulanchabu.aliyuncs.com', 'vpc' => ''],
['regionId' => 'cn-shenzhen', 'regionName' => '华南1(深圳)', 'areaId' => 'asiaPacific', 'areaName' => '亚太', 'public' => 'emrassistant.cn-shenzhen.aliyuncs.com', 'endpoint' => 'emrassistant.cn-shenzhen.aliyuncs.com', 'vpc' => ''],
['regionId' => 'cn-shanghai', 'regionName' => '华东2(上海)', 'areaId' => 'asiaPacific', 'areaName' => '亚太', 'public' => 'emrassistant.cn-shanghai.aliyuncs.com', 'endpoint' => 'emrassistant.cn-shanghai.aliyuncs.com', 'vpc' => ''],
['regionId' => 'cn-qingdao', 'regionName' => '华北1(青岛)', 'areaId' => 'asiaPacific', 'areaName' => '亚太', 'public' => 'emrassistant.cn-qingdao.aliyuncs.com', 'endpoint' => 'emrassistant.cn-qingdao.aliyuncs.com', 'vpc' => ''],
['regionId' => 'cn-huhehaote', 'regionName' => '华北5(呼和浩特)', 'areaId' => 'asiaPacific', 'areaName' => '亚太', 'public' => 'emrassistant.cn-huhehaote.aliyuncs.com', 'endpoint' => 'emrassistant.cn-huhehaote.aliyuncs.com', 'vpc' => ''],
['regionId' => 'cn-hangzhou', 'regionName' => '华东1(杭州)', 'areaId' => 'asiaPacific', 'areaName' => '亚太', 'public' => 'emrassistant.cn-hangzhou.aliyuncs.com', 'endpoint' => 'emrassistant.cn-hangzhou.aliyuncs.com', 'vpc' => ''],
['regionId' => 'cn-chengdu', 'regionName' => '西南1(成都)', 'areaId' => 'asiaPacific', 'areaName' => '亚太', 'public' => 'emrassistant.cn-chengdu.aliyuncs.com', 'endpoint' => 'emrassistant.cn-chengdu.aliyuncs.com', 'vpc' => ''],
['regionId' => 'cn-beijing', 'regionName' => '华北2(北京)', 'areaId' => 'asiaPacific', 'areaName' => '亚太', 'public' => 'emrassistant.cn-beijing.aliyuncs.com', 'endpoint' => 'emrassistant.cn-beijing.aliyuncs.com', 'vpc' => ''],
['regionId' => 'ap-southeast-1', 'regionName' => '新加坡', 'areaId' => 'asiaPacific', 'areaName' => '亚太', 'public' => 'emrassistant.ap-southeast-1.aliyuncs.com', 'endpoint' => 'emrassistant.ap-southeast-1.aliyuncs.com', 'vpc' => ''],
],
'errorCodes' => [
['code' => 'TaskNotSubscribed', 'message' => 'The task has not been subscribed.', 'http_code' => 400, 'description' => '该任务尚未被订阅,无法立即执行。'],
],
'changeSet' => [],
];
|