Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ palm.configure(api_key=api_key)
|
|
8 |
|
9 |
defaults = {
|
10 |
'model': 'models/text-bison-001',
|
11 |
-
'temperature': 0.
|
12 |
'candidate_count': 1,
|
13 |
'top_k': 40,
|
14 |
'top_p': 0.95,
|
@@ -24,21 +24,28 @@ defaults = {
|
|
24 |
|
25 |
}
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
|
44 |
if __name__ == "__main__":
|
|
|
8 |
|
9 |
defaults = {
|
10 |
'model': 'models/text-bison-001',
|
11 |
+
'temperature': 0.4,
|
12 |
'candidate_count': 1,
|
13 |
'top_k': 40,
|
14 |
'top_p': 0.95,
|
|
|
24 |
|
25 |
}
|
26 |
|
27 |
+
with gr.Blocks() as app:
|
28 |
+
def chat(text):
|
29 |
+
try:
|
30 |
+
response = palm.generate_text(
|
31 |
+
**defaults,
|
32 |
+
prompt=f"""Please correct these sentences and rectify any grammar errors. Additionally, when making your corrections, kindly refrain from including quotation marks in your revised sentences. The objective is to enhance the overall clarity and coherence of the paragraph. If the sentence given is correct then the response will be the same as the input. Do not add any sentences other than the correction of the sentences.
|
33 |
+
Sentences: '{text}'"""
|
34 |
+
)
|
35 |
+
return response.result
|
36 |
+
|
37 |
+
except:
|
38 |
+
return "Sentences must be in English"
|
39 |
+
|
40 |
+
with gr.Column():
|
41 |
+
text = gr.Textbox(lines=6, label="Text", max_lines=5, placeholder="Write something awesome. It will be corrected automatically.")
|
42 |
+
|
43 |
+
with gr.Column():
|
44 |
+
output = gr.Textbox(lines=6, label="Output", max_lines=6, show_copy_button=True)
|
45 |
+
with gr.Row():
|
46 |
+
clr_btn = gr.ClearButton([text, output], variant="primary")
|
47 |
+
btn = gr.Button("Submit")
|
48 |
+
btn.click(fn=chat, inputs=text, outputs=output)
|
49 |
|
50 |
|
51 |
if __name__ == "__main__":
|