Spaces:
Sleeping
Sleeping
oscarwang2
commited on
Commit
•
59eab61
1
Parent(s):
8d8e72d
Update app.py
Browse files
app.py
CHANGED
@@ -8,9 +8,15 @@ import time
|
|
8 |
client = Groq()
|
9 |
max_size = 1.1 * 1024 * 1024 * 1024 # 1.1GB in bytes
|
10 |
file_index = 1
|
11 |
-
|
|
|
12 |
file_paths = [current_file]
|
13 |
combined_tokens = 0
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
def get_file_size(filename):
|
16 |
if os.path.isfile(filename):
|
@@ -31,7 +37,7 @@ def generate_and_save_data():
|
|
31 |
}
|
32 |
],
|
33 |
temperature=1,
|
34 |
-
max_tokens=
|
35 |
top_p=1,
|
36 |
stream=True,
|
37 |
stop=None,
|
@@ -55,7 +61,7 @@ def generate_and_save_data():
|
|
55 |
}
|
56 |
],
|
57 |
temperature=1,
|
58 |
-
max_tokens=
|
59 |
top_p=1,
|
60 |
stream=True,
|
61 |
stop=None,
|
@@ -82,7 +88,7 @@ def generate_and_save_data():
|
|
82 |
# Check the size of the current file
|
83 |
if get_file_size(current_file) >= max_size:
|
84 |
file_index += 1
|
85 |
-
current_file = f'data{file_index}.csv'
|
86 |
file_paths.append(current_file)
|
87 |
|
88 |
# Check if the current file exists
|
@@ -94,6 +100,9 @@ def generate_and_save_data():
|
|
94 |
else:
|
95 |
data.to_csv(current_file, mode='w', header=True, index=False)
|
96 |
|
|
|
|
|
|
|
97 |
except Exception as e:
|
98 |
print(f"An error occurred: {e}. Retrying in 5 seconds...")
|
99 |
time.sleep(5)
|
|
|
8 |
client = Groq()
|
9 |
max_size = 1.1 * 1024 * 1024 * 1024 # 1.1GB in bytes
|
10 |
file_index = 1
|
11 |
+
data_directory = 'data'
|
12 |
+
current_file = os.path.join(data_directory, f'data{file_index}.csv')
|
13 |
file_paths = [current_file]
|
14 |
combined_tokens = 0
|
15 |
+
update_interval = 1 # Update interval in seconds
|
16 |
+
|
17 |
+
# Ensure the data directory exists
|
18 |
+
if not os.path.exists(data_directory):
|
19 |
+
os.makedirs(data_directory)
|
20 |
|
21 |
def get_file_size(filename):
|
22 |
if os.path.isfile(filename):
|
|
|
37 |
}
|
38 |
],
|
39 |
temperature=1,
|
40 |
+
max_tokens=1024,
|
41 |
top_p=1,
|
42 |
stream=True,
|
43 |
stop=None,
|
|
|
61 |
}
|
62 |
],
|
63 |
temperature=1,
|
64 |
+
max_tokens=8000,
|
65 |
top_p=1,
|
66 |
stream=True,
|
67 |
stop=None,
|
|
|
88 |
# Check the size of the current file
|
89 |
if get_file_size(current_file) >= max_size:
|
90 |
file_index += 1
|
91 |
+
current_file = os.path.join(data_directory, f'data{file_index}.csv')
|
92 |
file_paths.append(current_file)
|
93 |
|
94 |
# Check if the current file exists
|
|
|
100 |
else:
|
101 |
data.to_csv(current_file, mode='w', header=True, index=False)
|
102 |
|
103 |
+
# Wait for the next update interval
|
104 |
+
time.sleep(update_interval)
|
105 |
+
|
106 |
except Exception as e:
|
107 |
print(f"An error occurred: {e}. Retrying in 5 seconds...")
|
108 |
time.sleep(5)
|