github-actions[bot] commited on
Commit
647a656
·
1 Parent(s): 17af839

Auto-deploy backend from GitHub Actions

Browse files
app/api/v1/endpoints/learn.py CHANGED
@@ -31,6 +31,8 @@ async def create_learning_deck(
31
 
32
  return deck
33
 
 
 
34
  except RuntimeError as e:
35
  logger.error(f"Deck Generation Error: {e}")
36
  raise HTTPException(
 
31
 
32
  return deck
33
 
34
+ except HTTPException:
35
+ raise
36
  except RuntimeError as e:
37
  logger.error(f"Deck Generation Error: {e}")
38
  raise HTTPException(
app/services/llm_service.py CHANGED
@@ -127,7 +127,14 @@ async def generate_learning_deck(
127
  detail="Learning Deck AI timed out generating the lesson. Please try again.",
128
  )
129
  except Exception as e:
 
 
 
 
 
 
 
130
  raise HTTPException(
131
  status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
132
- detail=f"Learning Deck AI Failed: {str(e)}",
133
  )
 
127
  detail="Learning Deck AI timed out generating the lesson. Please try again.",
128
  )
129
  except Exception as e:
130
+ error_str = str(e)
131
+ if "429" in error_str or "RESOURCE_EXHAUSTED" in error_str:
132
+ raise HTTPException(
133
+ status_code=status.HTTP_429_TOO_MANY_REQUESTS,
134
+ detail="Tuklascope AI is currently analyzing too many anomalies globally. Please wait a few seconds and try again.",
135
+ )
136
+ # Handle Safety blocks in the future here
137
  raise HTTPException(
138
  status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
139
+ detail=f"Learning Deck AI Failed: {error_str}",
140
  )