lunarflu HF Staff commited on
Commit
fb3bd09
·
1 Parent(s): 4d47207

[falcon.py] debugging messages

Browse files
Files changed (1) hide show
  1. falcon.py +12 -4
falcon.py CHANGED
@@ -27,9 +27,8 @@ async def try_falcon(interaction, prompt):
27
 
28
  if interaction.user.id != BOT_USER_ID:
29
  if interaction.channel.id == FALCON_CHANNEL_ID:
30
-
31
  if os.environ.get('TEST_ENV') == 'True':
32
- print("TEST_ENV is True.")
33
  await interaction.response.send_message(f"Working on it!")
34
  channel = interaction.channel
35
  message = await channel.send(f"Creating thread...")
@@ -38,10 +37,14 @@ async def try_falcon(interaction, prompt):
38
  f"model and system prompt can be found here: https://huggingface.co/spaces/HuggingFaceH4/falcon-chat]")
39
 
40
  chathistory = falcon_client.predict(fn_index=5)
 
 
41
  job = falcon_client.submit(prompt, chathistory, instructions, 0.8, 0.9, fn_index=1) # This is not blocking, similar to run_in_executor (but better)
42
  while job.done() is False:
43
  pass
44
  else:
 
 
45
  file_paths = job.outputs()
46
  full_generation = file_paths[-1]
47
  with open(full_generation, 'r') as file:
@@ -62,17 +65,22 @@ async def continue_falcon(message):
62
  if not message.author.bot:
63
  global falcon_userid_threadid_dictionary # tracks userid-thread existence
64
  if message.channel.id in falcon_userid_threadid_dictionary: # is this a valid thread?
65
- if falcon_userid_threadid_dictionary[message.channel.id] == message.author.id: # more than that - is this specifically the right user for this thread?
 
 
66
  global instructions
67
  global threadid_conversation
68
  await message.add_reaction('🔁')
69
  chathistory = threadid_conversation[message.channel.id]
70
  prompt = message.content
71
-
 
72
  job = falcon_client.submit(prompt, chathistory, instructions, 0.8, 0.9, fn_index=1)
73
  while job.done() is False:
74
  pass
75
  else:
 
 
76
  file_paths = job.outputs()
77
  full_generation = file_paths[-1]
78
  with open(full_generation, 'r') as file:
 
27
 
28
  if interaction.user.id != BOT_USER_ID:
29
  if interaction.channel.id == FALCON_CHANNEL_ID:
 
30
  if os.environ.get('TEST_ENV') == 'True':
31
+ print("Safetychecks passed for try_falcon")
32
  await interaction.response.send_message(f"Working on it!")
33
  channel = interaction.channel
34
  message = await channel.send(f"Creating thread...")
 
37
  f"model and system prompt can be found here: https://huggingface.co/spaces/HuggingFaceH4/falcon-chat]")
38
 
39
  chathistory = falcon_client.predict(fn_index=5)
40
+ if os.environ.get('TEST_ENV') == 'True':
41
+ print("Running falcon_client.submit")
42
  job = falcon_client.submit(prompt, chathistory, instructions, 0.8, 0.9, fn_index=1) # This is not blocking, similar to run_in_executor (but better)
43
  while job.done() is False:
44
  pass
45
  else:
46
+ if os.environ.get('TEST_ENV') == 'True':
47
+ print("Try_falcon job done")
48
  file_paths = job.outputs()
49
  full_generation = file_paths[-1]
50
  with open(full_generation, 'r') as file:
 
65
  if not message.author.bot:
66
  global falcon_userid_threadid_dictionary # tracks userid-thread existence
67
  if message.channel.id in falcon_userid_threadid_dictionary: # is this a valid thread?
68
+ if falcon_userid_threadid_dictionary[message.channel.id] == message.author.id: # more than that - is this specifically the right user for this thread?
69
+ if os.environ.get('TEST_ENV') == 'True':
70
+ print("Safetychecks passed for continue_falcon")
71
  global instructions
72
  global threadid_conversation
73
  await message.add_reaction('🔁')
74
  chathistory = threadid_conversation[message.channel.id]
75
  prompt = message.content
76
+ if os.environ.get('TEST_ENV') == 'True':
77
+ print("Running falcon_client.submit")
78
  job = falcon_client.submit(prompt, chathistory, instructions, 0.8, 0.9, fn_index=1)
79
  while job.done() is False:
80
  pass
81
  else:
82
+ if os.environ.get('TEST_ENV') == 'True':
83
+ print("Continue_falcon job done")
84
  file_paths = job.outputs()
85
  full_generation = file_paths[-1]
86
  with open(full_generation, 'r') as file: