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,27 +24,29 @@ defaults = {
|
|
| 24 |
|
| 25 |
}
|
| 26 |
|
|
|
|
|
|
|
|
|
|
| 27 |
with gr.Blocks() as app:
|
| 28 |
def chat(text):
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
except:
|
| 38 |
-
return "Sentences must be in English"
|
| 39 |
|
| 40 |
with gr.Column():
|
| 41 |
-
text = gr.Textbox(lines=
|
| 42 |
-
|
| 43 |
with gr.Column():
|
| 44 |
-
output = gr.Textbox(lines=
|
|
|
|
| 45 |
with gr.Row():
|
| 46 |
-
clr_btn = gr.ClearButton([text, output])
|
| 47 |
-
btn = gr.Button("Submit"
|
| 48 |
btn.click(fn=chat, inputs=text, outputs=output)
|
| 49 |
|
| 50 |
|
|
|
|
| 8 |
|
| 9 |
defaults = {
|
| 10 |
'model': 'models/text-bison-001',
|
| 11 |
+
'temperature': 0.7,
|
| 12 |
'candidate_count': 1,
|
| 13 |
'top_k': 40,
|
| 14 |
'top_p': 0.95,
|
|
|
|
| 24 |
|
| 25 |
}
|
| 26 |
|
| 27 |
+
with open("example.txt") as f:
|
| 28 |
+
example = f.read()
|
| 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 |
+
|
| 44 |
with gr.Column():
|
| 45 |
+
output = gr.Textbox(lines=4, label="Output", max_lines=4, show_copy_button=True)
|
| 46 |
+
|
| 47 |
with gr.Row():
|
| 48 |
+
clr_btn = gr.ClearButton([text, output], variant="primary")
|
| 49 |
+
btn = gr.Button("Submit")
|
| 50 |
btn.click(fn=chat, inputs=text, outputs=output)
|
| 51 |
|
| 52 |
|