minko186 commited on
Commit
b8e5952
·
verified ·
1 Parent(s): 312e62e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py CHANGED
@@ -3,6 +3,7 @@ from humanize import paraphrase_text
3
  from gradio_client import Client
4
  from ai_generate import generate
5
  import requests
 
6
 
7
  def on_first_button_click():
8
  return gr.update(visible=True)
@@ -35,6 +36,7 @@ def humanize(
35
  ai_check_options = [
36
  "Polygraf AI",
37
  "Sapling AI",
 
38
  ]
39
 
40
  def ai_generated_test_polygraf(text):
@@ -59,11 +61,32 @@ def ai_generated_test_sapling(text):
59
  )
60
  return { "AI" : response.json()['score'], "HUMAN" : 1 - response.json()['score']}
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  def ai_check(text, option):
63
  if option == 'Polygraf AI':
64
  return ai_generated_test_polygraf(text)
65
  elif option == 'Sapling AI':
66
  return ai_generated_test_sapling(text)
 
 
67
  else:
68
  return ai_generated_test_polygraf(text)
69
 
 
3
  from gradio_client import Client
4
  from ai_generate import generate
5
  import requests
6
+ import http.client
7
 
8
  def on_first_button_click():
9
  return gr.update(visible=True)
 
36
  ai_check_options = [
37
  "Polygraf AI",
38
  "Sapling AI",
39
+ "CopyLeaks"
40
  ]
41
 
42
  def ai_generated_test_polygraf(text):
 
61
  )
62
  return { "AI" : response.json()['score'], "HUMAN" : 1 - response.json()['score']}
63
 
64
+ def ai_generated_test_copyleak(text):
65
+
66
+ conn = http.client.HTTPSConnection("api.copyleaks.com")
67
+ payload = f"{\n \"text\": \"{text}\"\n}"
68
+
69
+ headers = {
70
+ 'Authorization': "",
71
+ 'Content-Type': "application/json",
72
+ 'Accept': "application/json"
73
+ }
74
+ scanID = "9ea35187-f43a-4dc2-bfdf-25825b78eaf1"
75
+ conn.request("POST", f"/v2/writer-detector/{scanId}/check", payload, headers)
76
+
77
+ res = conn.getresponse()
78
+ data = res.read()
79
+ print(data.decode("utf-8"))
80
+ print(data.decode("utf-8")["results"]["summary"])
81
+ return data.decode("utf-8")["results"]["summary"]
82
+
83
  def ai_check(text, option):
84
  if option == 'Polygraf AI':
85
  return ai_generated_test_polygraf(text)
86
  elif option == 'Sapling AI':
87
  return ai_generated_test_sapling(text)
88
+ elif option == 'CopyLeaks':
89
+ return ai_generated_test_copyleak(text)
90
  else:
91
  return ai_generated_test_polygraf(text)
92