anon4ik commited on
Commit
48a4271
·
verified ·
1 Parent(s): d69621c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -1
app.py CHANGED
@@ -14,8 +14,39 @@ app.config['JSON_AS_ASCII'] = False
14
  CORS(app, resources={r"/*": {"origins": "*"}})
15
 
16
  API_KEY = os.environ['API_KEY']
 
17
  genai.configure(api_key=API_KEY)
18
- model = genai.GenerativeModel('gemini-pro')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  def get_response(prompt:str):
21
  try:
 
14
  CORS(app, resources={r"/*": {"origins": "*"}})
15
 
16
  API_KEY = os.environ['API_KEY']
17
+
18
  genai.configure(api_key=API_KEY)
19
+
20
+ safety_settings = [
21
+ {
22
+ "category": "HARM_CATEGORY_HARASSMENT",
23
+ "threshold": "BLOCK_NONE"
24
+ },
25
+ {
26
+ "category": "HARM_CATEGORY_HATE_SPEECH",
27
+ "threshold": "BLOCK_NONE"
28
+ },
29
+ {
30
+ "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
31
+ "threshold": "BLOCK_NONE"
32
+ },
33
+ {
34
+ "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
35
+ "threshold": "BLOCK_NONE"
36
+ },
37
+ ]
38
+
39
+ model = genai.GenerativeModel(
40
+ model_name = 'gemini-pro'
41
+ safety_settings = safety_settings,
42
+ generation_config = genai.GenerationConfig(
43
+ candidate_count = 1,
44
+ max_output_tokens = 4096,
45
+ temperature = 0.95,
46
+ top_p = 0.9,
47
+ top_k = 40
48
+ )
49
+ )
50
 
51
  def get_response(prompt:str):
52
  try: