Spaces:
Sleeping
Sleeping
Create utilities/setup.py
Browse files- utilities/setup.py +28 -0
utilities/setup.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import os
|
3 |
+
from datasets import load_dataset
|
4 |
+
|
5 |
+
class get_files:
|
6 |
+
|
7 |
+
def load_markdown_file(file_path):
|
8 |
+
try:
|
9 |
+
with open(file_path, 'r') as f:
|
10 |
+
return f.read()
|
11 |
+
except FileNotFoundError:
|
12 |
+
return "File not found. Please check the file path."
|
13 |
+
except Exception as e:
|
14 |
+
return f"Error loading file: {str(e)}"
|
15 |
+
|
16 |
+
def json_cfg():
|
17 |
+
"""Retrieve configuration file"""
|
18 |
+
config_path = os.getenv('CONFIG_PATH')
|
19 |
+
with open(config_path, 'r') as file:
|
20 |
+
config = json.load(file)
|
21 |
+
return config
|
22 |
+
|
23 |
+
def get_keys():
|
24 |
+
"Get keys required to set up loading"
|
25 |
+
return {
|
26 |
+
"huggingface": os.environ["HUGGINGFACE_TOKEN"],
|
27 |
+
"openai": "", # leaving this alone for future use.
|
28 |
+
}
|