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
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ COPY runners /app/runners
RUN chmod +x /app/runners/setup.sh
ENTRYPOINT ["/app/runners/setup.sh"]

# Copy static-data folder for budgets and grades
COPY static-data /app/static-data

# Optional .env copy for development
FROM base AS local
COPY .env /app/.env
12 changes: 5 additions & 7 deletions parser/budgetsParser.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ package parser

import (
"context"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
Expand All @@ -29,7 +27,8 @@ import (
)

// What gets sent to Gemini, with the PDF content added
// WARNING: Changes to this prompt will invalidate all cached AI responses, only change if necessary
// WARNING: Changes to this prompt WILL NOT invalidate cached AI responses. Caching is made only based off of year
// FOR CHANGES TO THIS PROMPT TO TAKE EFFECT THE GCP CACHE FILE MUST BE DELETED MANUALLY. The API project lead can do this for a PR
var budgetPrompt = `Parse the content of these PDFs and generate the following JSON schema.

{
Expand Down Expand Up @@ -414,9 +413,8 @@ func parseBudgetPdfs(paths []string) (schema.Budget, error) {
promptFilled := fmt.Sprintf(budgetPrompt, year, year, content)

// Check cache
hashByte := sha256.Sum256([]byte(promptFilled))
hash := hex.EncodeToString(hashByte[:]) + ".json"
result, err := utils.CheckCache(hash, apiBucket)
cacheName := year + ".json"
result, err := utils.CheckCache(cacheName, apiBucket)
if err != nil {
return schema.Budget{}, err
}
Expand Down Expand Up @@ -452,7 +450,7 @@ func parseBudgetPdfs(paths []string) (schema.Budget, error) {
result = response.Candidates[0].Content.Parts[0].Text

// Set cache for next time
err = utils.SetCache(hash, result, apiBucket)
err = utils.SetCache(cacheName, result, apiBucket)
if err != nil {
return schema.Budget{}, err
}
Expand Down
Loading