srigg commited on
Commit
a2cf8c3
·
verified ·
1 Parent(s): b57e83b

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -12,9 +12,20 @@ import gradio as gr
12
  # Load environment variables
13
  load_dotenv()
14
 
 
 
 
 
15
  # Load the rules
16
- with open('rules.txt', 'r') as file:
17
- golf_rules = file.read()
 
 
 
 
 
 
 
18
 
19
  # First split on major rule boundaries
20
  major_splitter = RecursiveCharacterTextSplitter(
 
12
  # Load environment variables
13
  load_dotenv()
14
 
15
+ # Get the directory where the script is located
16
+ SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
17
+ RULES_PATH = os.path.join(SCRIPT_DIR, 'rules.txt')
18
+
19
  # Load the rules
20
+ try:
21
+ with open(RULES_PATH, 'r') as file:
22
+ golf_rules = file.read()
23
+ except FileNotFoundError:
24
+ print(f"Error: Could not find rules.txt at {RULES_PATH}")
25
+ golf_rules = ""
26
+
27
+ if not golf_rules:
28
+ raise RuntimeError("Failed to load golf rules. Please ensure rules.txt is present in the repository.")
29
 
30
  # First split on major rule boundaries
31
  major_splitter = RecursiveCharacterTextSplitter(