Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -7,24 +7,38 @@ api_key = os.environ["api_key"]
|
|
7 |
palm.configure(api_key=api_key)
|
8 |
|
9 |
defaults = {
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
}
|
20 |
|
21 |
def chat(text):
|
22 |
response = palm.generate_text(
|
23 |
**defaults,
|
24 |
-
prompt=f"""
|
|
|
|
|
|
|
25 |
)
|
26 |
return response.result
|
27 |
|
28 |
-
|
|
|
|
|
|
|
29 |
|
30 |
-
|
|
|
|
|
|
7 |
palm.configure(api_key=api_key)
|
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,
|
15 |
+
'max_output_tokens': 1024,
|
16 |
+
'stop_sequences': [],
|
17 |
+
'safety_settings': [
|
18 |
+
{"category": "HARM_CATEGORY_DEROGATORY", "threshold": 3},
|
19 |
+
{"category": "HARM_CATEGORY_TOXICITY", "threshold": 3},
|
20 |
+
{"category": "HARM_CATEGORY_VIOLENCE", "threshold": 3},
|
21 |
+
{"category": "HARM_CATEGORY_SEXUAL", "threshold": 3},
|
22 |
+
{"category": "HARM_CATEGORY_MEDICAL", "threshold": 3},
|
23 |
+
{"category": "HARM_CATEGORY_DANGEROUS", "threshold": 3}]
|
24 |
|
25 |
}
|
26 |
|
27 |
def chat(text):
|
28 |
response = palm.generate_text(
|
29 |
**defaults,
|
30 |
+
prompt=f"""Please correct these sentences and rectify any grammar errors.
|
31 |
+
Additionally, when making your corrections, kindly refrain from including quotation marks in your revised sentences.
|
32 |
+
The objective is to enhance the overall clarity and coherence of the paragraph.
|
33 |
+
Sentences: {text}"""
|
34 |
)
|
35 |
return response.result
|
36 |
|
37 |
+
app = gr.Interface(fn=chat,
|
38 |
+
inputs=gr.Textbox(lines=10, label="Text", max_lines=10),
|
39 |
+
outputs=gr.Textbox(lines=10, label="Output", max_lines=10, show_copy_button=True),
|
40 |
+
allow_flagging="never")
|
41 |
|
42 |
+
|
43 |
+
if __name__ == "__main__":
|
44 |
+
app.launch(debug=True)
|