ming commited on
Commit
33cd483
·
1 Parent(s): 2ff86e9

Improve Outlines import error handling and logging

Browse files

- Capture and log actual import errors for debugging
- Log success when Outlines imports correctly
- Catch all exceptions, not just ImportError

app/services/structured_summarizer.py CHANGED
@@ -52,15 +52,18 @@ except ImportError:
52
  from pydantic import BaseModel
53
 
54
  # Try to import Outlines for JSON schema enforcement
 
 
 
 
55
  try:
56
  from outlines import models as outlines_models, generate as outlines_generate
57
-
58
  OUTLINES_AVAILABLE = True
59
- except ImportError:
60
- OUTLINES_AVAILABLE = False
61
- outlines_models = None
62
- outlines_generate = None
63
- logger.warning("Outlines library not available. V4 JSON streaming endpoints will be disabled.")
64
 
65
 
66
  class StructuredSummary(BaseModel):
 
52
  from pydantic import BaseModel
53
 
54
  # Try to import Outlines for JSON schema enforcement
55
+ OUTLINES_AVAILABLE = False
56
+ outlines_models = None
57
+ outlines_generate = None
58
+
59
  try:
60
  from outlines import models as outlines_models, generate as outlines_generate
 
61
  OUTLINES_AVAILABLE = True
62
+ logger.info("✅ Outlines library imported successfully")
63
+ except ImportError as e:
64
+ logger.warning(f"Outlines library not available: {e}. V4 JSON streaming endpoints will be disabled.")
65
+ except Exception as e:
66
+ logger.warning(f"Error importing Outlines library: {e}. V4 JSON streaming endpoints will be disabled.")
67
 
68
 
69
  class StructuredSummary(BaseModel):