-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcohor_2.py
More file actions
52 lines (40 loc) · 1.1 KB
/
cohor_2.py
File metadata and controls
52 lines (40 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import discord
import cohere
import os
from cohor import convo
import json
intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)
def save_prompt(prompt:str):
with open('prompt.txt', 'w') as f:
f.write(prompt)
def load_prompt():
try:
with open('prompt.txt', 'r') as f:
return f.read()
except:
return ""
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
Intial_prompt = load_prompt()
if message.author == client.user:
return
else:
new_prompt = f"""
--
patient: {message.content}
"""
Intial_prompt = Intial_prompt+new_prompt
res = convo(Intial_prompt)
Intial_prompt = Intial_prompt+res
print(Intial_prompt)
save_prompt(Intial_prompt)
await message.channel.send(res)
client.run('MTA2NjI0MDY4NzA1OTc2NzM3Ng.GoGIEL.LPNUdXT_0uw6gg6kVUfnx2XpquvvlfkDaocQVw')