README and License

This commit is contained in:
Laurie Voss
2025-04-30 10:48:15 -07:00
parent 963b6b7d2e
commit 67932384a4
2 changed files with 56 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
The MIT License
Copyright (c) Laurie Voss
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+35
View File
@@ -0,0 +1,35 @@
# LlamaIndex Invoice Reconciler
This is a full-stack web app showing how to use LlamaCloud with the LlamaIndex.TS framework to produce a real-world application, in this case matching the terms of contracts against incoming invoices from the contracted companies, aka "invoice reconciliation".
## User flow
1. The user uploads one or more contracts to the app
2. These are indexed and made searchable by the app
3. The user uploads one or more invoices to the app
4. The app determines which contract each invoice applies to
5. It examines the terms of the contract and the invoice details and flags any discrepancies
6. It shows the user the results
## Under the hood
1. The user "logs in" by providing a LlamaCloud API key. This is used to create a LlamaCloud index. (The API key is stored in localStorage, as are other settings. This is not a good practice, but it kept the code simple for a demonstration)
2. Uploaded invoices are uploaded to the LlamaCloud index, which parses them and then stores the parsed chunks in a vector database. The LlamaCloud index also stores the parsed documents and original file names in the metadata, which we use to display them on the frontend.
3. When a user uploads an invoice, we parse it with LlamaParse. Then an LLM call extracts the name of the company that issued the invoice, and runs a retrieval query again the LlamaCloud index with that name.
4. The chunk with the highest match to the name is taken as the contract that the invoice applies to. We retrieve the entire parsed contract from the index.
5. A further LLM call compares the entire parsed contract against the full parsed invoice, and asks it to flag discrepancies. Because this is a complex task, we use OpenAI's o3-mini model for this.
6. The parsed invoices and any discrepancies are returned to the frontend.
## Running the app
The frontend is a vanilla Next.js application. It requires a `.env.local` file with a single variable, your `OPENAI_API_KEY`. Everything else is handled by LlamaCloud and credentials are stored on the client (insecurely!). You can run the app as normal:
```bash
npm install
npm run dev
```