Araeynn commited on
Commit
2cef94c
·
verified ·
1 Parent(s): c207558

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -3
app.py CHANGED
@@ -41,6 +41,33 @@ async def syncMessages():
41
  item = item.split(": ", 1)
42
  st.markdown(f":blue[{item[0].split('GPT4 Correct ')[1]}]: {item[1]}")
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  lock_file_path = "test.txt"
45
 
46
  if not os.path.exists(lock_file_path):
@@ -49,9 +76,7 @@ if not os.path.exists(lock_file_path):
49
  else:
50
  print("Streamlit app is already running, only streaming bot activity.")
51
  while True:
52
- asyncio.run(syncMessages())
53
- time.sleep(0.5)
54
-
55
 
56
  try:
57
  os.mkdir("data")
 
41
  item = item.split(": ", 1)
42
  st.markdown(f":blue[{item[0].split('GPT4 Correct ')[1]}]: {item[1]}")
43
 
44
+ def syncViewMessages():
45
+ print(os.listdir(f"data"))
46
+ if os.listdir("data") == []:
47
+ return 0
48
+ with ph.container():
49
+ dirs = st.tabs(os.listdir("data"))
50
+ i = -1
51
+ for dir in os.listdir("data"):
52
+ i += 1
53
+ with dirs[i]:
54
+ print(i, os.listdir(f"data/{dir}"))
55
+ if os.listdir(f"data/{dir}") == []:
56
+ return 0
57
+ files = st.tabs(os.listdir("data/" + dir))
58
+ k = -1
59
+ for file in os.listdir("data/" + dir):
60
+ k += 1
61
+ with files[k]:
62
+ with open(f"data/{dir}/{file}", "r") as f:
63
+ o = f.read().split("<|end_of_turn|>")
64
+ print(o)
65
+ for item in o:
66
+ if item == "":
67
+ continue
68
+ item = item.split(": ", 1)
69
+ st.markdown(f":blue[{item[0].split('GPT4 Correct ')[1]}]: {item[1]}")
70
+
71
  lock_file_path = "test.txt"
72
 
73
  if not os.path.exists(lock_file_path):
 
76
  else:
77
  print("Streamlit app is already running, only streaming bot activity.")
78
  while True:
79
+ syncViewMessages()
 
 
80
 
81
  try:
82
  os.mkdir("data")