taufiqdp commited on
Commit
086584d
1 Parent(s): 4c6ac10

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -9
app.py CHANGED
@@ -29,15 +29,19 @@ with open("example.txt") as f:
29
 
30
  with gr.Blocks() as app:
31
  def chat(text):
32
- response = palm.generate_text(
33
- **defaults,
34
- prompt = f"""Rewrite the following sentence to fix the grammar issues and correct the sentence.
35
- {example}
36
- input: {text}
37
- fixed"""
38
- )
39
- return response.result
40
-
 
 
 
 
41
  with gr.Column():
42
  text = gr.Textbox(lines=4, label="Text", max_lines=4, placeholder="Write something awesome. It will be corrected automatically.")
43
 
 
29
 
30
  with gr.Blocks() as app:
31
  def chat(text):
32
+ try:
33
+ response = palm.generate_text(
34
+ **defaults,
35
+ prompt = f"""Rewrite the following sentence to fix the grammar issues and correct the sentence.
36
+ {example}
37
+ input: {text}
38
+ fixed"""
39
+ )
40
+ return response.result
41
+
42
+ except:
43
+ return "I am not able to correct the sentence given. Please try again."
44
+
45
  with gr.Column():
46
  text = gr.Textbox(lines=4, label="Text", max_lines=4, placeholder="Write something awesome. It will be corrected automatically.")
47