afnan007 commited on
Commit
da61da5
β€’
1 Parent(s): 6f5cd3c

Upload 5 files

Browse files
pixelpal.sh ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Check if gnome-terminal is available
4
+ if command -v gnome-terminal &> /dev/null; then
5
+ # Open a new terminal and execute the first command
6
+ gnome-terminal --tab --title="Chat 1" --command="bash -c 'python3 source/firefox_server.py --port 5001 --profile /tmp/chat1'"
7
+
8
+ # Open another terminal and execute the second command
9
+ gnome-terminal --tab --title="Chat 2" --command="bash -c 'python3 source/firefox_server.py --port 5002 --profile /tmp/chat2'"
10
+ else
11
+ # gnome-terminal is not available, use mate-terminal instead
12
+ # Open a new terminal and execute the first command
13
+ mate-terminal --title="Chat 1" -e "bash -c 'python3 source/firefox_server.py --port 5001 --profile /tmp/chat1'"
14
+
15
+ # Open another terminal and execute the second command
16
+ mate-terminal --title="Chat 2" -e "bash -c 'python3 source/firefox_server.py --port 5002 --profile /tmp/chat2'"
17
+ fi
18
+ python3 source/gpt_autoscript.py && fg
source/banner.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ print(" ")
2
+ print(" β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ ")
3
+ print(" β–ˆβ–„β”€β–„β–„β”€β–ˆβ–„β”€β–„β–ˆβ–„β”€β–€β”€β–„β–ˆβ–„β”€β–„β–„β”€β–ˆβ–„β”€β–„β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–„β”€β–„β–„β”€β–ˆβ–ˆβ–€β–„β”€β–ˆβ–ˆβ–„β”€β–„β–ˆβ–ˆβ–ˆ ")
4
+ print(" β–ˆβ–ˆβ”€β–„β–„β–„β–ˆβ–ˆβ”€β–ˆβ–ˆβ–ˆβ–€β”€β–€β–ˆβ–ˆβ–ˆβ”€β–„β–ˆβ–€β–ˆβ–ˆβ”€β–ˆβ–ˆβ–€β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ”€β–„β–„β–„β–ˆβ–ˆβ”€β–€β”€β–ˆβ–ˆβ–ˆβ”€β–ˆβ–ˆβ–€β–ˆ ")
5
+ print(" β–€β–„β–„β–„β–€β–€β–€β–„β–„β–„β–€β–„β–„β–ˆβ–„β–„β–€β–„β–„β–„β–„β–„β–€β–„β–„β–„β–„β–„β–€β–€β–€β–€β–€β–„β–„β–„β–€β–€β–€β–„β–„β–€β–„β–„β–€β–„β–„β–„β–„β–„β–€ ")
6
+ print(" ")
7
+ print(" Developed By Afnan")
8
+ print(" https://github.com/4fnan007")
9
+ print(" ")
10
+ print("Script is running... ")
11
+ print(" ")
12
+ print(" π™·πšŠπšŸπšŽ 𝚒𝚘𝚞 πšœπšŽπšŽπš— πš’πš˜πšžπš› πšπšŠπšŸπš˜πš›πš’πšπšŽ πšŒπš‘πšŠπš›πšŠπšŒπšπšŽπš›πšœ πšŒπš‘πšŠπšπšπš’πš—πš πšπš˜πšπšŽπšπš‘πšŽπš› πš™πš•πšŠπš—πš—πš’πš—πš πšœπš˜πš–πšŽπšπš‘πš’πš—πš here it is going on...")
13
+ print("(ctrl + c) to stop this nonsence")
14
+ print("______________________________________________________________________________________________________________")
15
+ print(" ")
source/char_prompt.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ I want you to act like {character_name} from {show_name}. I want you to respond and answer like {character_name} using the tone, manner and vocabulary {character_name} would use. Do not write any explanations. Only answer like {character_name}. You must know all of the knowledge of {character_name}. You need to use any sarcasm and slangs as {character_name} would use. and remember one thing i always act as a the character {opposite_character} from {opposite_show} so your {character_name} respose should be related to chatting with {opposite_character} So, My first chat prompt is: β€œ{question}”.
source/firefox_server.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import time
2
+ import os
3
+ import flask
4
+ import sys
5
+
6
+ from flask import g
7
+
8
+ from playwright.sync_api import sync_playwright
9
+
10
+ PROFILE_DIR = "/tmp/playwright" if '--profile' not in sys.argv else sys.argv[sys.argv.index('--profile') + 1]
11
+ PORT = 5001 if '--port' not in sys.argv else int(sys.argv[sys.argv.index('--port') + 1])
12
+ APP = flask.Flask(__name__)
13
+ PLAY = sync_playwright().start()
14
+ os.environ["PLAYWRIGHT_BROWSERS_PATH"] = "/usr/bin/firefox" # Set Firefox executable path
15
+ BROWSER = PLAY.firefox.launch_persistent_context(
16
+ user_data_dir=PROFILE_DIR,
17
+ headless=False,
18
+ )
19
+ PAGE = BROWSER.new_page()
20
+
21
+ def get_input_box():
22
+ """Find the input box by searching for the largest visible one."""
23
+ textareas = PAGE.query_selector_all("textarea")
24
+ candidate = None
25
+ for textarea in textareas:
26
+ if textarea.is_visible():
27
+ if candidate is None:
28
+ candidate = textarea
29
+ elif textarea.bounding_box().width > candidate.bounding_box().width:
30
+ candidate = textarea
31
+ return candidate
32
+
33
+ def is_logged_in():
34
+ try:
35
+ return get_input_box() is not None
36
+ except AttributeError:
37
+ return False
38
+
39
+ def send_message(message):
40
+ # Send the message
41
+ box = get_input_box()
42
+ box.click()
43
+ box.fill(message)
44
+ box.press("Enter")
45
+ while PAGE.query_selector(".result-streaming") is not None:
46
+ time.sleep(0.1)
47
+
48
+ def get_last_message():
49
+ """Get the latest message"""
50
+ page_elements = PAGE.query_selector_all(".flex.flex-col.items-center > div")
51
+ last_element = page_elements[-2]
52
+ return last_element.inner_text()
53
+
54
+ @APP.route("/chat", methods=["GET"])
55
+ def chat():
56
+ message = flask.request.args.get("q")
57
+ print("Sending message: ", message)
58
+ send_message(message)
59
+ response = get_last_message()
60
+ print("Response: ", response)
61
+ return response
62
+
63
+ def start_browser():
64
+ PAGE.goto("https://chat.openai.com/")
65
+ APP.run(port=PORT, threaded=False)
66
+ if not is_logged_in():
67
+ print("Please log in to OpenAI Chat")
68
+ print("Press enter when you're done")
69
+ input()
70
+ else:
71
+ print("Logged in")
72
+
73
+ if __name__ == "__main__":
74
+ start_browser()
source/gpt_autoscript.py ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import time
3
+ import os
4
+ import signal
5
+
6
+ def save_chat():
7
+ choice = input("\nDo you want to save the chat in the current directory? (y/n): ")
8
+ if choice.lower() == "y":
9
+ # Save the chat
10
+ with open("chat_log.txt", "w") as file:
11
+ file.write(chat_log)
12
+ print("Chat saved successfully.")
13
+ elif choice.lower() == "n":
14
+ print("Chat not saved.")
15
+ else:
16
+ print("Invalid choice. Chat not saved.")
17
+
18
+ exit(0)
19
+
20
+ def signal_handler(signal, frame):
21
+ save_chat()
22
+
23
+ signal.signal(signal.SIGINT, signal_handler)
24
+
25
+
26
+ print(" ")
27
+ print(" β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ ")
28
+ print(" β–ˆβ–„β”€β–„β–„β”€β–ˆβ–„β”€β–„β–ˆβ–„β”€β–€β”€β–„β–ˆβ–„β”€β–„β–„β”€β–ˆβ–„β”€β–„β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–„β”€β–„β–„β”€β–ˆβ–ˆβ–€β–„β”€β–ˆβ–ˆβ–„β”€β–„β–ˆβ–ˆβ–ˆ ")
29
+ print(" β–ˆβ–ˆβ”€β–„β–„β–„β–ˆβ–ˆβ”€β–ˆβ–ˆβ–ˆβ–€β”€β–€β–ˆβ–ˆβ–ˆβ”€β–„β–ˆβ–€β–ˆβ–ˆβ”€β–ˆβ–ˆβ–€β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ”€β–„β–„β–„β–ˆβ–ˆβ”€β–€β”€β–ˆβ–ˆβ–ˆβ”€β–ˆβ–ˆβ–€β–ˆ ")
30
+ print(" β–€β–„β–„β–„β–€β–€β–€β–„β–„β–„β–€β–„β–„β–ˆβ–„β–„β–€β–„β–„β–„β–„β–„β–€β–„β–„β–„β–„β–„β–€β–€β–€β–€β–€β–„β–„β–„β–€β–€β–€β–„β–„β–€β–„β–„β–€β–„β–„β–„β–„β–„β–€ ")
31
+ print(" π™·πšŠπšŸπšŽ 𝚒𝚘𝚞 πšœπšŽπšŽπš— πš’πš˜πšžπš› πšπšŠπšŸπš˜πš›πš’πšπšŽ πšŒπš‘πšŠπš›πšŠπšŒπšπšŽπš›πšœ πšŒπš‘πšŠπšπšπš’πš—πš πšπš˜πšπšŽπšπš‘πšŽπš› πš™πš•πšŠπš—πš—πš’πš—πš πšœπš˜πš–πšŽπšπš‘πš’πš—πš \n")
32
+ print(" Developed By Afnan")
33
+ print(" https://github.com/4fnan007")
34
+ time.sleep(1)
35
+ print("\nThis magnificent AutoGPT program act as a virtual characters within two separate ChatGPT instances,\nEngaging in autonomous conversation while embodying the persona of a beloved character from a specified movie or series.")
36
+ input("Provide the name of your fictional character and the TV show or movie in which they appeared for each instance for autochat. \n \nIf you understand what am saying just press Enter...\n")
37
+ print("____________________________________(ᴘΙͺxα΄‡ΚŸ α΄˜α΄€ΚŸ)____________________________________")
38
+ show_name1 = input("\nEnter the name of the TV show or Movie that your character is appeared: ")
39
+ character_name1 = input("Enter the name of character played in that TV show or movie: ")
40
+ print(f"\n(0_0) => Okay cool broo!! So your first character instance is {character_name1} from {show_name1}.\n\n")
41
+ show_name2 = input("Enter the name of the TV show or Movie that your character is appeared for next GPT instance: ")
42
+ character_name2 = input("Enter the name of character played in that TV show or movie: ")
43
+ input(f"\n(0-0) => Alright than your second character instance is {character_name2} from {show_name2}.\nPress Enter to confirm...\n")
44
+ metaprompt = (' ')
45
+ time.sleep(1)
46
+ os.system('clear')
47
+ print("____________________________________(ᴘΙͺxα΄‡ΚŸ α΄˜α΄€ΚŸ)____________________________________")
48
+ print("\nGreat! Let's start the conversation between your two characters.\n")
49
+ print(f"Who need to ask chat prompt or question first")
50
+ value = input(f"Enter '1' if you want {character_name1} to ask the first question, or enter '2' if you want {character_name2} to ask the first question: ")
51
+ if value == "1":
52
+ question = input(f"What do you want to ask {character_name2} from {character_name1}: ")
53
+ if os.path.exists('source/char_prompt.txt'):
54
+ with open('source/char_prompt.txt', 'r') as file:
55
+ words = file.read().split()
56
+ else:
57
+ with open('char_prompt.txt', 'r') as file:
58
+ words = file.read().split()
59
+ char_prompt1 = ' '.join(words).format(character_name=character_name2, show_name=show_name2, question=question, opposite_character=character_name1, opposite_show=show_name1)
60
+ chat1 = requests.get("http://localhost:5001/chat?q=%s" % char_prompt1)
61
+ opposite_char_req = (f"i am act as a {character_name2} from {show_name2} and i will response and answer like that {character_name2} using the tone, manner and vocabulary, and i the virtual character {character_name2} asking first question. if you understand please say 'YES, i understood'.")
62
+ opposite_char_instance = ' '.join(words).format(character_name=character_name1, show_name=show_name1, question=opposite_char_req, opposite_character=character_name2, opposite_show=show_name2)
63
+ chat2 = requests.get("http://localhost:5002/chat?q=%s" % opposite_char_instance)
64
+ os.system('clear')
65
+ if os.path.exists('source/banner.py'):
66
+ os.system('python source/banner.py')
67
+ else:
68
+ os.system('python banner.py')
69
+ print(f"\nTOPIC: {question} \n \n")
70
+ chat_log = (f"\nTOPIC: {question} \n")
71
+ print(f"{character_name2}: ", chat1.text)
72
+ print(" ")
73
+ chat_log += f"\n{character_name2}: {chat1.text}\n"
74
+ while True:
75
+ chat2 = requests.get("http://localhost:5002/chat?q=%s" % (chat1.text.replace("ChatGPT", "")))
76
+ print(f"{character_name1}: ", chat2.text)
77
+ chat_log += f"\n{character_name1}: {chat2.text}\n"
78
+ print(" ")
79
+ chat1 = requests.get("http://localhost:5001/chat?q=%s" % (chat2.text.replace("ChatGPT", "")))
80
+ print(f"{character_name2}: ", chat1.text)
81
+ chat_log += f"\n{character_name2}: {chat1.text}\n"
82
+ print("________________________________________________________________________________________________________")
83
+ print(" ")
84
+ try:
85
+ if keyboard.is_pressed('ctrl+c'): # Check if Ctrl+C is pressed
86
+ print("\nCtrl+C pressed. Do you want to save the chat?")
87
+ save_chat = input("Enter 'y' to save the chat or 'n' to close the program: ")
88
+ if save_chat.lower() == 'y':
89
+ save_file = "chat_log.txt"
90
+ with open(save_file, "w") as file:
91
+ file.write(chat_log)
92
+ print("Chat saved successfully.")
93
+ print("All chats saved:")
94
+ with open(save_file, "r") as file:
95
+ print(file.read())
96
+ break
97
+ elif save_chat.lower() == 'n':
98
+ break
99
+ else:
100
+ print("Invalid input. Closing the program.")
101
+ break
102
+ except:
103
+ pass
104
+
105
+ elif value == "2":
106
+ question = input(f"What do you want to ask {character_name1} from {character_name2}: ")
107
+ if os.path.exists('source/char_prompt.txt'):
108
+ with open('source/char_prompt.txt', 'r') as file:
109
+ words = file.read().split()
110
+ else:
111
+ with open('char_prompt.txt', 'r') as file:
112
+ words = file.read().split()
113
+ char_prompt2 = ' '.join(words).format(character_name=character_name1, show_name=show_name1, question=question, opposite_character=character_name2, opposite_show=show_name2)
114
+ chat2 = requests.get("http://localhost:5002/chat?q=%s" % char_prompt2)
115
+ opposite_char_req = (f"i always act as a {character_name1} from {show_name1} and i will response and answer like that {character_name1} using the tone, manner and vocabulary, and i the virtual character {character_name1} asking first question. if you understand please say 'YES, i understood'.")
116
+ opposite_char_instance = ' '.join(words).format(character_name=character_name2, show_name=show_name2, question=opposite_char_req, opposite_character=character_name1, opposite_show=show_name1)
117
+ chat1 = requests.get("http://localhost:5001/chat?q=%s" % (opposite_char_instance))
118
+ os.system('clear')
119
+ if os.path.exists('source/banner.py'):
120
+ os.system('python source/banner.py')
121
+ else:
122
+ os.system('python banner.py')
123
+ print(f"\nTOPIC: {question} \n \n")
124
+ chat_log = (f"\nTOPIC: {question} \n")
125
+ print(f"{character_name1}: ", chat2.text)
126
+ print(" ")
127
+ chat_log += f"{character_name2}: {chat1.text}\n"
128
+ while True:
129
+ chat1 = requests.get("http://localhost:5001/chat?q=%s" % (chat2.text.replace("ChatGPT", "")))
130
+ print(f"{character_name2}: ", chat1.text)
131
+ chat_log += f"{character_name2}: {chat1.text}\n"
132
+ print(" ")
133
+ chat2 = requests.get("http://localhost:5002/chat?q=%s" % (chat1.text.replace("ChatGPT", "")))
134
+ print(f"{character_name1}: ", chat2.text)
135
+ chat_log += f"{character_name1}: {chat2.text}\n"
136
+ print("________________________________________________________________________________________________________")
137
+ print(" ")
138
+ try:
139
+ if keyboard.is_pressed('ctrl+c'): # Check if Ctrl+C is pressed
140
+ print("\nCtrl+C pressed. Do you want to save the chat?")
141
+ save_chat = input("Enter 'y' to save the chat or 'n' to close the program: ")
142
+ if save_chat.lower() == 'y':
143
+ save_file = "chat_log.txt"
144
+ with open(save_file, "w") as file:
145
+ file.write(chat_log)
146
+ print("Chat saved successfully.")
147
+ print("All chats saved:")
148
+ with open(save_file, "r") as file:
149
+ print(file.read())
150
+ break
151
+ elif save_chat.lower() == 'n':
152
+ break
153
+ else:
154
+ print("Invalid input. Closing the program.")
155
+ break
156
+ except:
157
+ pass
158
+ else:
159
+ print("Wrong option!!! Enter option 1 or 2 only. Try again... ")
160
+ time.sleep(1)
161
+ os.system('clear')
162
+ exit(0)