AurelioAguirre commited on
Commit
9814b43
·
1 Parent(s): 5b76cc5

fixing pydantic issue v10

Browse files
Files changed (2) hide show
  1. main/main.py +11 -5
  2. main/routes.py +2 -1
main/main.py CHANGED
@@ -4,6 +4,7 @@ LLM Inference Server main application using LitServe framework.
4
  import litserve as ls
5
  import yaml
6
  import logging
 
7
  from pathlib import Path
8
  from fastapi.middleware.cors import CORSMiddleware
9
  from .routes import router, init_router
@@ -23,17 +24,18 @@ def load_config():
23
  with open(config_path) as f:
24
  return yaml.safe_load(f)
25
 
26
- def main():
27
- """Create and configure the application instance."""
28
  logger = setup_logging()
29
 
30
  try:
31
  # Load configuration
32
  config = load_config()
33
 
34
- # Initialize API and router
35
  api = InferenceApi()
36
- init_router(config)
 
37
 
38
  # Create LitServer instance
39
  server = ls.LitServer(
@@ -58,11 +60,15 @@ def main():
58
  port = config.get("server", {}).get("port", 8001)
59
 
60
  # Get the server instance from our app and run it
61
- server.run(port=port) # assuming the LitServer instance is stored as parent
62
 
63
  except Exception as e:
64
  logger.error(f"Server initialization failed: {str(e)}")
65
  raise
66
 
 
 
 
 
67
  if __name__ == "__main__":
68
  main()
 
4
  import litserve as ls
5
  import yaml
6
  import logging
7
+ import asyncio
8
  from pathlib import Path
9
  from fastapi.middleware.cors import CORSMiddleware
10
  from .routes import router, init_router
 
24
  with open(config_path) as f:
25
  return yaml.safe_load(f)
26
 
27
+ async def async_main():
28
+ """Create and configure the application instance asynchronously."""
29
  logger = setup_logging()
30
 
31
  try:
32
  # Load configuration
33
  config = load_config()
34
 
35
+ # Initialize API and router with await
36
  api = InferenceApi()
37
+ await api.setup() # Properly await the setup
38
+ await init_router(config) # Modified to be async
39
 
40
  # Create LitServer instance
41
  server = ls.LitServer(
 
60
  port = config.get("server", {}).get("port", 8001)
61
 
62
  # Get the server instance from our app and run it
63
+ server.run(port=port)
64
 
65
  except Exception as e:
66
  logger.error(f"Server initialization failed: {str(e)}")
67
  raise
68
 
69
+ def main():
70
+ """Entry point that runs the async main"""
71
+ asyncio.run(async_main())
72
+
73
  if __name__ == "__main__":
74
  main()
main/routes.py CHANGED
@@ -14,10 +14,11 @@ router = APIRouter()
14
  logger = logging.getLogger(__name__)
15
  api = None
16
 
17
- def init_router(config: dict):
18
  """Initialize router with config and Inference API instance"""
19
  global api
20
  api = InferenceApi()
 
21
  logger.info("Router initialized with Inference API instance")
22
 
23
  @router.post("/generate")
 
14
  logger = logging.getLogger(__name__)
15
  api = None
16
 
17
+ async def init_router(config: dict):
18
  """Initialize router with config and Inference API instance"""
19
  global api
20
  api = InferenceApi()
21
+ await api.setup() # Properly await the setup
22
  logger.info("Router initialized with Inference API instance")
23
 
24
  @router.post("/generate")