Update app.py
Browse files
app.py
CHANGED
|
@@ -86,18 +86,15 @@ def sumy(payload):
|
|
| 86 |
|
| 87 |
|
| 88 |
def query(payload):
|
| 89 |
-
API_URL = "https://api-inference.huggingface.co/models/
|
| 90 |
data = json.dumps(payload)
|
| 91 |
response = requests.request("POST", API_URL, headers=headers, data=data)
|
| 92 |
return json.loads(response.content.decode("utf-8"))
|
| 93 |
|
| 94 |
def google(name):
|
| 95 |
-
if "give" in name:
|
| 96 |
-
r_c = name.split("give")[1]
|
| 97 |
|
| 98 |
-
result_count =
|
| 99 |
-
#print(result_count)
|
| 100 |
-
name = name.split("give")[0]
|
| 101 |
print(name)
|
| 102 |
|
| 103 |
else:
|
|
@@ -142,18 +139,18 @@ def google(name):
|
|
| 142 |
f_result = sumy({"inputs":temp,"parameters": {"do_sample": False,"max_length":300}})
|
| 143 |
return f_result[0]['summary_text']
|
| 144 |
else:
|
| 145 |
-
|
|
|
|
|
|
|
| 146 |
if "..." in r:
|
| 147 |
r = r.split("...")
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
if "\n\n" in w:
|
| 151 |
-
print("=")
|
| 152 |
-
f_result = f_result +w+"\n\n"
|
| 153 |
else:
|
| 154 |
-
print(
|
| 155 |
-
|
| 156 |
-
|
|
|
|
| 157 |
return f_result
|
| 158 |
|
| 159 |
def greet(name1):
|
|
|
|
| 86 |
|
| 87 |
|
| 88 |
def query(payload):
|
| 89 |
+
API_URL = "https://api-inference.huggingface.co/models/facebook/bart-large-cnn"
|
| 90 |
data = json.dumps(payload)
|
| 91 |
response = requests.request("POST", API_URL, headers=headers, data=data)
|
| 92 |
return json.loads(response.content.decode("utf-8"))
|
| 93 |
|
| 94 |
def google(name):
|
| 95 |
+
if "give" in name or "reason" in name or "result" in name or "step" in name:
|
|
|
|
| 96 |
|
| 97 |
+
result_count = 2
|
|
|
|
|
|
|
| 98 |
print(name)
|
| 99 |
|
| 100 |
else:
|
|
|
|
| 139 |
f_result = sumy({"inputs":temp,"parameters": {"do_sample": False,"max_length":300}})
|
| 140 |
return f_result[0]['summary_text']
|
| 141 |
else:
|
| 142 |
+
n=1
|
| 143 |
+
for r in text.split("\n\n")[2:-2]:
|
| 144 |
+
if len(r)>10:
|
| 145 |
if "..." in r:
|
| 146 |
r = r.split("...")
|
| 147 |
+
w = query(r[0].replace("\xa0",""))
|
| 148 |
+
f_result = f_result + str(n)+"\t"+(w[0]['summary_text'])+"\n\n"+r"\\"
|
|
|
|
|
|
|
|
|
|
| 149 |
else:
|
| 150 |
+
#print(r[:-1])
|
| 151 |
+
w = query(r[:-1])
|
| 152 |
+
f_result = f_result + str(n)+"\t"+(w[0]['summary_text'])+"\n\n"+r"\\"
|
| 153 |
+
n=n+1
|
| 154 |
return f_result
|
| 155 |
|
| 156 |
def greet(name1):
|