页面树结构
转至元数据结尾
转至元数据起始

在大模型的交互场景中,流式返回(Streaming Response) 是一种常见的数据传输方式:模型生成结果时,不会等待完整文本全部生成后再一次性返回,而是将内容逐句、逐段甚至逐词地实时输出,让用户可以 “边接收边阅读”,无需等待最终结果。

如果使用了nginx代理smartbi,需要添加流式返回的配置。如果不配置,AIChat的返回会不流畅,也可能提前结束。

location /smartbi {
    proxy_pass http://ip:端口/smartbi;

    # 基本代理头
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;

    # 隐藏敏感头
    proxy_hide_header X-Powered-By;
    proxy_hide_header Vary;
    proxy_ignore_headers X-Accel-Expires Expires Cache-Control Set-Cookie;

    # 超时设置(可根据业务调整)
    proxy_connect_timeout 60s;    # 连接后端超时
    proxy_send_timeout 600s;      # 发送请求超时
    proxy_read_timeout 600s;      # 读取响应超时

    # SSE(Server-Sent Events)支持
    proxy_buffering off;          # 禁用缓冲,确保实时性
    proxy_cache off;              # 禁用缓存
    proxy_http_version 1.1;       # 使用 HTTP/1.1(支持长连接)
    chunked_transfer_encoding on; # 启用分块传输

    # 其他优化
    proxy_redirect off;           # 避免重定向问题
    proxy_no_cache $http_pragma $http_authorization;  # 不缓存特定请求
}
  • 无标签