Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,10 @@ from google.genai import types
|
|
| 4 |
from PIL import Image
|
| 5 |
from io import BytesIO
|
| 6 |
from google import genai
|
|
|
|
| 7 |
|
|
|
|
|
|
|
| 8 |
#Connect to index.html
|
| 9 |
app = Flask(__name__)
|
| 10 |
|
|
@@ -33,7 +36,7 @@ def write():
|
|
| 33 |
else:
|
| 34 |
word_limit = None
|
| 35 |
|
| 36 |
-
generativeai.configure(api_key=
|
| 37 |
|
| 38 |
try:
|
| 39 |
model = generativeai.GenerativeModel("gemini-2.0-flash")
|
|
@@ -63,7 +66,7 @@ def summarize():
|
|
| 63 |
if not question:
|
| 64 |
return jsonify({"error": "Please provide a question."}), 400
|
| 65 |
|
| 66 |
-
generativeai.configure(api_key=
|
| 67 |
|
| 68 |
try:
|
| 69 |
|
|
@@ -94,7 +97,7 @@ def think():
|
|
| 94 |
if not question:
|
| 95 |
return jsonify({"error": "Please provide a question."}), 400
|
| 96 |
|
| 97 |
-
generativeai.configure(api_key=
|
| 98 |
|
| 99 |
try:
|
| 100 |
model = generativeai.GenerativeModel('gemini-2.0-flash-thinking-exp-01-21')
|
|
@@ -121,7 +124,7 @@ def translate():
|
|
| 121 |
if not question:
|
| 122 |
return jsonify({"error": "Please provide a question."}), 400
|
| 123 |
|
| 124 |
-
generativeai.configure(api_key=
|
| 125 |
|
| 126 |
try:
|
| 127 |
|
|
@@ -145,7 +148,7 @@ def imagine():
|
|
| 145 |
if not contents:
|
| 146 |
return jsonify({"error": "Please provide a prompt."}), 400
|
| 147 |
|
| 148 |
-
client = genai.Client(api_key=
|
| 149 |
|
| 150 |
response = client.models.generate_content(
|
| 151 |
model="gemini-2.0-flash-preview-image-generation",
|
|
@@ -177,7 +180,7 @@ def ask():
|
|
| 177 |
if not question:
|
| 178 |
return jsonify({"error": "Please provide a question."}), 400
|
| 179 |
|
| 180 |
-
generativeai.configure(api_key=
|
| 181 |
|
| 182 |
try:
|
| 183 |
# use Google's Gemini-2.0-Flash nodle for generating content
|
|
|
|
| 4 |
from PIL import Image
|
| 5 |
from io import BytesIO
|
| 6 |
from google import genai
|
| 7 |
+
import os
|
| 8 |
|
| 9 |
+
CHAT_API_KEY = os.getenv("CHAT_APIKEY")
|
| 10 |
+
IMAGINE_API_KEY = os.getenv("IMAGE_API_KEY")
|
| 11 |
#Connect to index.html
|
| 12 |
app = Flask(__name__)
|
| 13 |
|
|
|
|
| 36 |
else:
|
| 37 |
word_limit = None
|
| 38 |
|
| 39 |
+
generativeai.configure(api_key=CHAT_API_KEY)
|
| 40 |
|
| 41 |
try:
|
| 42 |
model = generativeai.GenerativeModel("gemini-2.0-flash")
|
|
|
|
| 66 |
if not question:
|
| 67 |
return jsonify({"error": "Please provide a question."}), 400
|
| 68 |
|
| 69 |
+
generativeai.configure(api_key=CHAT_API_KEY)
|
| 70 |
|
| 71 |
try:
|
| 72 |
|
|
|
|
| 97 |
if not question:
|
| 98 |
return jsonify({"error": "Please provide a question."}), 400
|
| 99 |
|
| 100 |
+
generativeai.configure(api_key=CHAT_API_KEY)
|
| 101 |
|
| 102 |
try:
|
| 103 |
model = generativeai.GenerativeModel('gemini-2.0-flash-thinking-exp-01-21')
|
|
|
|
| 124 |
if not question:
|
| 125 |
return jsonify({"error": "Please provide a question."}), 400
|
| 126 |
|
| 127 |
+
generativeai.configure(api_key=CHAT_API_KEY)
|
| 128 |
|
| 129 |
try:
|
| 130 |
|
|
|
|
| 148 |
if not contents:
|
| 149 |
return jsonify({"error": "Please provide a prompt."}), 400
|
| 150 |
|
| 151 |
+
client = genai.Client(api_key=IMAGINE_API_KEY)
|
| 152 |
|
| 153 |
response = client.models.generate_content(
|
| 154 |
model="gemini-2.0-flash-preview-image-generation",
|
|
|
|
| 180 |
if not question:
|
| 181 |
return jsonify({"error": "Please provide a question."}), 400
|
| 182 |
|
| 183 |
+
generativeai.configure(api_key=CHAT_API_KEY)
|
| 184 |
|
| 185 |
try:
|
| 186 |
# use Google's Gemini-2.0-Flash nodle for generating content
|