DIVY118 commited on
Commit
b5385c0
·
verified ·
1 Parent(s): d11bf5b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -31
app.py CHANGED
@@ -10,36 +10,7 @@ from time import time as t
10
 
11
  app = Flask(__name__)
12
 
13
- generation_config = {
14
- "temperature": 0.7,
15
- "top_p": 1,
16
- "top_k": 1,
17
- "max_output_tokens": 300,
18
- }
19
-
20
- safety_settings = [
21
- {
22
- "category": "HARM_CATEGORY_HARASSMENT",
23
- "threshold": "BLOCK_MEDIUM_AND_ABOVE"
24
- },
25
- {
26
- "category": "HARM_CATEGORY_HATE_SPEECH",
27
- "threshold": "BLOCK_MEDIUM_AND_ABOVE"
28
- },
29
- {
30
- "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
31
- "threshold": "BLOCK_MEDIUM_AND_ABOVE"
32
- },
33
- {
34
- "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
35
- "threshold": "BLOCK_MEDIUM_AND_ABOVE"
36
- },
37
- ]
38
-
39
- model = genai.GenerativeModel(
40
- model_name="gemini-pro",
41
- generation_config=generation_config,
42
- safety_settings=safety_settings)
43
 
44
 
45
 
@@ -121,7 +92,37 @@ def IMGEN():
121
  @app.route('/generativeai', methods=['POST'])
122
  def Genration():
123
  import google.generativeai as genai
124
- global model,safety_settings,generation_config
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  data = request.json
126
  prompt = data.get('prompt', '')
127
  messages = data.get('messages', [])
 
10
 
11
  app = Flask(__name__)
12
 
13
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
 
16
 
 
92
  @app.route('/generativeai', methods=['POST'])
93
  def Genration():
94
  import google.generativeai as genai
95
+ generation_config = {
96
+ "temperature": 0.7,
97
+ "top_p": 1,
98
+ "top_k": 1,
99
+ "max_output_tokens": 300,
100
+ }
101
+
102
+ safety_settings = [
103
+ {
104
+ "category": "HARM_CATEGORY_HARASSMENT",
105
+ "threshold": "BLOCK_MEDIUM_AND_ABOVE"
106
+ },
107
+ {
108
+ "category": "HARM_CATEGORY_HATE_SPEECH",
109
+ "threshold": "BLOCK_MEDIUM_AND_ABOVE"
110
+ },
111
+ {
112
+ "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
113
+ "threshold": "BLOCK_MEDIUM_AND_ABOVE"
114
+ },
115
+ {
116
+ "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
117
+ "threshold": "BLOCK_MEDIUM_AND_ABOVE"
118
+ },
119
+ ]
120
+
121
+ model = genai.GenerativeModel(
122
+ model_name="gemini-pro",
123
+ generation_config=generation_config,
124
+ safety_settings=safety_settings)
125
+
126
  data = request.json
127
  prompt = data.get('prompt', '')
128
  messages = data.get('messages', [])