-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
26 lines (23 loc) · 830 Bytes
/
main.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
from flask import Flask, render_template, request
import google.generativeai as genai
import markdown
app = Flask(__name__)
genai.configure(api_key='API KEY')
generation_config = {
"temperature": 1,
"top_p": 0.95,
"top_k": 64,
"max_output_tokens": 8192,
"response_mime_type": "text/plain",
}
model = genai.GenerativeModel('gemini-1.5-pro', generation_config=generation_config, system_instruction="You are the `recipe generator`.")
@app.route('/', methods=['GET', 'POST'])
def main():
if request.method == 'GET':
return render_template('index.html')
else:
prompt = request.form['prompt']
recipe = model.generate_content(prompt).text
return render_template('index.html', recipe = markdown.markdown(recipe))
if __name__ == '__main__': # Not imported, which means not WSGI
app.run(debug=True)#