Spaces:
Sleeping
Sleeping
| import os | |
| import shutil | |
| # Force HOME to /tmp so CrewAI doesn't try writing to /.local | |
| os.environ["HOME"] = "/tmp" | |
| os.environ["XDG_DATA_HOME"] = "/tmp/.local/share" | |
| os.environ["CREWAI_STORAGE_PATH"] = "/tmp/crewai_data" | |
| os.environ["CREWAI_HOME"] = "/tmp/crewai_home" | |
| # Create safe directories | |
| os.makedirs("/tmp/.local/share", exist_ok=True) | |
| os.makedirs("/tmp/crewai_data", exist_ok=True) | |
| os.makedirs("/tmp/crewai_home", exist_ok=True) | |
| from crewai import Crew, Process | |
| import json | |
| from fastapi import FastAPI | |
| from routers import objective_route, outliner_route, outcome_route,introduction_route | |
| app = FastAPI(title="AI Agent Project", version="1.0.0") | |
| app.include_router(outliner_route.router) | |
| app.include_router(objective_route.router) | |
| app.include_router(outcome_route.router) | |
| app.include_router(introduction_route.router) | |
| # Clear Cashe | |
| def reset_cache(): | |
| paths = [ | |
| "/tmp/crewai_data", | |
| "/tmp/crewai_home", | |
| "/tmp/.local/share", | |
| ] | |
| for path in paths: | |
| if os.path.exists(path): | |
| shutil.rmtree(path, ignore_errors=True) | |
| os.makedirs("/tmp/crewai_data", exist_ok=True) | |
| os.makedirs("/tmp/crewai_home", exist_ok=True) | |
| os.makedirs("/tmp/.local/share", exist_ok=True) | |
| return {"message": "โ Cache cleared successfully."} | |
| # Example root endpoint | |
| def read_root(): | |
| return {"message": "Welcome to AI Agent Project API ๐"} | |
| # ------------------------ | |
| # โ ููุทุฉ ุชุดุบูู ุงูุณูุฑูุฑ | |
| # ------------------------ | |
| # if __name__ == "__main__": | |
| # import uvicorn | |
| # uvicorn.run("main:app", host="127.0.0.1", port=8000, reload=True) | |