Spaces:
Sleeping

PERDYPTO commited on
Commit
18d06ca
·
verified ·
1 Parent(s): edd7530

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +26 -25
main.py CHANGED
@@ -33,6 +33,7 @@ def _parse_api_keys(raw_value: str) -> list[str]:
33
  if key not in seen:
34
  seen.add(key)
35
  unique_keys.append(key)
 
36
  return unique_keys
37
 
38
 
@@ -172,19 +173,19 @@ async def lifespan(app: FastAPI):
172
  for pool in app.state.reasoning_provider_pools:
173
  await pool.close()
174
  await app.state.http_client.aclose()
175
-
176
-
177
- app = FastAPI(title="Perdypto Reasoning Service", lifespan=lifespan)
178
-
179
- app.add_middleware(
180
- CORSMiddleware,
181
- allow_origins=["*"],
182
- allow_credentials=True,
183
- allow_methods=["*"],
184
- allow_headers=["*"],
185
- )
186
-
187
-
188
  @app.get("/health")
189
  async def health_check():
190
  pools = getattr(app.state, "reasoning_provider_pools", [])
@@ -270,11 +271,11 @@ async def _get_prediction_with_fallback(request: ReasoningRequest):
270
  print(f"[WARN] {pool.name} failed for {request.symbol}: {e}; trying fallback provider")
271
 
272
  raise ValueError("All reasoning providers failed. " + " | ".join(failures))
273
-
274
-
275
- @app.post("/reason", response_model=ReasoningResponse)
276
- async def reason(request: ReasoningRequest):
277
- """Generate structured price prediction from combined TA + news + price data."""
278
  start_time = time.time()
279
 
280
  try:
@@ -289,11 +290,11 @@ async def reason(request: ReasoningRequest):
289
  model_used=model_used,
290
  reasoning_time_ms=int((time.time() - start_time) * 1000)
291
  )
292
-
293
- except Exception as e:
294
- # Always print full error to stdout for debugging
295
- print(f"[ERROR] /reason failed for {request.symbol}: {e}")
296
- raise HTTPException(
297
- status_code=503,
298
- detail=ErrorResponse(error="Prediction generation failed", detail=str(e)).model_dump()
299
  )
 
33
  if key not in seen:
34
  seen.add(key)
35
  unique_keys.append(key)
36
+ print(key)
37
  return unique_keys
38
 
39
 
 
173
  for pool in app.state.reasoning_provider_pools:
174
  await pool.close()
175
  await app.state.http_client.aclose()
176
+
177
+
178
+ app = FastAPI(title="Perdypto Reasoning Service", lifespan=lifespan)
179
+
180
+ app.add_middleware(
181
+ CORSMiddleware,
182
+ allow_origins=["*"],
183
+ allow_credentials=True,
184
+ allow_methods=["*"],
185
+ allow_headers=["*"],
186
+ )
187
+
188
+
189
  @app.get("/health")
190
  async def health_check():
191
  pools = getattr(app.state, "reasoning_provider_pools", [])
 
271
  print(f"[WARN] {pool.name} failed for {request.symbol}: {e}; trying fallback provider")
272
 
273
  raise ValueError("All reasoning providers failed. " + " | ".join(failures))
274
+
275
+
276
+ @app.post("/reason", response_model=ReasoningResponse)
277
+ async def reason(request: ReasoningRequest):
278
+ """Generate structured price prediction from combined TA + news + price data."""
279
  start_time = time.time()
280
 
281
  try:
 
290
  model_used=model_used,
291
  reasoning_time_ms=int((time.time() - start_time) * 1000)
292
  )
293
+
294
+ except Exception as e:
295
+ # Always print full error to stdout for debugging
296
+ print(f"[ERROR] /reason failed for {request.symbol}: {e}")
297
+ raise HTTPException(
298
+ status_code=503,
299
+ detail=ErrorResponse(error="Prediction generation failed", detail=str(e)).model_dump()
300
  )