Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 15 additions & 19 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# .env.example
# Application
APP_ENV=development
APP_HOST=0.0.0.0
Expand All @@ -7,15 +6,21 @@ APP_WORKERS=1
LOG_LEVEL=INFO

# Database
DATABASE_URL=postgresql+asyncpg://user:pass@localhost:5432/docintel
DATABASE_URL=sqlite+aiosqlite:///:memory:
DATABASE_POOL_SIZE=10
DATABASE_MAX_OVERFLOW=20
DATABASE_POOL_TIMEOUT=30
DATABASE_POOL_RECYCLE=3600
DATABASE_ECHO=false

# Anthropic
ANTHROPIC_API_KEY=sk-ant-xxxxxxxxxxxxx
# Anthropic / Claude
ANTHROPIC_API_KEY=your-api-key-here
ANTHROPIC_MODEL=claude-3-5-sonnet-20241022
ANTHROPIC_MAX_TOKENS=4096
ANTHROPIC_TEMPERATURE=0.1
ANTHROPIC_TIMEOUT=60
ANTHROPIC_MAX_RETRIES=3
ANTHROPIC_RETRY_WAIT=2

# Authentication
API_KEY_PREFIX=di_
Expand All @@ -26,23 +31,14 @@ RATE_LIMIT_WINDOW=60
# Storage
STORAGE_PROVIDER=local
LOCAL_STORAGE_PATH=/app/data/uploads
AZURE_STORAGE_ACCOUNT=
AZURE_STORAGE_CONTAINER=documents
AZURE_STORAGE_CONNECTION_STRING=

# Azure Key Vault
AZURE_KEY_VAULT_URL=

# Azure Monitor / OpenTelemetry
AZURE_MONITOR_CONNECTION_STRING=
OTEL_SERVICE_NAME=document-intelligence-api
OTEL_EXPORTER_OTLP_ENDPOINT=

# File Processing
MAX_FILE_SIZE_MB=50
ALLOWED_MIME_TYPES=application/pdf,text/plain,application/vnd.openxmlformats-officedocument.wordprocessingml.document,image/png,image/jpeg,image/tiff

# Processing
OCR_LANGUAGE=eng
MAX_TEXT_LENGTH=100000

# CORS
CORS_ORIGINS=["*"]
CORS_ALLOW_CREDENTIALS=true
CORS_ALLOW_CREDENTIALS=true
CORS_ALLOW_METHODS=["*"]
CORS_ALLOW_HEADERS=["*"]
97 changes: 51 additions & 46 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,73 +2,78 @@ name: CI

on:
push:
branches: [main, develop]
branches: [main, master]
pull_request:
branches: [main, develop]
branches: [main, master]

jobs:
lint:
name: Lint (ruff)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/ruff-action@v2
with:
version: "0.1.15"

typecheck:
name: Typecheck (mypy)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
- run: pip install -e .[dev]
- run: mypy app/

test:
name: Test (pytest)
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
image: postgres:16-alpine
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: docintel
ports: [5432:5432]
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: testdb
ports: ["5432:5432"]
options: >-
--health-cmd "pg_isready -U postgres"
--health-cmd "pg_isready -U test"
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
- run: pip install -e .[dev]
- name: Run tests with coverage
python-version: "3.12"
cache: pip

- name: Install dependencies
run: |
pip install -r requirements.txt
pip install pytest pytest-asyncio pytest-cov httpx

- name: Run tests
env:
DATABASE_URL: postgresql+asyncpg://postgres:postgres@localhost:5432/docintel
DATABASE_URL: postgresql+asyncpg://test:test@localhost:5432/testdb
ANTHROPIC_API_KEY: test-key
API_KEY_PREFIX: di_
run: pytest --cov=app --cov-report=xml --cov-fail-under=85
- uses: codecov/codecov-action@v4
APP_ENV: test
run: |
pytest -v --cov=app --cov-report=xml

- name: Upload coverage
uses: codecov/codecov-action@v4
with:
files: ./coverage.xml

build:
name: Build Docker image
lint:
runs-on: ubuntu-latest
needs: [lint, typecheck, test]
steps:
- uses: actions/checkout@v4
- uses: docker/build-push-action@v5
- name: Set up Python
uses: actions/setup-python@v5
with:
context: .
push: false
tags: docintel-api:test
load: true
python-version: "3.12"
- name: Install ruff
run: pip install ruff
- name: Run ruff
run: ruff check app tests

docker:
runs-on: ubuntu-latest
needs: [test, lint]
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Build Docker image
run: docker build -t doc-intel-api .
- name: Test Docker image
run: |
docker run -d --name test -p 8000:8000 -e ANTHROPIC_API_KEY=test doc-intel-api
sleep 10
curl -f http://localhost:8000/health/live
docker stop test
Loading
Loading