mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
fix(copilot): fix stream_err UnboundLocalError, move local import to top-level
Python 3 deletes `except ... as e` bindings after the except block exits (PEP 3110). Save the exception to a persistent variable so the for...else exhaustion block can reference it. Also move `from backend.copilot.config import ChatConfig` from a local import to top-level in transcript.py.
This commit is contained in:
@@ -1409,7 +1409,8 @@ async def stream_chat_completion_sdk(
|
||||
_MAX_STREAM_ATTEMPTS,
|
||||
)
|
||||
raise
|
||||
except Exception as stream_err:
|
||||
except Exception as e:
|
||||
stream_err = e
|
||||
logger.warning(
|
||||
"%s Stream error (attempt %d/%d): %s",
|
||||
log_prefix,
|
||||
|
||||
@@ -21,6 +21,7 @@ from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from uuid import uuid4
|
||||
|
||||
from backend.copilot.config import ChatConfig
|
||||
from backend.util import json
|
||||
from backend.util.clients import get_openai_client
|
||||
from backend.util.prompt import CompressResult, compress_context
|
||||
@@ -734,8 +735,6 @@ async def compact_transcript(
|
||||
|
||||
Returns the compacted JSONL string, or ``None`` on failure.
|
||||
"""
|
||||
from backend.copilot.config import ChatConfig
|
||||
|
||||
cfg = ChatConfig()
|
||||
messages = _transcript_to_messages(content)
|
||||
if len(messages) < 2:
|
||||
|
||||
Reference in New Issue
Block a user