lunarflu HF staff commited on
Commit
11fb06f
1 Parent(s): 270d6f4

API_URL = "https://api-inference.huggingface.co/models/mariagrandury/roberta-base-finetuned-sms-spam-detection"

Browse files
Files changed (1) hide show
  1. app.py +17 -5
app.py CHANGED
@@ -4,6 +4,7 @@ import threading
4
  from discord.ext import commands
5
  import json
6
  import datetime
 
7
 
8
  import gradio_client
9
  import gradio as gr
@@ -20,6 +21,18 @@ data_file_path = '/data/xp_data.json'
20
  xp_data = {}
21
  """"""
22
  #client = Client("https://lunarflu-bert-test.hf.space/--replicas/kjf2p/")
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  @bot.event
25
  async def on_ready():
@@ -38,11 +51,6 @@ except FileNotFoundError:
38
  xp_data = {}
39
 
40
  """
41
-
42
-
43
-
44
-
45
-
46
 
47
  def save_xp_data():
48
  with open(data_file_path, 'w') as f:
@@ -60,6 +68,10 @@ def load_xp_data():
60
  async def on_message(message):
61
  try:
62
  if message.author != bot.user:
 
 
 
 
63
  """AWAIT LEVEL ALGORITHM OR SOMETHING (MULTIPLE FILES?)"""
64
  author_id = str(message.author.id) # dictionary pairs (ID -> TOTAL XP)
65
  xp_data.setdefault(author_id, 0) # default if it doesn't already exist
 
4
  from discord.ext import commands
5
  import json
6
  import datetime
7
+ import requests
8
 
9
  import gradio_client
10
  import gradio as gr
 
21
  xp_data = {}
22
  """"""
23
  #client = Client("https://lunarflu-bert-test.hf.space/--replicas/kjf2p/")
24
+ API_URL = "https://api-inference.huggingface.co/models/mariagrandury/roberta-base-finetuned-sms-spam-detection"
25
+ HF_TOKEN = os.environ.get("HF_TOKEN", None)
26
+ headers = {"Authorization": f"Bearer {HF_TOKEN}"}
27
+
28
+
29
+ def query(payload):
30
+ response = requests.post(API_URL, headers=headers, json=payload)
31
+ return response.json()
32
+
33
+
34
+ output = query({"inputs": f"{message.content}",})
35
+
36
 
37
  @bot.event
38
  async def on_ready():
 
51
  xp_data = {}
52
 
53
  """
 
 
 
 
 
54
 
55
  def save_xp_data():
56
  with open(data_file_path, 'w') as f:
 
68
  async def on_message(message):
69
  try:
70
  if message.author != bot.user:
71
+
72
+ output = query({"inputs": f"{message.content}",})
73
+ print(output)
74
+
75
  """AWAIT LEVEL ALGORITHM OR SOMETHING (MULTIPLE FILES?)"""
76
  author_id = str(message.author.id) # dictionary pairs (ID -> TOTAL XP)
77
  xp_data.setdefault(author_id, 0) # default if it doesn't already exist