11import PySimpleGUI as sg
22import openai
3+ import pyperclip
34
45# Set up OpenAI API credentials
5- openai .api_key = "YOUR_TOKEN "
6+ openai .api_key = "YOUR_API_KEY "
67
78# Define the ChatGPT function that sends a prompt to OpenAI and returns the response
89def chat_gpt (prompt ):
910 response = openai .Completion .create (
10- engine = "text- davinci-003 " ,
11+ engine = "davinci" ,
1112 prompt = prompt ,
1213 max_tokens = 1024 ,
1314 n = 1 ,
@@ -18,14 +19,28 @@ def chat_gpt(prompt):
1819 return message .strip ()
1920
2021# Define the PySimpleGUI layout
21- sg .theme ('DarkGrey1' )
22- layout = [[sg .Text ('ChatGPT Client v1' , font = ('Helvetica' , 20 ), pad = (5 , 5 ))],
23- [sg .Multiline ('' , key = 'conversation' , font = ('Helvetica' , 14 ), size = (60 , 10 ), pad = (5 , 5 ))],
24- [sg .Input ('' , key = 'input_message' , font = ('Helvetica' , 14 ), size = (50 , 1 ), pad = (5 , 5 )),
25- sg .Button ('Send' , font = ('Helvetica' , 14 ), pad = (5 , 5 ))]]
22+ sg .theme ('LightGrey1' )
23+ layout = [
24+ [sg .Text ('ChatGPT' , font = ('Helvetica' , 20 ), pad = (5 , 5 ))],
25+ [sg .Multiline ('' , key = 'conversation' , font = ('Helvetica' , 14 ), size = (60 , 10 ), pad = (5 , 5 ))],
26+ [
27+ sg .Input ('' , key = 'input_message' , font = ('Helvetica' , 14 ), size = (50 , 1 ), pad = (5 , 5 )),
28+ sg .Button ('Send' , font = ('Helvetica' , 14 ), pad = (5 , 5 ))
29+ ],
30+ [sg .Button ('Toggle Theme' , font = ('Helvetica' , 14 ), pad = (5 , 5 ))],
31+ [
32+ sg .TabGroup ([
33+ [
34+ sg .Tab ('Jailbreaking' , [
35+ [sg .Button ('Button 1' ), sg .Button ('Button 2' ), sg .Button ('Button 3' ), sg .Button ('Button 4' ), sg .Button ('Button 5' )]
36+ ])
37+ ]
38+ ])
39+ ]
40+ ]
2641
2742# Create the PySimpleGUI window
28- window = sg .Window ('ChatGPT Client by LopeKinz ' , layout )
43+ window = sg .Window ('ChatGPT' , layout )
2944
3045# Start the PySimpleGUI event loop
3146while True :
@@ -35,6 +50,12 @@ def chat_gpt(prompt):
3550 if event == sg .WINDOW_CLOSED :
3651 break
3752
53+ # Toggle between light and dark theme
54+ if event == 'Toggle Theme' :
55+ if sg .theme () == 'LightGrey1' :
56+ sg .theme ('DarkGrey1' )
57+ else :
58+ sg .theme ('LightGrey1' )
3859
3960 # Send the user's message and get a response from ChatGPT
4061 if event == 'Send' :
@@ -45,13 +66,17 @@ def chat_gpt(prompt):
4566 window ['input_message' ].update ('' )
4667
4768 # Add the user's message to the conversation area
48- window ['conversation' ].print ('You: ' + message + ' \n \n ' )
69+ window ['conversation' ].print ('You: ' + message )
4970
5071 # Call ChatGPT to get a response
5172 response = chat_gpt (message )
5273
5374 # Add the response to the conversation area
54- window ['conversation' ].print ('ChatGPT: ' + response + '\n ' )
75+ window ['conversation' ].print ('ChatGPT: ' + response )
76+
77+ # Copy the text to the clipboard when the button is clicked
78+ if event .startswith ('Button' ):
79+ pyperclip .copy ('Button ' + event [- 1 ] + ' text copied to clipboard!' )
5580
5681# Close the PySimpleGUI window when the event loop is exited
5782window .close ()
0 commit comments