lunarflu HF staff commited on
Commit
08694f1
1 Parent(s): 7c48ec1

Synced repo using 'sync_with_huggingface' Github Action

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -24,6 +24,7 @@ def convert_to_timezone(dt, tz):
24
  DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
25
  intents = discord.Intents.all()
26
  bot = commands.Bot(command_prefix='!', intents=intents)
 
27
 
28
  #rate_limiter = RateLimiter(max_calls=10, period=60) # needs testing
29
 
@@ -42,7 +43,15 @@ async def on_message(message):
42
  """Backup"""
43
  number_of_messages = number_of_messages + 1
44
  message_link = f"[#{message.channel.name}]({message.jump_url})"
45
- dm_message = await lunarflu.send(f"{number_of_messages}| {message_link} |{message.author}: {message.content}")
 
 
 
 
 
 
 
 
46
 
47
  """Antispam"""
48
  #Detecting certain unwanted strings
@@ -396,4 +405,4 @@ def greet(name):
396
  return "Hello " + name + "!"
397
 
398
  demo = gr.Interface(fn=greet, inputs="text", outputs="text")
399
- demo.launch()
 
24
  DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
25
  intents = discord.Intents.all()
26
  bot = commands.Bot(command_prefix='!', intents=intents)
27
+ testclient = Client("https://lunarflu-bert-test.hf.space/--replicas/58fjw/")
28
 
29
  #rate_limiter = RateLimiter(max_calls=10, period=60) # needs testing
30
 
 
43
  """Backup"""
44
  number_of_messages = number_of_messages + 1
45
  message_link = f"[#{message.channel.name}]({message.jump_url})"
46
+ try:
47
+ job = testclient.submit(message.content, api_name="/predict")
48
+ while not job.done():
49
+ await asyncio.sleep(0.2)
50
+ if job.done():
51
+ label = job.outputs()[0]['label']
52
+ except Exception as e:
53
+ print(f"on_message Error: {e}")
54
+ dm_message = await lunarflu.send(f"{number_of_messages}| {label} |{message_link} |{message.author}: {message.content}")
55
 
56
  """Antispam"""
57
  #Detecting certain unwanted strings
 
405
  return "Hello " + name + "!"
406
 
407
  demo = gr.Interface(fn=greet, inputs="text", outputs="text")
408
+ demo.launch()