Araeynn commited on
Commit
ff9f74b
·
verified ·
1 Parent(s): e28e494

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -1,4 +1,3 @@
1
- print("Started.")
2
  import json
3
  import os
4
  import re
@@ -63,7 +62,7 @@ async def syncMessages():
63
  item = item.split(": ", 1)
64
  if len(item) < 2:
65
  return 0
66
- st.markdown(f":blue[{item[0].split('GPT4 Correct ')[0]}]: {item[1]}")
67
 
68
  @client.event
69
  async def on_ready():
@@ -113,16 +112,18 @@ async def on_message(message):
113
  sysp = """You are Lyre, a helpful discord chatbot. Respond in markdown. Your username is lyre#9828."""
114
  try:
115
  os.mkdir("data/" + guild_name)
116
- with open(f"data/{guild_name}/{msgchannel_name}", "w") as f:
117
- f.write(
118
- f"GPT4 Correct system: {sysp}<|end_of_turn|>GPT4 Correct {message.author}: {message.content}<|end_of_turn|>"
119
- )
120
  except:
121
- with open(f"data/{guild_name}/{msgchannel_name}", "a") as f:
 
122
  n = "\n"
123
  f.write(
124
  f"""GPT4 Correct {message.author.name}: {message.content.strip(n)}<|end_of_turn|>"""
125
  )
 
 
 
 
 
126
  finally:
127
  with open(f"data/{guild_name}/{msgchannel_name}", "r") as f:
128
  context = f.read()
 
 
1
  import json
2
  import os
3
  import re
 
62
  item = item.split(": ", 1)
63
  if len(item) < 2:
64
  return 0
65
+ st.markdown(f":blue[{item[0].split('GPT4 Correct ')[1]}]: {item[1]}")
66
 
67
  @client.event
68
  async def on_ready():
 
112
  sysp = """You are Lyre, a helpful discord chatbot. Respond in markdown. Your username is lyre#9828."""
113
  try:
114
  os.mkdir("data/" + guild_name)
 
 
 
 
115
  except:
116
+ try:
117
+ with open(f"data/{guild_name}/{msgchannel_name}", "a") as f:
118
  n = "\n"
119
  f.write(
120
  f"""GPT4 Correct {message.author.name}: {message.content.strip(n)}<|end_of_turn|>"""
121
  )
122
+ except error:
123
+ with open(f"data/{guild_name}/{msgchannel_name}", "w") as f:
124
+ f.write(
125
+ f"GPT4 Correct system: {sysp}<|end_of_turn|>GPT4 Correct {message.author}: {message.content}<|end_of_turn|>"
126
+ )
127
  finally:
128
  with open(f"data/{guild_name}/{msgchannel_name}", "r") as f:
129
  context = f.read()