fix(gateway): restore safe search fallback
Fall back to guarded Chat Completions answers when DeepSeek web search fails so grounded current-information hints do not surface generic provider errors.
This commit is contained in:
+5
-4
@@ -9,6 +9,7 @@ import com.osglab.account.features.gateway.models.ProviderOutput
|
||||
import com.osglab.account.features.gateway.models.ProviderUsage
|
||||
import com.osglab.account.features.gateway.models.TextProviderRequest
|
||||
import com.osglab.account.features.gateway.models.UsageMeter
|
||||
import com.osglab.account.features.gateway.providers.ProviderUpstreamException
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.call.body
|
||||
import io.ktor.client.request.bearerAuth
|
||||
@@ -72,16 +73,16 @@ internal class DeepSeekSearchFallbackClient(
|
||||
} catch (failure: CancellationException) {
|
||||
throw failure
|
||||
} catch (failure: Exception) {
|
||||
val upstreamStatus = (failure as? ProviderUpstreamException)?.upstreamStatus
|
||||
LOG.warn(
|
||||
"DeepSeek search path failed requestId={} taskKind={} searchMode={} failureType={}",
|
||||
"DeepSeek search path failed requestId={} taskKind={} searchMode={} " +
|
||||
"failureType={} upstreamStatus={} fallback=chat_completions",
|
||||
request.requestId,
|
||||
request.executionPolicy.taskKind.name,
|
||||
request.executionPolicy.webSearch.name,
|
||||
failure::class.simpleName ?: "Exception",
|
||||
upstreamStatus ?: "unknown",
|
||||
)
|
||||
if (request.executionPolicy.webSearch == GatewayWebSearchMode.REQUIRED) {
|
||||
throw failure
|
||||
}
|
||||
return fallback.complete(
|
||||
request.copy(
|
||||
executionPolicy = request.executionPolicy.copy(
|
||||
|
||||
Reference in New Issue
Block a user