mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-08 02:17:46 +08:00
feat(stream-bridge): 支持上游 sync 响应转 SSE 流式输出,记录 client/upstream 流模式差异
- 新增 sync_to_stream 桥接模块,将非 SSE 上游响应转换为 SSE 格式回传给流式客户端 - stream_pump 检测非 SSE 响应头后缓冲整包并通过桥接逻辑重写为 SSE 帧 - proxy handler 同步支持 sync→stream 聚合与转换(覆盖 openai/claude/gemini 四种格式) - sync_products 补全 openai:cli 的完整流式事件聚合(text delta、reasoning、tool call 等) - usage runtime 写入 client_requested_stream / upstream_is_stream 到 request_metadata - SQL 查询层将两个布尔字段从 request_metadata jsonb 中提取并回传给前端 - 前端 status.ts 新增 resolveUsageStreamLabelSegments,优先读取 client_requested_stream - RequestDetailDrawer 在流式转换场景下显示"客户端→上游"两段 Badge
This commit is contained in:
@@ -384,6 +384,42 @@ export function useUsageData(options: UseUsageDataOptions) {
|
||||
|
||||
// 如果需要保护状态,说明本地数据比后端更新,应该保留本地的所有实时更新字段
|
||||
if (protectStatus) {
|
||||
const recordUpstreamIsStream = typeof record.upstream_is_stream === 'boolean'
|
||||
? record.upstream_is_stream
|
||||
: typeof record.is_stream === 'boolean'
|
||||
? record.is_stream
|
||||
: undefined
|
||||
const existingUpstreamIsStream = typeof existing.upstream_is_stream === 'boolean'
|
||||
? existing.upstream_is_stream
|
||||
: typeof existing.is_stream === 'boolean'
|
||||
? existing.is_stream
|
||||
: undefined
|
||||
const upstreamIsStream = recordUpstreamIsStream ?? existingUpstreamIsStream ?? false
|
||||
|
||||
const recordClientRequestedStream = typeof record.client_requested_stream === 'boolean'
|
||||
? record.client_requested_stream
|
||||
: typeof record.client_is_stream === 'boolean'
|
||||
? record.client_is_stream
|
||||
: undefined
|
||||
const existingClientRequestedStream = typeof existing.client_requested_stream === 'boolean'
|
||||
? existing.client_requested_stream
|
||||
: typeof existing.client_is_stream === 'boolean'
|
||||
? existing.client_is_stream
|
||||
: undefined
|
||||
const clientRequestedStream = recordClientRequestedStream ?? existingClientRequestedStream
|
||||
|
||||
const recordClientIsStream = typeof record.client_is_stream === 'boolean'
|
||||
? record.client_is_stream
|
||||
: typeof record.client_requested_stream === 'boolean'
|
||||
? record.client_requested_stream
|
||||
: undefined
|
||||
const existingClientIsStream = typeof existing.client_is_stream === 'boolean'
|
||||
? existing.client_is_stream
|
||||
: typeof existing.client_requested_stream === 'boolean'
|
||||
? existing.client_requested_stream
|
||||
: undefined
|
||||
const clientIsStream = recordClientIsStream ?? existingClientIsStream ?? clientRequestedStream
|
||||
|
||||
return {
|
||||
...record,
|
||||
// 保留本地的状态和所有通过轮询更新的字段
|
||||
@@ -404,6 +440,10 @@ export function useUsageData(options: UseUsageDataOptions) {
|
||||
actual_cost: existing.actual_cost ?? record.actual_cost,
|
||||
response_time_ms: existing.response_time_ms ?? record.response_time_ms,
|
||||
first_byte_time_ms: existing.first_byte_time_ms ?? record.first_byte_time_ms,
|
||||
is_stream: upstreamIsStream,
|
||||
upstream_is_stream: upstreamIsStream,
|
||||
client_requested_stream: clientRequestedStream,
|
||||
client_is_stream: clientIsStream,
|
||||
api_format: existing.api_format || record.api_format,
|
||||
endpoint_api_format: existing.endpoint_api_format || record.endpoint_api_format,
|
||||
has_format_conversion: existing.has_format_conversion ?? record.has_format_conversion,
|
||||
|
||||
Reference in New Issue
Block a user