This adds a small FastAPI wrapper around the existing INVOICE.PY utilities.
Endpoints:
- POST /upload - upload a PDF file; it will be indexed (one embedding per doc) and a parsed JSON file saved.
- GET /search?q=... - run a semantic search and return top hits.
How to run (dev):
- Ensure dependencies are installed (prefer the project's venv):
pip install -r requirements.txt- Ensure your
GOOGLE_API_KEYis available:
- Create a
.envfile at the project root withGOOGLE_API_KEY=...(the app loads it automatically), or export it in your shell.
- Start the server:
uvicorn app:app --reload --host 0.0.0.0 --port 8000- Open the API docs at
http://localhost:8000/docsto upload or search.
Notes:
- If
chromadbor the generative API is not available, the app falls back to a local JSON index and a hash-based embedding. - Do not commit
.env— it's in.gitignore.