# app.py import os import sys from fastapi import FastAPI # --- Crucial for finding your modules --- # Assuming app.py is at the project root level. # This ensures Python can find 'components' and 'routes' as packages. sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "components"))) sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "routes"))) # Add the routes directory # Add routes/api to path if you are doing 'from routes.api import module' directly sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "routes", "api"))) # Import your routers # These imports expect routes/api/ingest.py, routes/api/query.py, routes/api/headlines.py to exist from routes.api import ingest as ingest_router_module from routes.api import query as query_router_module # Assuming this exists from routes.api import headlines as headlines_router_module # NOTE: Settings.llm = None # This line is problematic if LlamaIndex components in your pipeline (like query engine) # rely on a global LLM setting. If you intend to use an LLM with LlamaIndex features, # you would set it here, e.g., `Settings.llm = OpenAI()` # For this current pipeline, the OpenAI client is initialized explicitly within # daily_feed.py and detailed_explainer.py, so setting Settings.llm here is not strictly needed # but also not harmful if it's just meant as a placeholder for a different use case. # I will leave it commented out as per your original request, but be aware of its implications. # Settings.llm = None app = FastAPI() @app.get("/") def greet(): return {"welcome": "nuse ai"} # Include your routers # Use .router to access the APIRouter instance from the imported modules app.include_router(ingest_router_module.router, prefix="/api/ingest") app.include_router(query_router_module.router, prefix="/api/query") # Assuming query.py exists app.include_router(headlines_router_module.router, prefix="/api/headlines")