Bayhaqy commited on
Commit
d4c506e
1 Parent(s): 5ad2dc4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -5
app.py CHANGED
@@ -64,11 +64,18 @@ if fetch_button:
64
  # HuggingFace API KEY input
65
  API_KEY = st.text_input("Enter your HuggingFace API key", type="password")
66
 
67
- # HuggingFace API inference URL.
68
- API_URL = "https://api-inference.huggingface.co/models/google/pegasus-cnn_dailymail"
69
 
70
- headers = {"Authorization": f"Bearer {API_KEY}"}
 
 
 
 
 
 
 
 
71
 
 
72
 
73
  submit_button = st.button("Submit")
74
 
@@ -80,6 +87,7 @@ if submit_button:
80
 
81
  title = article.title
82
  text = article.text
 
83
 
84
  # HuggingFace API request function
85
  def query(payload):
@@ -96,6 +104,14 @@ if submit_button:
96
  summary = output[0]['summary_text'].replace('<n>', " ")
97
 
98
  st.divider()
99
- st.subheader("Summary")
100
  st.write(f"Your article: **{title}**")
101
- st.write(f"**{summary}**")
 
 
 
 
 
 
 
 
 
64
  # HuggingFace API KEY input
65
  API_KEY = st.text_input("Enter your HuggingFace API key", type="password")
66
 
 
 
67
 
68
+ # Selectbox to choose between API URLs
69
+ selected_api_url = st.selectbox("Select Model", options=["pegasus-cnn_dailymail", "pegasus_indonesian_base-finetune"])
70
+
71
+ # Determine the selected Model
72
+ if selected_api_url == "pegasus-cnn_dailymail":
73
+ API_URL = "https://api-inference.huggingface.co/models/google/pegasus-cnn_dailymail"
74
+ else:
75
+ API_URL = "https://api-inference.huggingface.co/models/thonyyy/pegasus_indonesian_base-finetune"
76
+
77
 
78
+ headers = {"Authorization": f"Bearer {API_KEY}"}
79
 
80
  submit_button = st.button("Submit")
81
 
 
87
 
88
  title = article.title
89
  text = article.text
90
+ summary_lib = article.summary
91
 
92
  # HuggingFace API request function
93
  def query(payload):
 
104
  summary = output[0]['summary_text'].replace('<n>', " ")
105
 
106
  st.divider()
107
+ st.subheader("Summary AI")
108
  st.write(f"Your article: **{title}**")
109
+ st.write(f"**{summary}**")
110
+
111
+ st.divider()
112
+ st.subheader("Summary Library Newspaper")
113
+ st.write(f"**{summary_lib}**")
114
+
115
+ st.divider()
116
+ st.subheader("Real Article")
117
+ st.write(f"**{text}**")