Update app.py
Browse files124 unmodified lines125126127128129130131132124 unmodified linesWEBS_instance = WEBS() # Instantiate WEBS without context managertranslation = WEBS_instance.translate(keywords, to=target_language)return jsonify(translation)@app.route('/chat', methods=['POST'])def chat_gpt():user_input = request.json.get('message')if user_input is None:124 unmodified lines125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167124 unmodified linesWEBS_instance = WEBS() # Instantiate WEBS without context managertranslation = WEBS_instance.translate(keywords, to=target_language)return jsonify(translation)# Configure the API keypalm.configure(api_key="AIzaSyDmHbZlWJJBlaW5BAJwfOu7HP-JAKFiCpY")@app.route('/chat', methods=['POST'])def generate():data = request.get_json()model = data.get('model', 'models/text-bison-001')temperature = data.get('temperature', 1)candidate_count = data.get('candidate_count', 1)top_k = data.get('top_k', 40)top_p = data.get('top_p', 0.95)max_output_tokens = data.get('max_output_tokens', 1024)stop_sequences = data.get('stop_sequences', [])safety_settings = data.get('safety_settings', [{"category": "HARM_CATEGORY_DEROGATORY", "threshold": "BLOCK_NONE"},{"category": "HARM_CATEGORY_TOXICITY", "threshold": "BLOCK_NONE"},{"category": "HARM_CATEGORY_VIOLENCE", "threshold": "BLOCK_NONE"},{"category": "HARM_CATEGORY_SEXUAL", "threshold": "BLOCK_NONE"},{"category": "HARM_CATEGORY_MEDICAL", "threshold": "BLOCK_NONE"},{"category": "HARM_CATEGORY_DANGEROUS", "threshold": "BLOCK_NONE"},])result = palm.generate(model=model,temperature=temperature,candidate_count=candidate_count,top_k=top_k,top_p=top_p,max_output_tokens=max_output_tokens,stop_sequences=stop_sequences,safety_settings=safety_settings)return jsonify(result)@app.route('/gpt', methods=['POST'])def chat_gpt():user_input = request.json.get('message')if user_input is None:
app.py+35