Skip to content

Commit

Permalink
added config parsing to decide email addresses and operation mode
Browse files Browse the repository at this point in the history
  • Loading branch information
AntounMichael committed Nov 12, 2023
1 parent b567551 commit 02fc7b4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"Emails": [],
"emails": ["[email protected]", "[email protected]"],
"DEBUG": false
}
27 changes: 24 additions & 3 deletions document_analysis.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import re

from VectorDatabase import Lantern, Publication
Expand All @@ -18,13 +19,33 @@ class DocumentAnalyzer:
aggregates the results, and reports the results to the spreadsheet
"""

CONFIG_PATH = "./config.json"

def __init__(self):
self.lantern = Lantern()
self.sheets = SheetsApiClient()
self.llm = LlmHandler()

self.email_addresses = []
self.notification_via_email = True
self.email_addresses, self.notification_via_email = self.parse_config()

@staticmethod
def parse_config():
try:
with open(DocumentAnalyzer.CONFIG_PATH, 'r') as config_file:
config_data = json.load(config_file)

# Extracting fields from the config_data
my_list = config_data.get('emails', []) # Default to an empty list if 'my_list' is not present
my_bool = config_data.get('DEBUG', False) # Default to False if 'my_bool' is not present

return my_list, my_bool

except FileNotFoundError:
print(f"Config file '{DocumentAnalyzer.CONFIG_PATH}' not found. Using defaults (no email addresses)")
return [], False
except json.JSONDecodeError as e:
print(f"Error decoding JSON in '{DocumentAnalyzer.CONFIG_PATH}': {e}")
return None, None

def analyze_all_unread(self):
"""pulls all new files from Lantern database, evaluates them, and publishes results to google sheets
Expand Down Expand Up @@ -162,7 +183,7 @@ def evaluate_queries(self, embedding, queries):

def main():
document_analyzer = DocumentAnalyzer()
document_analyzer.analyze_all_unread() # analyzes all new files in lantern db
#document_analyzer.analyze_all_unread() # analyzes all new files in lantern db


if __name__ == '__main__':
Expand Down

0 comments on commit 02fc7b4

Please sign in to comment.