diff --git a/.gitignore b/.gitignore index ad30117..675022a 100644 --- a/.gitignore +++ b/.gitignore @@ -149,3 +149,6 @@ cython_debug/ # OS X .DS_Store + +# User custom folders +external_component/ diff --git a/app/main.py b/app/main.py index 796b493..b62ddb6 100644 --- a/app/main.py +++ b/app/main.py @@ -35,7 +35,7 @@ def create_application() -> FastAPI: application.add_middleware( CORSMiddleware, allow_origins=["*"], - allow_credentials=True, + allow_credentials=False, # Changed to False for better compat with allow_origins=["*"] allow_methods=["*"], allow_headers=["*"], ) diff --git a/implementation_plan.md b/implementation_plan.md deleted file mode 100644 index c1d3ea0..0000000 --- a/implementation_plan.md +++ /dev/null @@ -1,51 +0,0 @@ -# Storyline AI Gateway - Implementation Plan - -## Project Overview -A FastAPI-based gateway for e-learning modules (Articulate Storyline) to access LLM services (Gemini, OpenAI) with centralized authentication and rate limiting. - -## Tech Stack -- **Framework**: FastAPI -- **Server**: Uvicorn -- **Rate Limiting**: Slowapi (limiter) -- **Auth**: Header-based API Key (`X-API-Key`) -- **LLMs**: Google Gemini, OpenAI - -## Directory Structure -- `app/main.py`: Application entry point and middleware configuration. -- `app/core/`: Configuration and utilities (limiter, settings). -- `app/api/deps.py`: Shared dependencies (authentication). -- `app/api/router.py`: API versioning and route aggregation. -- `app/api/endpoints/`: - - `storyline.py`: Generic endpoint. - - `gemini.py`: Dedicated Gemini endpoint. - - `openai.py`: Dedicated OpenAI endpoint. - -## Configuration -Managed via `.env` file: -- `API_KEY`: Secret key for Storyline modules. -- `GOOGLE_API_KEY`: API key for Google Generative AI. -- `OPENAI_API_KEY`: API key for OpenAI. -- `PORT`: Server port (default 8000). - -## API Endpoints -All endpoints are versioned under `/api/v1`. - -### 1. Gemini Chat -- **URL**: `/api/v1/gemini/chat` -- **Method**: POST -- **Headers**: `X-API-Key: ` -- **Body**: `{"prompt": "string", "context": "string"}` - -### 2. OpenAI Chat -- **URL**: `/api/v1/openai/chat` -- **Method**: POST -- **Headers**: `X-API-Key: ` -- **Body**: `{"prompt": "string", "context": "string"}` - -## Rate Limiting -- Applied globally/per endpoint: **20 calls per minute**. - -## Future Steps -- Add logging (WandB or file-based). -- Implement response caching. -- Add more LLM providers (Anthropic, etc.). diff --git a/update_schema.py b/update_schema.py deleted file mode 100644 index a43f625..0000000 --- a/update_schema.py +++ /dev/null @@ -1,30 +0,0 @@ -from sqlalchemy import create_engine, text -from app.core.config import settings - -def update_schema(): - engine = create_engine(settings.DATABASE_URL) - with engine.connect() as conn: - print("Adding token tracking columns to modules table...") - try: - conn.execute(text("ALTER TABLE modules ADD COLUMN ingress_tokens INTEGER DEFAULT 0")) - print("Added ingress_tokens column.") - except Exception as e: - print(f"ingress_tokens column might already exist: {e}") - - try: - conn.execute(text("ALTER TABLE modules ADD COLUMN egress_tokens INTEGER DEFAULT 0")) - print("Added egress_tokens column.") - except Exception as e: - print(f"egress_tokens column might already exist: {e}") - - try: - conn.execute(text("ALTER TABLE modules ADD COLUMN total_tokens INTEGER DEFAULT 0")) - print("Added total_tokens column.") - except Exception as e: - print(f"total_tokens column might already exist: {e}") - - conn.commit() - print("Schema update complete.") - -if __name__ == "__main__": - update_schema()