File tree Expand file tree Collapse file tree
packages/console/app/src/routes/zen/util Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -120,6 +120,7 @@ export async function handler(
120120 zenData ,
121121 authInfo ,
122122 modelInfo ,
123+ ip ,
123124 sessionId ,
124125 trialProviders ,
125126 retry ,
@@ -402,6 +403,7 @@ export async function handler(
402403 zenData : ZenData ,
403404 authInfo : AuthInfo ,
404405 modelInfo : ModelInfo ,
406+ ip : string ,
405407 sessionId : string ,
406408 trialProviders : string [ ] | undefined ,
407409 retry : RetryOptions ,
@@ -430,10 +432,11 @@ export async function handler(
430432 . flatMap ( ( provider ) => Array < typeof provider > ( provider . weight ?? 1 ) . fill ( provider ) )
431433
432434 // Use the last 4 characters of session ID to select a provider
435+ const identifier = sessionId . length ? sessionId : ip
433436 let h = 0
434- const l = sessionId . length
437+ const l = identifier . length
435438 for ( let i = l - 4 ; i < l ; i ++ ) {
436- h = ( h * 31 + sessionId . charCodeAt ( i ) ) | 0 // 32-bit int
439+ h = ( h * 31 + identifier . charCodeAt ( i ) ) | 0 // 32-bit int
437440 }
438441 const index = ( h >>> 0 ) % providers . length // make unsigned + range 0..length-1
439442 const provider = providers [ index || 0 ]
You can’t perform that action at this time.
0 commit comments