帮助文档 Logo
平台使用
阿里云
百度云
移动云
智算服务
教育生态
登录 →
帮助文档 Logo
平台使用 阿里云 百度云 移动云 智算服务 教育生态
登录
  1. 首页
  2. 阿里云
  3. 对象存储
  4. 操作指南
  5. 数据处理
  6. 文档处理
  7. 文档处理参数
  8. 文档智能处理
  9. 普通模式和SSE模式说明

普通模式和SSE模式说明

  • 文档智能处理
  • 发布于 2025-04-21
  • 0 次阅读
文档编辑
文档编辑

本文介绍普通HTTP交互方式与SSE模式的区别。在普通HTTP交互方式下,一次请求只会收到一个数据包作为结果,但请求时间会略微长一些。SSE模式下服务器会推送多个事件,每生成一些数据后就会推送给客户端。SSE模式更适用于实时数据更新的场景,可以实现动态生成文字的效果。

普通模式

在普通模式下,给服务端发送的每个请求都会收到一个数据包作为结果。

HTTP/1.1 200 OK
Server: AliyunOSS
Date: Mon, 07 Aug 2023 09:44:02 GMT
Content-Type: application/json;charset=UTF-8
Connection: close
Vary: Accept-Encoding
x-oss-request-id: 64D0BCDD88339E32330E2D1D
x-oss-server-time: 5865
Content-Encoding: gzip

{
  "RequestID": "64D0BCDD88339E32330E2D1D",
  "Output": {
    "Text": "A Ghost, the Communist Ghost, haunts the European continent. In order to holy suppression of this ghost, all forces of the old Europe, including the Pope and the Czar, Metternich and Guizot, the radical party in France and the police in Germany, have united. Is there any opposition party that is not denounced by its governing enemies as a Communist? And is there any opposition party that does not use the charge of Communism as a weapon against more progressive oppositionists and its reactionary enemies? From this fact we can draw two conclusions: Communism has been recognized by all the forces of Europe as a power; it is now the turn of the Communists to make themselves known to the world, to state their views, their aims, their intentions, and to publish their own manifestos in order to refute the myth about the Communist ghost. For this purpose, delegates of the Communist parties of all countries assembled in London and adopted the following manifesto, which is published in English, French, German, Italian, Flemish and Danish.",
    "FinishReason": "stop"
  }
}

SSE模式

SSE模式,即Server-Sent Events的简称,是一种服务器端到客户端(浏览器)的单向事件推送。EventSource接口是HTML5规范的一部分。

SSE推送的消息是UTF-8编码的纯文本。每次推送由若干个事件消息组成,每个事件消息之间用两个换行分割(\n\n)。事件消息中由若干行组成,每行以[key]: value\n的键值对组成。其中key可选项为id、event和data。data中的内容是消息本身。

在智能文档服务的实现中,data中的内容为一个JSON结构体,结构内容为文档中返回参数介绍。

在一次请求中,您收到的结果如下所示:

HTTP/1.1 200 OK
Server: AliyunOSS
Date: Mon, 07 Aug 2023 09:44:36 GMT
Content-Type: text/event-stream;charset=UTF-8
Transfer-Encoding: chunked
Connection: close
x-oss-request-id: 64D0BD0388339E30331D2D1D
x-oss-server-time: 761

id: 0
event: message
data: {"RequestId":"","Output":{"Text":"A Ghost,","FinishReason":"null"},"Usage":{"InputTokens":320,"OutputTokens":3}}

id: 1
event: message
data: {"RequestId":"","Output":{"Text":"A Ghost, the Communist Ghost, haunts the European","FinishReason":"null"},"Usage":{"InputTokens":320,"OutputTokens":11}}

id: 2
event: message
data: {"RequestId":"","Output":{"Text":"A Ghost, the Communist Ghost, haunts the European continent. In order to holy suppression of","FinishReason":"null"},"Usage":{"InputTokens":320,"OutputTokens":19}}

......

id: 27
event: Result
data: {"RequestId":"","Output":{"Text":"A Ghost, the Communist Ghost, haunts the European continent. In order to holy suppression of this ghost, all forces of the old Europe, including the Pope and the Czar, Metternich and Guizot, the radical party in France and the police in Germany, have united. Is there any opposition party that is not denounced by its governing enemies as a Communist? And is there any opposition party that does not use the charge of Communism as a weapon against more progressive oppositionists and its reactionary enemies? From this fact we can draw two conclusions: Communism has been recognized by all the forces of Europe as a power; it is now the turn of the Communists to make themselves known to the world, to state their views, their aims, their intentions, and to publish their own manifestos in order to refute the myth about the Communist ghost. For this purpose, delegates of the Communist parties of all countries assembled in London and adopted the following manifesto, which is published in English, French, German, Italian, Flemish and Danish.","FinishReason":"stop"},"Usage":{"InputTokens":320,"OutputTokens":212}}

其中每次事件中的消息内容包含增量的数据,也就是在请求中data内容逐步更新。

相关文章

普通模式和SSE模式说明 2025-04-21 18:16

本文介绍普通HTTP交互方式与SSE模式的区别。在普通HTTP交互方式下,一次请求只会收到一个数据包作为结果,但请求时间会略微长一些。SSE模式下服务器会推送多个事件,每生成一些数据后就会推送给客户端。SSE模式更适用于实时数据更新的场景,可以实现动态生成文字的效果。 普通模式 在普通模式下,给服务

智能文档翻译 2025-04-21 18:16

您可以通过智能文档翻译功能,将文本翻译为中文、英文等多种语言。通过人工智能技术,可以更高效、精准、便捷地进行多种语言的翻译。 注意事项 文档智能翻译功能仅支持同步处理(x-oss-process处理方式)。 该接口需采用POST

智能文档润色 2025-04-21 18:16

您可以通过智能文档润色功能,使得文档更加优雅、清晰、易读。 注意事项 智能文档润色功能仅支持同步处理(x-oss-process处理方式)。 该接口需采用POST方式请求。

智能文档摘要 2025-04-21 18:16

智能文档摘要用于快速识别长篇文档中的核心要点、关键句子或段落,自动生成文档内容的简短概括或提取关键信息,帮助您高效地了解文档主旨,节省阅读和理解全文所需的时间。 前提条件 已绑定IMM Project。通过OSS控制台绑定的具体操作,请参见快速入门。通过API绑定的具体操作,请参见AttachOSS

智能文档续写 2025-04-21 18:16

智能文档续写是一种基于人工智能技术的文字创作辅助功能,可以根据既定的起始文本、主题、风格等条件,自动生成连贯、符合逻辑的后续内容。智能文档续写广泛应用于写作辅助、内容创作等多个领域,旨在提高写作效率以及文本质量。 前提条件 已绑定IMM Project。通过OSS控制台绑定的具体操作,请参见快速入门

智能文档丰富 2025-04-21 18:16

智能文档丰富侧重于优化现有文档的语言表达和风格,使得文档更加流畅、易读,提高其整体质量。 前提条件 已绑定IMM Project。通过OSS控制台绑定的具体操作,请参见快速入门。通过API绑定的具体操作,请参见AttachOSSBucket - 绑定对象存储桶。

目录
Copyright © 2025 your company All Rights Reserved. Powered by 博智数字服务平台.
闽ICP备08105208号-1