-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
30 lines (24 loc) · 1.06 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from flask import Flask, request, jsonify
import openai_local
import requests
app = Flask(__name__)
# # Route to handle GET requests
# @app.route('/get', methods=['GET'])
# def handle_get():
# data = request.args # Get query parameters from the URL
# return jsonify({"received": data})
# Route to handle POST requests
@app.route('/post', methods=['POST'])
def handle_post():
data = request.json # Expecting JSON data in POST body
citizenship_status = data['citizenship_status']
location = data['location']
more_info = data['more_info']
university = data['university']
category = data['category']
prompt = f"""I am a/an {citizenship_status} planning to live in {location}. I am {more_info}. I plan to attend {university}. Please give me a breakdown of my {category} costs.
When you give the output, make sure its a json object. Do not add any information to the response, just the json object"""
response = openai_local.generate_text(prompt)
return jsonify({"received": response})
if __name__ == '__main__':
app.run(debug=True)