Spaces:
Sleeping
Sleeping
PanagiotisMark
commited on
Commit
•
00c7c1e
1
Parent(s):
e059730
Delete gradio_app.py
Browse files- gradio_app.py +0 -67
gradio_app.py
DELETED
@@ -1,67 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
import gradio as gr
|
3 |
-
import requests
|
4 |
-
|
5 |
-
# Retrieve HF space secrets
|
6 |
-
auth_key = os.getenv('AUTH_KEY')
|
7 |
-
api_url = os.getenv('API_URL')
|
8 |
-
api_port = os.getenv('API_PORT')
|
9 |
-
|
10 |
-
HEADERS = {
|
11 |
-
'Content-Type': 'application/json'
|
12 |
-
}
|
13 |
-
|
14 |
-
def news_analysis(text):
|
15 |
-
try:
|
16 |
-
response = requests.post(
|
17 |
-
f"{api_url}:{api_port}/news_analysis",
|
18 |
-
json={
|
19 |
-
'doc_id': '1',
|
20 |
-
'text': text,
|
21 |
-
'auth_key': auth_key
|
22 |
-
},
|
23 |
-
headers=HEADERS
|
24 |
-
)
|
25 |
-
response.raise_for_status()
|
26 |
-
return response.json()
|
27 |
-
except requests.exceptions.RequestException as error:
|
28 |
-
print('Error fetching data from news_analysis:', error)
|
29 |
-
raise
|
30 |
-
|
31 |
-
def claim_verification(text):
|
32 |
-
try:
|
33 |
-
response = requests.post(
|
34 |
-
f"{api_url}:{api_port}/claim_verification",
|
35 |
-
json={
|
36 |
-
'doc_id': '1',
|
37 |
-
'text': text,
|
38 |
-
'auth_key': auth_key
|
39 |
-
},
|
40 |
-
headers=HEADERS
|
41 |
-
)
|
42 |
-
response.raise_for_status()
|
43 |
-
return response.json()
|
44 |
-
except requests.exceptions.RequestException as error:
|
45 |
-
print('Error fetching data from claim_verification:', error)
|
46 |
-
raise
|
47 |
-
|
48 |
-
iface_news_analysis = gr.Interface(
|
49 |
-
fn=news_analysis,
|
50 |
-
inputs=gr.Textbox(lines=10, label="News Article Text"),
|
51 |
-
outputs=gr.JSON(label="Classification Result"),
|
52 |
-
title="News Analysis",
|
53 |
-
description="Classify the domain of a news article and detect major claims."
|
54 |
-
)
|
55 |
-
|
56 |
-
iface_claim_verification = gr.Interface(
|
57 |
-
fn=claim_verification,
|
58 |
-
inputs=gr.Textbox(lines=10, label="Claim Text"),
|
59 |
-
outputs=gr.JSON(label="Verification Result"),
|
60 |
-
title="Claim Verification",
|
61 |
-
description="Verify claims made in a news article."
|
62 |
-
)
|
63 |
-
|
64 |
-
iface = gr.TabbedInterface([iface_news_analysis, iface_claim_verification], ["News Analysis", "Claim Verification"])
|
65 |
-
|
66 |
-
# Launch the interface
|
67 |
-
iface.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|