Mistral-8x7b / flask_app.py
DevsDoCode's picture
Upload 4 files
cbbe463 verified
raw
history blame
1.37 kB
from flask import Flask, request, jsonify
import mistral_8x7b
import api_info
app = Flask(__name__)
@app.route('/')
def initial():
return '<pre>' + api_info.default_info + '</pre>'
@app.route("/available_models", methods=['GET'])
def available_models():
return jsonify(api_info.available_models)
@app.route("/endpoints", methods=['GET'])
def endpoints():
return jsonify(api_info.endpoint)
@app.route("/developer_info", methods=['GET'])
def developer_info():
return jsonify(api_info.developer_info)
@app.route('/generate', methods=['GET'])
def generate():
query = request.args.get('query') # Question to ask
system_prompt = str(request.args.get('system', "Be Helpful and Friendly. Keep your response straightfoward, short and concise")) # Optional parameter with default value
max_tokens = int(request.args.get('max_tokens', 1280)) # Optional parameter with default value
temperature = float(request.args.get('temperature', 0.9)) # Optional parameter with default value
if query:
response = mistral_8x7b.generate(query, system_prompt=system_prompt, max_tokens=max_tokens, temperature=temperature)
return jsonify([{'response': response}, {'developer_info': api_info.developer_info}])
else:
return jsonify(api_info.error_message), 400
if __name__ == '__main__':
app.run(debug=True)