Fix UnboundLocalError in stream_generator - add json import

parent 8628e8d3
...@@ -491,7 +491,7 @@ class RequestHandler: ...@@ -491,7 +491,7 @@ class RequestHandler:
logger.debug(f"Chunk {chunk_idx}/{total_chunks}: delta_text='{delta_text}', delta_tool_calls={len(delta_tool_calls)}, is_last={is_last_chunk}, condition={bool(delta_text or delta_tool_calls or is_last_chunk)}") logger.debug(f"Chunk {chunk_idx}/{total_chunks}: delta_text='{delta_text}', delta_tool_calls={len(delta_tool_calls)}, is_last={is_last_chunk}, condition={bool(delta_text or delta_tool_calls or is_last_chunk)}")
# Only send if there's new content, new tool calls, or it's the last chunk with finish_reason # Only send if there's new content, new tool calls, or it's the last chunk with finish_reason
if delta_text or delta_tool_calls or is_last_chunk: if delta_tool_calls or delta_text or is_last_chunk:
# Create OpenAI-compatible chunk with additional fields # Create OpenAI-compatible chunk with additional fields
openai_chunk = { openai_chunk = {
"id": response_id, "id": response_id,
...@@ -1533,6 +1533,7 @@ class RotationHandler: ...@@ -1533,6 +1533,7 @@ class RotationHandler:
system_fingerprint = generate_system_fingerprint(provider_id, seed) system_fingerprint = generate_system_fingerprint(provider_id, seed)
async def stream_generator(effective_context): async def stream_generator(effective_context):
import json
try: try:
if is_google_provider: if is_google_provider:
# Handle Google's streaming response # Handle Google's streaming response
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment