更新
This commit is contained in:
@@ -95,6 +95,37 @@ $explicitOpenAi = callDifyStreamPrivate('buildRequestSpecs', [
|
||||
difyStreamExpect(count($explicitDify) === 1 && $explicitDify[0]['protocol'] === 'dify', 'explicit Dify endpoint never changes protocol');
|
||||
difyStreamExpect(count($explicitOpenAi) === 1 && $explicitOpenAi[0]['protocol'] === 'openai', 'explicit OpenAI endpoint never changes protocol');
|
||||
|
||||
$retryableStream = [
|
||||
'errno' => 0,
|
||||
'http_code' => 200,
|
||||
'emitted' => false,
|
||||
'upstream_error' => true,
|
||||
'finished' => false,
|
||||
];
|
||||
difyStreamExpect(
|
||||
callDifyStreamPrivate('shouldTryNextProtocol', [$retryableStream, true]) === true,
|
||||
'a terminal-free stream error before any delta tries the alternate protocol'
|
||||
);
|
||||
$retryableStream['emitted'] = true;
|
||||
difyStreamExpect(
|
||||
callDifyStreamPrivate('shouldTryNextProtocol', [$retryableStream, true]) === false,
|
||||
'an emitted delta forbids protocol retry'
|
||||
);
|
||||
difyStreamExpect(
|
||||
callDifyStreamPrivate('shouldTryNextProtocol', [[
|
||||
'errno' => 0,
|
||||
'http_code' => 400,
|
||||
], false]) === true,
|
||||
'an ambiguous endpoint rejected before generation tries the alternate protocol'
|
||||
);
|
||||
difyStreamExpect(
|
||||
callDifyStreamPrivate('shouldTryNextProtocol', [[
|
||||
'errno' => 0,
|
||||
'http_code' => 401,
|
||||
], true]) === false,
|
||||
'credential failures are not hidden by protocol retry'
|
||||
);
|
||||
|
||||
$difyWire = ": ping\r\n\r\n"
|
||||
. "data: {\"event\":\"message\",\"answer\":\"你\",\"message_id\":\"msg-safe\"}\r\n\r\n"
|
||||
. "data: {\"event\":\"agent_message\",\"answer\":\"好\"}\r\n\r\n"
|
||||
|
||||
Reference in New Issue
Block a user