cahya commited on
Commit
e9acb28
1 Parent(s): 28efd24

add error messsage if still loading

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -73,7 +73,7 @@ top_k = st.sidebar.text_input(
73
 
74
  top_p = st.sidebar.text_input(
75
  "Top p",
76
- value=1.0,
77
  help=" If set to float < 1, only the most probable tokens with probabilities that add up to top_p or higher are kept for generation."
78
  )
79
 
@@ -105,8 +105,12 @@ if st.button("Run"):
105
  temp=temp,
106
  top_k=int(top_k),
107
  top_p=float(top_p))
 
108
  print("result:", result)
109
- result = result[0]["generated_text"]
110
- st.write(result.replace("\n", " \n"))
111
- st.text("English translation")
112
- st.write(translate(result, "en", "id").replace("\n", " \n"))
 
 
 
 
73
 
74
  top_p = st.sidebar.text_input(
75
  "Top p",
76
+ value=0.95,
77
  help=" If set to float < 1, only the most probable tokens with probabilities that add up to top_p or higher are kept for generation."
78
  )
79
 
 
105
  temp=temp,
106
  top_k=int(top_k),
107
  top_p=float(top_p))
108
+
109
  print("result:", result)
110
+ if "error" in result:
111
+ st.write(f'{result["error"]}. Please try it again in about {result["estimated_time"]:.0f} seconds')
112
+ else:
113
+ result = result[0]["generated_text"]
114
+ st.write(result.replace("\n", " \n"))
115
+ st.text("English translation")
116
+ st.write(translate(result, "en", "id").replace("\n", " \n"))