Skip to content

Commit e38008c

Browse files
Chessing234claude
andcommitted
Fix UnboundLocalError in generate_gate when generator yields nothing
Initialize x before the loop to prevent UnboundLocalError if generate_stream_gate yields no items. Fixes #3786 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 587d5cf commit e38008c

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

fastchat/serve/model_worker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ def generate_stream_gate(self, params):
144144
yield json.dumps(ret).encode() + b"\0"
145145

146146
def generate_gate(self, params):
147+
x = b"{}\0"
147148
for x in self.generate_stream_gate(params):
148149
pass
149150
return json.loads(x[:-1].decode())

0 commit comments

Comments
 (0)