Skip to content

Commit 8e352e6

Browse files
authored
Merge pull request #7 from ivankahl/feature/configurable-google-gemini-model
Feature: Made Gemini model variant configurable with environment variables
2 parents 88e5d9b + ef4ef66 commit 8e352e6

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ APP_PORT=3000
55
MAX_FILE_SIZE=
66

77
GEMINI_API_KEY=
8+
GEMINI_MODEL=
89

910
YNAB_API_KEY=
1011
YNAB_BUDGET_ID=

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ docker run \
3232
-e APP_API_KEY=your_api_key \
3333
-e APP_API_SECRET=your_api_secret \
3434
-e GEMINI_API_KEY=your_gemini_api_key \
35+
-e GEMINI_MODEL=gemini-2.0-flash-exp
3536
-e YNAB_API_KEY=your_ynab_api_key \
3637
-e YNAB_BUDGET_ID=your_ynab_budget_id \
3738
-p 3000:3000 \
3839
ivankahl/ynab-slip-uploader
3940
```
4041

41-
Replace the `your_gemini_api_key`, `your_ynab_api_key`, and `your_ynab_budget_id` placeholders with your Google Gemini and YNAB API credentials. You should also replace `your_ynab_budget_id` with the ID of your YNAB budget. The application is secured using basic authentication, with `your_api_key` as the username and `your_api_secret` as the password.
42+
Replace the `your_gemini_api_key`, `your_ynab_api_key`, and `your_ynab_budget_id` placeholders with your Google Gemini and YNAB API credentials. You should also replace `your_ynab_budget_id` with the ID of your YNAB budget. The application is secured using basic authentication, with `your_api_key` as the username and `your_api_secret` as the password. You can customize which Gemini model should be used with the `GEMINI_MODEL` variable.
4243

4344
Finally, you can provide a comma-separated list of category groups if you want to limit which envelopes should be considered when classifying transactions. Leaving it empty means all envelopes will be used.
4445

@@ -91,6 +92,7 @@ The following environment variables let you configure the application:
9192
| Environment Variable | Required | Description |
9293
| ---------------------- | -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
9394
| `GEMINI_API_KEY` | Required | Your Google Gemini API key which you can generate [here](https://aistudio.google.com/app/apikey). |
95+
| `GEMINI_MODEL` | Required | The [Gemini model variant](https://ai.google.dev/gemini-api/docs/models/gemini) you want to use. Minimum required variant is Gemini 1.5 and up as these support structured outputs. |
9496
| `YNAB_API_KEY` | Required | Your YNAB Account API Key which y can generate [here](https://app.ynab.com/settings/developer). |
9597
| `YNAB_BUDGET_ID` | Required | The ID of your YNAB budget. You'll find this in the URL when viewing your budget on YNAB. |
9698
| `YNAB_CATEGORY_GROUPS` | Optional | A comma-separated list of category group names that should be considered when categorizing the transaction. If left blank, all categories will be used. |

services/gen-ai.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { Receipt } from "./shared-types";
88

99
const genAI = new GoogleGenerativeAI(env.GEMINI_API_KEY);
1010
const model = genAI.getGenerativeModel({
11-
model: "gemini-2.0-flash-exp",
11+
model: env.GEMINI_MODEL,
1212
systemInstruction: `Please process this slip. Categorize each line item individually based on the line item description. You should also provide a category for the entire slip based on the highest spent category in the line items. If there are no line items, use the name of the merchant to try and determine the category. Provide a very short memo which summarises what products were purchased. Output the transaction date in the format: 'YYYY-MM-DD'. If the slip doesn't have the full date, use the current date, which is ${new Date().toDateString()}, to try determine the full date`,
1313
});
1414

utils/env-vars.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { z } from "zod";
22

33
const envScheme = z.object({
44
GEMINI_API_KEY: z.string().nonempty(),
5+
GEMINI_MODEL: z.string().nonempty(),
56
YNAB_API_KEY: z.string().nonempty(),
67
YNAB_BUDGET_ID: z.string().nonempty(),
78
YNAB_CATEGORY_GROUPS: z

0 commit comments

Comments
 (0)