Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -17,17 +17,14 @@ import os
|
|
17 |
ph = st.empty()
|
18 |
|
19 |
async def syncMessages():
|
20 |
-
print(os.listdir(f"data"))
|
21 |
if os.listdir("data") == []:
|
22 |
return 0
|
23 |
-
ph.empty()
|
24 |
with ph.container():
|
25 |
dirs = st.tabs(os.listdir("data"))
|
26 |
i = -1
|
27 |
for dir in os.listdir("data"):
|
28 |
i += 1
|
29 |
with dirs[i]:
|
30 |
-
print(i, os.listdir(f"data/{dir}"))
|
31 |
if os.listdir(f"data/{dir}") == []:
|
32 |
return 0
|
33 |
files = st.tabs(os.listdir("data/" + dir))
|
@@ -37,7 +34,6 @@ async def syncMessages():
|
|
37 |
with files[k]:
|
38 |
with open(f"data/{dir}/{file}", "r") as f:
|
39 |
o = f.read().split("<|end_of_turn|>")
|
40 |
-
print(o)
|
41 |
for item in o:
|
42 |
if item == "":
|
43 |
continue
|
@@ -56,6 +52,7 @@ else:
|
|
56 |
while True:
|
57 |
asyncio.run(syncMessages())
|
58 |
time.sleep(0.5)
|
|
|
59 |
|
60 |
try:
|
61 |
os.mkdir("data")
|
@@ -72,7 +69,7 @@ LLM = InferenceClient(model="openchat/openchat-3.5-0106")
|
|
72 |
RF = InferenceClient(model="stabilityai/stable-diffusion-xl-refiner-1.0")
|
73 |
|
74 |
|
75 |
-
def ec(x, fd="
|
76 |
matches = re.findall(re.escape(fd) + "(.*?)" + re.escape(sd), x)
|
77 |
matches = matches if matches else [""]
|
78 |
return matches
|
@@ -144,14 +141,14 @@ async def on_message(message):
|
|
144 |
s = f":green[{message.author}]: :violet[{message.content}] :blue[{msgchannel_name}] :orange[{guild_name}]"
|
145 |
if message.author == client.user:
|
146 |
return
|
147 |
-
sysp = """GPT4 Correct
|
148 |
You must use the markdown format for your responses.
|
149 |
Do not excessively use bullet points.
|
150 |
Use emojis at the start of your responses.
|
151 |
-
Use
|
152 |
Your title must summarize the user's message.
|
153 |
-
If the user asks you to generate an image, use the start tag
|
154 |
-
For example, if the user asks you to generate an image of a cat, you would say
|
155 |
Always include a title.
|
156 |
Do not generate images unless the user speciifes that they want an image."""
|
157 |
try:
|
@@ -176,7 +173,7 @@ async def on_message(message):
|
|
176 |
if "Feeway" in guild_name:
|
177 |
async with msgchannel.typing():
|
178 |
context += f"GPT4 Correct Assistant:"
|
179 |
-
title = ec(context, "
|
180 |
imgp = ec(context)[0]
|
181 |
load = random.choice(
|
182 |
[
|
@@ -193,7 +190,7 @@ async def on_message(message):
|
|
193 |
f.write(f"GPT4 Correct Assistant: {output}<|end_of_turn|>")
|
194 |
embed = discord.Embed(title=title,
|
195 |
description=output.replace(
|
196 |
-
f"
|
197 |
color=0x1E81B0)
|
198 |
embed.set_footer(
|
199 |
text=
|
|
|
17 |
ph = st.empty()
|
18 |
|
19 |
async def syncMessages():
|
|
|
20 |
if os.listdir("data") == []:
|
21 |
return 0
|
|
|
22 |
with ph.container():
|
23 |
dirs = st.tabs(os.listdir("data"))
|
24 |
i = -1
|
25 |
for dir in os.listdir("data"):
|
26 |
i += 1
|
27 |
with dirs[i]:
|
|
|
28 |
if os.listdir(f"data/{dir}") == []:
|
29 |
return 0
|
30 |
files = st.tabs(os.listdir("data/" + dir))
|
|
|
34 |
with files[k]:
|
35 |
with open(f"data/{dir}/{file}", "r") as f:
|
36 |
o = f.read().split("<|end_of_turn|>")
|
|
|
37 |
for item in o:
|
38 |
if item == "":
|
39 |
continue
|
|
|
52 |
while True:
|
53 |
asyncio.run(syncMessages())
|
54 |
time.sleep(0.5)
|
55 |
+
exit()
|
56 |
|
57 |
try:
|
58 |
os.mkdir("data")
|
|
|
69 |
RF = InferenceClient(model="stabilityai/stable-diffusion-xl-refiner-1.0")
|
70 |
|
71 |
|
72 |
+
def ec(x, fd="<|image|>", sd="<|image|>"):
|
73 |
matches = re.findall(re.escape(fd) + "(.*?)" + re.escape(sd), x)
|
74 |
matches = matches if matches else [""]
|
75 |
return matches
|
|
|
141 |
s = f":green[{message.author}]: :violet[{message.content}] :blue[{msgchannel_name}] :orange[{guild_name}]"
|
142 |
if message.author == client.user:
|
143 |
return
|
144 |
+
sysp = """GPT4 Correct System: You are lr, a discord bot. You were made by Araeyn.
|
145 |
You must use the markdown format for your responses.
|
146 |
Do not excessively use bullet points.
|
147 |
Use emojis at the start of your responses.
|
148 |
+
Use <|title|> at the start of your title for the response and <|title|> at the end of the title.
|
149 |
Your title must summarize the user's message.
|
150 |
+
If the user asks you to generate an image, use the start tag <|image|> and the end tag <|image|> around the prompt to generate it. Put this at the end of your response. Do not use a link for the image.
|
151 |
+
For example, if the user asks you to generate an image of a cat, you would say <|image|>A cute cat with long fur that is looking out a window with curious eyes.<|image|>
|
152 |
Always include a title.
|
153 |
Do not generate images unless the user speciifes that they want an image."""
|
154 |
try:
|
|
|
173 |
if "Feeway" in guild_name:
|
174 |
async with msgchannel.typing():
|
175 |
context += f"GPT4 Correct Assistant:"
|
176 |
+
title = ec(context, "<|title|>", "<|title|>")[0]
|
177 |
imgp = ec(context)[0]
|
178 |
load = random.choice(
|
179 |
[
|
|
|
190 |
f.write(f"GPT4 Correct Assistant: {output}<|end_of_turn|>")
|
191 |
embed = discord.Embed(title=title,
|
192 |
description=output.replace(
|
193 |
+
f"<|title|>{title}<|title|>", ""),
|
194 |
color=0x1E81B0)
|
195 |
embed.set_footer(
|
196 |
text=
|