@@ -1109,6 +1109,11 @@ def generate(
11091109 provider ,
11101110 quiet ,
11111111 )
1112+ if with_copied :
1113+ sep = "\n " if prompt else ""
1114+ prompt = prompt + sep + clipman .get ()
1115+ assert prompt .strip () != sep , "No copied text found, issue prompt"
1116+
11121117 if not prompt :
11131118 # Let's try to read piped input
11141119 import signal
@@ -1137,8 +1142,6 @@ def timeout_handler(signum, frame):
11371142 # Just incase the previous timeout was not 0
11381143
11391144 clear_history_file (filepath , new )
1140- if with_copied :
1141- prompt = prompt + "\n " + clipman .get ()
11421145 prompt = Optimizers .code (prompt ) if code else prompt
11431146 prompt = Optimizers .shell_command (prompt ) if shell else prompt
11441147 busy_bar .spin_index = busy_bar_index
@@ -1263,6 +1266,57 @@ def delete(name, case_sensitive, file):
12631266 return AwesomePrompts ().delete_prompt (name , case_sensitive )
12641267
12651268
1269+ @awesome .command ()
1270+ @click .option (
1271+ "-j" ,
1272+ "--json" ,
1273+ is_flag = True ,
1274+ help = "Display prompts in json format" ,
1275+ )
1276+ @click .option (
1277+ "-i" ,
1278+ "--indent" ,
1279+ type = click .IntRange (1 , 20 ),
1280+ help = "Json format indentation level" ,
1281+ default = 4 ,
1282+ )
1283+ @click .option (
1284+ "-x" ,
1285+ "--index" ,
1286+ is_flag = True ,
1287+ help = "Display prompts with their corresponding indexes" ,
1288+ )
1289+ @click .option ("-c" , "--color" , help = "Prompts stdout font color" )
1290+ @click .option ("-o" , "--output" , type = click .Path (), help = "Path to save the prompts" )
1291+ @click .help_option ("-h" , "--help" )
1292+ def all (json , indent , index , color , output ):
1293+ """Stdout all awesome prompts"""
1294+ ap = AwesomePrompts ()
1295+ awesome_prompts = ap .all_acts if index else ap .get_acts ()
1296+ from json import dumps
1297+
1298+ formatted_awesome_prompts = dumps (awesome_prompts )
1299+ if json :
1300+ # click.secho(formatted_awesome_prompts, fg=color)
1301+ rich .print_json (formatted_awesome_prompts ,indent = indent )
1302+
1303+ else :
1304+ awesome_table = Table (show_lines = True , title = "All Awesome-Prompts" )
1305+ awesome_table .add_column ("index" , justify = "center" , style = "yellow" )
1306+ awesome_table .add_column ("Act Name/Index" , justify = "left" , style = "cyan" )
1307+ awesome_table .add_column (
1308+ "Prompt" ,
1309+ style = color ,
1310+ )
1311+ for index , key_value in enumerate (awesome_prompts .items ()):
1312+ awesome_table .add_row (str (index ), str (key_value [0 ]), key_value [1 ])
1313+ rich .print (awesome_table )
1314+
1315+ if output :
1316+ with open (output , "w" ) as fh :
1317+ fh .write (formatted_awesome_prompts )
1318+
1319+
12661320tgpt2_ .add_command (
12671321 webchatgpt , "webchatgpt"
12681322) # Intergration with WebChatGPT https://github.com/Simatwa/WebChatGPT
0 commit comments