Spaces:
Running
Running
DevsDoCode
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,42 +1,42 @@
|
|
1 |
-
from flask import Flask, request, jsonify
|
2 |
-
import openrouter
|
3 |
-
import api_info
|
4 |
-
|
5 |
-
app = Flask(__name__)
|
6 |
-
|
7 |
-
@app.route('/')
|
8 |
-
def initial():
|
9 |
-
return '<pre>' + api_info.default_info + '</pre>'
|
10 |
-
|
11 |
-
@app.route("/available_models", methods=['GET'])
|
12 |
-
def available_models():
|
13 |
-
return jsonify(api_info.available_models)
|
14 |
-
|
15 |
-
@app.route("/endpoints", methods=['GET'])
|
16 |
-
def endpoints():
|
17 |
-
return jsonify(api_info.endpoint)
|
18 |
-
|
19 |
-
@app.route("/developer_info", methods=['GET'])
|
20 |
-
def developer_info():
|
21 |
-
return jsonify(api_info.developer_info)
|
22 |
-
|
23 |
-
@app.route('/generate', methods=['GET'])
|
24 |
-
def generate():
|
25 |
-
|
26 |
-
query = request.args.get('query') # Assuming the query is sent in JSON format
|
27 |
-
system_prompt = str(request.args.get('system', "Be Helpful and Friendly. Keep your response straightfoward, short and concise")) # Optional parameter with default value
|
28 |
-
model = str(request.args.get('model', "openchat/openchat-7b")) # Optional parameter with default value
|
29 |
-
max_tokens = int(request.args.get('max_tokens', 512))
|
30 |
-
temperature = float(request.args.get('temperature', 0.7)) # Optional parameter with default value
|
31 |
-
|
32 |
-
if query:
|
33 |
-
response = openrouter.generate(query, model=model, system_prompt=system_prompt, temperature=temperature, max_tokens=max_tokens)
|
34 |
-
return jsonify([{'response':
|
35 |
-
|
36 |
-
else:
|
37 |
-
return jsonify(api_info.error_message), 400
|
38 |
-
|
39 |
-
if __name__ == '__main__':
|
40 |
-
app.run(debug=True)
|
41 |
-
|
42 |
-
|
|
|
1 |
+
from flask import Flask, request, jsonify
|
2 |
+
import openrouter
|
3 |
+
import api_info
|
4 |
+
|
5 |
+
app = Flask(__name__)
|
6 |
+
|
7 |
+
@app.route('/')
|
8 |
+
def initial():
|
9 |
+
return '<pre>' + api_info.default_info + '</pre>'
|
10 |
+
|
11 |
+
@app.route("/available_models", methods=['GET'])
|
12 |
+
def available_models():
|
13 |
+
return jsonify(api_info.available_models)
|
14 |
+
|
15 |
+
@app.route("/endpoints", methods=['GET'])
|
16 |
+
def endpoints():
|
17 |
+
return jsonify(api_info.endpoint)
|
18 |
+
|
19 |
+
@app.route("/developer_info", methods=['GET'])
|
20 |
+
def developer_info():
|
21 |
+
return jsonify(api_info.developer_info)
|
22 |
+
|
23 |
+
@app.route('/generate', methods=['GET'])
|
24 |
+
def generate():
|
25 |
+
|
26 |
+
query = request.args.get('query') # Assuming the query is sent in JSON format
|
27 |
+
system_prompt = str(request.args.get('system', "Be Helpful and Friendly. Keep your response straightfoward, short and concise")) # Optional parameter with default value
|
28 |
+
model = str(request.args.get('model', "openchat/openchat-7b")) # Optional parameter with default value
|
29 |
+
max_tokens = int(request.args.get('max_tokens', 512))
|
30 |
+
temperature = float(request.args.get('temperature', 0.7)) # Optional parameter with default value
|
31 |
+
|
32 |
+
if query:
|
33 |
+
# response = openrouter.generate(query, model=model, system_prompt=system_prompt, temperature=temperature, max_tokens=max_tokens)
|
34 |
+
return jsonify([{'response': "DEMO API IS OFFLINE. CONTACT `DEVS DO CODE`"}, {'developer_info': api_info.developer_info}]), 200
|
35 |
+
|
36 |
+
else:
|
37 |
+
return jsonify(api_info.error_message), 400
|
38 |
+
|
39 |
+
if __name__ == '__main__':
|
40 |
+
app.run(debug=True)
|
41 |
+
|
42 |
+
|