Update app.py
Browse files
app.py
CHANGED
@@ -127,40 +127,8 @@ def WEBScout_translate():
|
|
127 |
return jsonify(translation)
|
128 |
|
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({'response': result.result})
|
162 |
|
163 |
-
@app.route('/
|
164 |
def chat_gpt():
|
165 |
user_input = request.json.get('message')
|
166 |
if user_input is None:
|
|
|
127 |
return jsonify(translation)
|
128 |
|
129 |
# Configure the API key
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
|
131 |
+
@app.route('/chat', methods=['POST'])
|
132 |
def chat_gpt():
|
133 |
user_input = request.json.get('message')
|
134 |
if user_input is None:
|