mirror of
https://github.com/Pythagora-io/gpt-pilot.git
synced 2026-01-10 13:37:55 -05:00
assertion error
This commit is contained in:
@@ -10,6 +10,7 @@ from core.cli.helpers import delete_project, init, list_projects, list_projects_
|
||||
from core.config import LLMProvider, get_config
|
||||
from core.db.session import SessionManager
|
||||
from core.db.v0importer import LegacyDatabaseImporter
|
||||
from core.llm.anthropic_client import CustomAssertionError
|
||||
from core.llm.base import APIError, BaseLLMClient
|
||||
from core.log import get_logger
|
||||
from core.state.state_manager import StateManager
|
||||
@@ -67,6 +68,14 @@ async def run_project(sm: StateManager, ui: UIBase, args) -> bool:
|
||||
)
|
||||
telemetry.set("end_result", "failure:api-error")
|
||||
await sm.rollback()
|
||||
except CustomAssertionError as err:
|
||||
log.warning(f"Anthropic assertion error occurred: {err.message}")
|
||||
await ui.send_message(
|
||||
f"Stopping Pythagora due to an error inside Anthropic SDK. {err.message}",
|
||||
source=pythagora_source,
|
||||
)
|
||||
telemetry.set("end_result", "failure:assertion-error")
|
||||
await sm.rollback()
|
||||
except Exception as err:
|
||||
log.error(f"Uncaught exception: {err}", exc_info=True)
|
||||
stack_trace = telemetry.record_crash(err)
|
||||
|
||||
@@ -19,7 +19,7 @@ MAX_TOKENS = 4096
|
||||
MAX_TOKENS_SONNET = 8192
|
||||
|
||||
|
||||
class RetryableError(Exception):
|
||||
class CustomAssertionError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ class AnthropicClient(BaseLLMClient):
|
||||
final_message.content # Access content to verify it exists
|
||||
except AssertionError:
|
||||
log.debug("Anthropic package AssertionError")
|
||||
raise RetryableError("Anthropic package AssertionError")
|
||||
raise CustomAssertionError("No final message received.")
|
||||
|
||||
response_str = "".join(response)
|
||||
|
||||
@@ -114,9 +114,9 @@ class AnthropicClient(BaseLLMClient):
|
||||
for attempt in range(retry_count + 1):
|
||||
try:
|
||||
return await single_attempt()
|
||||
except RetryableError as e:
|
||||
except CustomAssertionError as e:
|
||||
if attempt == retry_count: # If this was our last attempt
|
||||
raise RuntimeError(f"Request failed after {retry_count + 1} attempts: {str(e)}")
|
||||
raise CustomAssertionError(f"Request failed after {retry_count + 1} attempts: {str(e)}")
|
||||
# Add a small delay before retrying
|
||||
await asyncio.sleep(1)
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user