MightyOctopus commited on
Commit
6232d23
·
verified ·
1 Parent(s): c3b1132

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -39,7 +39,7 @@ user_input="""Brooo, you won’t believe what happened today 😭 So I’m just
39
 
40
 
41
  @tool
42
- def detect_text(texts):
43
  """ Process AI text detection using fakespot-ai/roberta-base-ai-text-detection-v1 model.
44
  It returns its result in a List[Dict] form.
45
  e.g. [{'label': 'AI', 'score': 0.9998624324798584}]
@@ -53,22 +53,21 @@ def detect_text(texts):
53
  ### due to the max token limit of the detection model
54
  num_words = 300
55
  batched_words = []
56
- words: List = texts.split()
57
 
58
- if len(texts.split()) >= num_words:
59
  for i in range(0, len(words), num_words):
60
  chunk = " ".join(words[i: i + num_words])
61
  batched_words.append(chunk)
62
 
 
63
  cleaned_text = classifier([clean_text(t) for t in batched_words])
64
  label_result = cleaned_text[0]["label"]
65
  score_result = cleaned_text[0]["score"]
66
 
67
  return label_result, score_result
68
  else:
69
- cleaned_text = classifier(clean_text(texts))
70
-
71
- ### Works with a batch of texts
72
  label_result = cleaned_text[0]["label"]
73
  score_result = cleaned_text[0]["score"]
74
 
 
39
 
40
 
41
  @tool
42
+ def detect_text(text):
43
  """ Process AI text detection using fakespot-ai/roberta-base-ai-text-detection-v1 model.
44
  It returns its result in a List[Dict] form.
45
  e.g. [{'label': 'AI', 'score': 0.9998624324798584}]
 
53
  ### due to the max token limit of the detection model
54
  num_words = 300
55
  batched_words = []
56
+ words: List = text.split()
57
 
58
+ if len(text.split()) >= num_words:
59
  for i in range(0, len(words), num_words):
60
  chunk = " ".join(words[i: i + num_words])
61
  batched_words.append(chunk)
62
 
63
+ ### Works with a batch of texts
64
  cleaned_text = classifier([clean_text(t) for t in batched_words])
65
  label_result = cleaned_text[0]["label"]
66
  score_result = cleaned_text[0]["score"]
67
 
68
  return label_result, score_result
69
  else:
70
+ cleaned_text = classifier(clean_text(text))
 
 
71
  label_result = cleaned_text[0]["label"]
72
  score_result = cleaned_text[0]["score"]
73