m1k3wn commited on
Commit
afe46be
·
verified ·
1 Parent(s): f7ed1d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py CHANGED
@@ -99,6 +99,7 @@ class PredictionResponse(BaseModel):
99
  generated_text: str
100
  model_used: str
101
 
 
102
  @app.get("/version")
103
  async def version():
104
  return {
@@ -106,6 +107,26 @@ async def version():
106
  "models_available": list(MODELS.keys())
107
  }
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  @app.get("/health")
110
  async def health():
111
  # More comprehensive health check
@@ -123,6 +144,7 @@ async def health():
123
  "error": str(e)
124
  }
125
 
 
126
  @app.post("/predict", response_model=PredictionResponse)
127
  async def predict(request: PredictionRequest):
128
  try:
 
99
  generated_text: str
100
  model_used: str
101
 
102
+ # Pythhon version check
103
  @app.get("/version")
104
  async def version():
105
  return {
 
107
  "models_available": list(MODELS.keys())
108
  }
109
 
110
+ # Environment check
111
+ @app.get("/debug/environment")
112
+ async def get_environment_info():
113
+ import torch
114
+ import transformers
115
+ import platform
116
+
117
+ return {
118
+ "python_version": platform.python_version(),
119
+ "torch_version": torch.__version__,
120
+ "torch_device": str(torch.device("cuda" if torch.cuda.is_available() else "cpu")),
121
+ "transformers_version": transformers.__version__,
122
+ "available_devices": {
123
+ "cuda_available": torch.cuda.is_available(),
124
+ "cuda_device_count": torch.cuda.device_count() if torch.cuda.is_available() else 0,
125
+ "mps_available": hasattr(torch.backends, "mps") and torch.backends.mps.is_available()
126
+ }
127
+ }
128
+
129
+ # Health check
130
  @app.get("/health")
131
  async def health():
132
  # More comprehensive health check
 
144
  "error": str(e)
145
  }
146
 
147
+ # Main /predict endpoint
148
  @app.post("/predict", response_model=PredictionResponse)
149
  async def predict(request: PredictionRequest):
150
  try: