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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
from google import genai
from google.genai import types
import flask
import flask_cors
app = flask.Flask(__name__)
flask_cors.CORS(app)
UPLOAD_FOLDER = "uploads"
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
client = genai.Client(api_key="AIzaSyA-mA7v4xlbEAz80uKf3Dywpbeh9ZfpLMs")
@app.route("/yeah", methods=["POST"])
def yeah_flask():
uploaded_files = flask.request.files.getlist("files")
file_names = []
contents = []
for file in uploaded_files:
file_data = file.read()
print(file.filename)
file_names.append(file.filename)
contents.append(
types.Part.from_bytes(
data=file_data,
mime_type=file.mimetype
)
)
contents.append("Please summarise the following content. Make it concise, but detailed (this is a priority), organised into a mind map, structured with clear hierarchy, where each item is first prefixed and just prefixed with a > times depth, where depth starts at 1. For example, a sub item would be \">> subitem\". Do not start or end your message with an approval message, start immediately with the content requested. Absolutely do not add any blank lines, and do not add spaces OR numbering after the '>' prefix.")
response = client.models.generate_content(
model="gemini-2.0-flash",
contents=contents
)
print(response)
print("hi")
return flask.jsonify({"status": "success", "map": response.text})
if __name__ == '__main__':
app.run(debug=True, host='127.0.0.1', port=9000)
|