Abhaykoul commited on
Commit
8903bd2
·
verified ·
1 Parent(s): e6f831e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -23
app.py CHANGED
@@ -129,37 +129,36 @@ def WEBScout_translate():
129
  # Configure the API key
130
  palm.configure(api_key="AIzaSyDmHbZlWJJBlaW5BAJwfOu7HP-JAKFiCpY")
131
 
132
- @app.route('/chat', methods=['POST'])
133
- def generate():
134
- data = request.get_json()
135
- model = data.get('model', 'models/text-bison-001')
136
- temperature = data.get('temperature', 1)
137
- candidate_count = data.get('candidate_count', 1)
138
- top_k = data.get('top_k', 40)
139
- top_p = data.get('top_p', 0.95)
140
- max_output_tokens = data.get('max_output_tokens', 1024)
141
- stop_sequences = data.get('stop_sequences', [])
142
- safety_settings = data.get('safety_settings', [
143
  {"category": "HARM_CATEGORY_DEROGATORY", "threshold": "BLOCK_NONE"},
144
  {"category": "HARM_CATEGORY_TOXICITY", "threshold": "BLOCK_NONE"},
145
  {"category": "HARM_CATEGORY_VIOLENCE", "threshold": "BLOCK_NONE"},
146
  {"category": "HARM_CATEGORY_SEXUAL", "threshold": "BLOCK_NONE"},
147
  {"category": "HARM_CATEGORY_MEDICAL", "threshold": "BLOCK_NONE"},
148
  {"category": "HARM_CATEGORY_DANGEROUS", "threshold": "BLOCK_NONE"},
149
- ])
150
-
151
- result = palm.generate(
152
- model=model,
153
- temperature=temperature,
154
- candidate_count=candidate_count,
155
- top_k=top_k,
156
- top_p=top_p,
157
- max_output_tokens=max_output_tokens,
158
- stop_sequences=stop_sequences,
159
- safety_settings=safety_settings
 
160
  )
161
 
162
- return jsonify(result)
163
 
164
  @app.route('/gpt', methods=['POST'])
165
  def chat_gpt():
 
129
  # Configure the API key
130
  palm.configure(api_key="AIzaSyDmHbZlWJJBlaW5BAJwfOu7HP-JAKFiCpY")
131
 
132
+ defaults = {
133
+ 'model': 'models/text-bison-001',
134
+ 'temperature': 1,
135
+ 'candidate_count': 1,
136
+ 'top_k': 40,
137
+ 'top_p': 0.95,
138
+ 'max_output_tokens': 1024,
139
+ 'stop_sequences': [],
140
+ 'safety_settings': [
 
 
141
  {"category": "HARM_CATEGORY_DEROGATORY", "threshold": "BLOCK_NONE"},
142
  {"category": "HARM_CATEGORY_TOXICITY", "threshold": "BLOCK_NONE"},
143
  {"category": "HARM_CATEGORY_VIOLENCE", "threshold": "BLOCK_NONE"},
144
  {"category": "HARM_CATEGORY_SEXUAL", "threshold": "BLOCK_NONE"},
145
  {"category": "HARM_CATEGORY_MEDICAL", "threshold": "BLOCK_NONE"},
146
  {"category": "HARM_CATEGORY_DANGEROUS", "threshold": "BLOCK_NONE"},
147
+ ]
148
+ }
149
+
150
+ @app.route('/chat', methods=['POST'])
151
+ def generate():
152
+ data = request.get_json()
153
+ prompt = data.get('prompt', 'You are A helpfull AI that will follow users instructions.')
154
+
155
+ # Call the generate function
156
+ result = palm.generate_text(
157
+ **defaults,
158
+ prompt=prompt
159
  )
160
 
161
+ return jsonify(result.result)
162
 
163
  @app.route('/gpt', methods=['POST'])
164
  def chat_gpt():