Download app.py from aliroya32/ContiAI: direct link, hf CLI and curl.
- Browser
- Download file 2.99 kB
-
https://huggingface.co/spaces/aliroya32/ContiAI/resolve/main/app.py
- Command line
-
hf download hf://spaces/aliroya32/ContiAI/app.py
-
curl -L -o app.py https://huggingface.co/spaces/aliroya32/ContiAI/resolve/main/app.py
2.99 kB
| import os | |
| import shutil | |
| # hijl;kpplp[kiohyufrdeswa] | |
| # 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, | |
| source_route, | |
| scraper_route, | |
| final_outlines_before_content_route, | |
| content_generation_route, | |
| quiz_route, | |
| details_before_content_route, | |
| ) | |
| from routers.books import ( | |
| units_structure_route, | |
| book_structure_route, | |
| book_planning_route, | |
| rag_route, | |
| rag_automation_route, | |
| book_content, | |
| rag_admin, | |
| queries_route, | |
| search_route, | |
| rag_sources, | |
| units_intro, | |
| book_enrichment, | |
| reference, | |
| ) | |
| 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) | |
| # app.include_router(source_route.router) | |
| # app.include_router(scraper_route.router) | |
| app.include_router(final_outlines_before_content_route.router) | |
| app.include_router(content_generation_route.router) | |
| app.include_router(quiz_route.router) | |
| app.include_router(details_before_content_route.router) | |
| app.include_router(units_structure_route.router) | |
| app.include_router(book_structure_route.router) | |
| app.include_router(book_planning_route.router) | |
| app.include_router(rag_route.router) | |
| app.include_router(book_content.router) | |
| app.include_router(rag_automation_route.router) | |
| app.include_router(rag_admin.router) | |
| app.include_router(queries_route.router) | |
| app.include_router(search_route.router) | |
| app.include_router(rag_sources.router) | |
| app.include_router(units_intro.router) | |
| app.include_router(book_enrichment.router) | |
| app.include_router(reference.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) | |