Appearance
简要描述
- 人工智能服务-Agent助手
请求URL
https://open.gangtise.com/application/open-ai/ai/chat/sse
请求方式
- POST (SSE协议)
请求头
请求头 | 类型 | 说明 |
---|---|---|
Authorization | String | accessToken,通accessToken接口获取 |
参数说明
参数名 | 必选 | 类型 | 说明 |
---|---|---|---|
text | 是 | String | 问题内容 |
mode | 是 | String | 问答模式 deep_research:深度研究模式 ark_agent:Agent模式 |
askChatParam | 是 | Object | 问答参数,问答模式不同,支持的参数不同 |
深度研究模式 askChatParam参数说明
参数名 | 必选 | 类型 | 说明 |
---|---|---|---|
iter | 是 | Integer | 思考轮数,默认3轮,最大支持3轮 |
Agent模式 askChatParam参数说明
参数名 | 必选 | 类型 | 说明 |
---|---|---|---|
history | 是 | List<String> | 问题历史,最大支持10个问题 |
includeSearchTypes | 是 | List<Integer> | 查询数据所包含的类型,包含以下类型 10:券商研究报告 20:首席分析师观点 30:会议平台纪要 |
startDate | 否 | String | 查询开始日期,格式为yyyy-MM-dd |
endDate | 否 | String | 查询结束日期,格式为yyyy-MM-dd |
webEnable | 否 | Boolean | 是否联网查询 |
traceId | 否 | String | 请求traceId,建议使用前缀+uuid |
请求示例
深度研究模式:
{
"text":"介绍一下比亚迪",
"mode":"deep_research",
"askChatParam":{
"iter":3
}
}
agent模式:
{
"text":"介绍一下比亚迪",
"mode":"ark_agent",
"askChatParam":{
"history":["比亚迪今天的销量","比亚迪以前的表现"],
"includeSearchTypes":[10,20,30],
"startDate":"2025-04-09",
"endDate":"2025-04-16",
"webEnable":true,
"traceId":"traceId"
}
}
返回示例
{"phase": "think", "round": 1, "result": {"type": "rich_text", "isStream": true, "isStreamLast": false, "delta": "好的"}}
{"phase": "think", "round": 1, "result": {"type": "rich_text", "isStream": true, "isStreamLast": false, "delta": ","}}
{"phase": "think", "round": 1, "result": {"type": "rich_text", "isStream": true, "isStreamLast": false, "delta": "我现在"}}
{"phase": "think", "round": 1, "result": {"type": "rich_text", "isStream": true, "isStreamLast": false, "delta": "需要"}}
{"phase": "think", "round": 1, "result": {"type": "rich_text", "isStream": true, "isStreamLast": false, "delta": "回答"}}
{"phase": "think", "round": 1, "result": {"type": "rich_text", "isStream": true, "isStreamLast": false, "delta": "用户"}}
{"phase": "think", "round": 1, "result": {"type": "rich_text", "isStream": true, "isStreamLast": false, "delta": "的问题"}}
{"phase": "think", "round": 1, "result": {"type": "rich_text", "isStream": true, "isStreamLast": false, "delta": ":“"}}
返回参数说明
参数名 | 类型 | 说明 |
---|---|---|
phase | String | 当前阶段,think:思考阶段,answer:回答阶段 |
round | Integer | 当前思考轮数 |
result | Object | 输出结果对象 |
result.type | String | 输出格式,rich_text:富文本 |
result.isStream | Boolean | 是否流式输出 |
result.isStreamLast | Boolean | 是否为流式的最后一个输出 |
result.delta | String | 内容增量 |
调用示例(java)
String accessToken = "你的accessToken";
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody requestBody = RequestBody.create(mediaType, "{\"mode\":\"deep_research\",\"askChatParam\":{\"iter\":2},\"text\":\"介绍一下比亚迪\"}");
Request request = new Request.Builder()
.url("https://open.gangtise.com/application/open-ai/ai/chat/sse")
.method("POST", requestBody)
.addHeader("Authorization", accessToken)
.addHeader("Content-Type", "application/json")
.build();
try ( Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
assert response.body() != null;
try (BufferedReader reader = new BufferedReader(new InputStreamReader(response.body().byteStream(), StandardCharsets.UTF_8))) {
String line;
while ((line = reader.readLine()) != null) {
// 解析 SSE 格式
if (line.startsWith("data:")) {
String data = line.substring(5).trim();
//这里是打印输入内容
System.out.println(data);
}
}
}catch (Exception e){
e.printStackTrace();
}
}
} catch (IOException e) {
e.printStackTrace();
}
备注
HTTP状态码 | 说明 |
---|---|
200 | 操作成功 |
429 | 接口繁忙,请稍后再试 |
- 更多返回错误代码请看首页的错误代码描述