-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode_test_conversation.py
34 lines (24 loc) · 1.02 KB
/
code_test_conversation.py
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
from EdgeGPT.EdgeUtils import Query, Cookie
from EdgeGPT.EdgeGPT import Chatbot, ConversationStyle
from datetime import datetime
from dotenv import load_dotenv
import telebot
import asyncio
import json
import os
cookies = json.loads(open("cookies.json", encoding="utf-8").read())
async def main():
bot_ai = await Chatbot.create(cookies = cookies)
while True:
prompt = input('Write your prompt: ')
time_prompt = datetime.now().strftime("%H:%M:%S")
if prompt.lower() != 'exit':
response = await bot_ai.ask(prompt = prompt, conversation_style = ConversationStyle.creative, simplify_response = True)
time_response = datetime.now().strftime("%H:%M:%S")
conversation = f"{time_prompt} Prompt:\n\n{prompt}\n\n{time_response} Response:\n\n{response['text']}\n\n"
with open("conversation.md", "a", encoding="utf-8") as file: file.write(conversation)
else:
await bot_ai.close()
break
if __name__ == "__main__":
asyncio.run(main())