lunarflu HF Staff commited on
Commit
815a27e
Β·
1 Parent(s): 1cea653

[falcon.py] moving continue_falcon

Browse files
Files changed (1) hide show
  1. falcon.py +30 -0
falcon.py CHANGED
@@ -72,3 +72,33 @@ async def try_falcon(interaction, prompt):
72
  except Exception as e:
73
  print(f"Error: {e}")
74
  #await thread.send(f"{e} cc <@811235357663297546> (falconprivate error)")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  except Exception as e:
73
  print(f"Error: {e}")
74
  #await thread.send(f"{e} cc <@811235357663297546> (falconprivate error)")
75
+ #-------------------------------------------------------------------------------------------------------------------------------------
76
+ async def continue_falcon(message):
77
+ try:
78
+ global instructions
79
+ global threadid_conversation
80
+ await message.add_reaction('πŸ”')
81
+ chathistory = threadid_conversation[message.channel.id]
82
+ prompt = message.content
83
+ # generation
84
+ job = falconclient.submit(prompt, chathistory, instructions, 0.8, 0.9, fn_index=1) # This is not blocking, similar to run_in_executor (but better)
85
+ while job.done() == False:
86
+ status = job.status()
87
+ #print(status)
88
+ else:
89
+ file_paths = job.outputs()
90
+ full_generation = file_paths[-1] # tmp12345678.json
91
+ with open(full_generation, 'r') as file:
92
+ data = json.load(file)
93
+ output_text = data[-1][-1] # we output this as the bot
94
+
95
+ threadid_conversation[message.channel.id] = full_generation # overwrite the old file
96
+ falcon_userid_threadid_dictionary[message.channel.id] = message.author.id
97
+
98
+ print(output_text)
99
+ await message.reply(f"{output_text}")
100
+ await message.remove_reaction('πŸ”', client.user) # test=πŸ” hf=πŸ”
101
+
102
+ except Exception as e:
103
+ print(f"Error: {e}")
104
+ await message.reply(f"Error: {e} <@811235357663297546> (continue_falcon error)")