PinkAlpaca commited on
Commit
6a35b35
·
verified ·
1 Parent(s): b9c4d4a

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +3 -2
main.py CHANGED
@@ -10,7 +10,8 @@ app = FastAPI()
10
  cache_dir = './cache'
11
 
12
  # Create the cache directory if it doesn't exist
13
- os.makedirs(cache_dir, exist_ok=True)
 
14
 
15
  # Set the TRANSFORMERS_CACHE environment variable to the cache directory
16
  os.environ['TRANSFORMERS_CACHE'] = cache_dir
@@ -60,4 +61,4 @@ async def generate_text(item: Item):
60
  raise HTTPException(status_code=500, detail=f"An error occurred: {e}")
61
 
62
  if __name__ == "__main__":
63
- uvicorn.run(app, host="0.0.0.0", port=8000)
 
10
  cache_dir = './cache'
11
 
12
  # Create the cache directory if it doesn't exist
13
+ if not os.path.exists(cache_dir):
14
+ os.makedirs(cache_dir, exist_ok=True)
15
 
16
  # Set the TRANSFORMERS_CACHE environment variable to the cache directory
17
  os.environ['TRANSFORMERS_CACHE'] = cache_dir
 
61
  raise HTTPException(status_code=500, detail=f"An error occurred: {e}")
62
 
63
  if __name__ == "__main__":
64
+ uvicorn.run(app, host="0.0.0.0", port=8000)