Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,11 +10,11 @@ genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
|
10 |
|
11 |
# Function to get response from Gemini model
|
12 |
def get_gemini_response(input_prompt, image_data, genre, length, language, mood):
|
|
|
13 |
if image_data:
|
14 |
full_prompt = f"""
|
15 |
You are a famous creative writer. Look at the image provided and create a {length} {genre} in {language}. The {genre} should be {mood}. The {genre} should be based on the image and contain realistic and emotional elements.
|
16 |
"""
|
17 |
-
response = genai.generate_content([full_prompt, image_data[0]])
|
18 |
else:
|
19 |
full_prompt = f"""
|
20 |
You are a creative writer. Create a {length} {genre} in {language}. The {genre} should be {mood}. The {genre} should be based on the following prompt:
|
@@ -23,11 +23,13 @@ def get_gemini_response(input_prompt, image_data, genre, length, language, mood)
|
|
23 |
|
24 |
Make sure it contains realistic and emotional elements.
|
25 |
"""
|
26 |
-
|
27 |
-
|
|
|
|
|
28 |
# Check if response is valid and return text
|
29 |
-
if response and response
|
30 |
-
return response
|
31 |
else:
|
32 |
raise ValueError("Sorry, But please try a different combination of inputs.")
|
33 |
|
|
|
10 |
|
11 |
# Function to get response from Gemini model
|
12 |
def get_gemini_response(input_prompt, image_data, genre, length, language, mood):
|
13 |
+
# Prepare the prompts
|
14 |
if image_data:
|
15 |
full_prompt = f"""
|
16 |
You are a famous creative writer. Look at the image provided and create a {length} {genre} in {language}. The {genre} should be {mood}. The {genre} should be based on the image and contain realistic and emotional elements.
|
17 |
"""
|
|
|
18 |
else:
|
19 |
full_prompt = f"""
|
20 |
You are a creative writer. Create a {length} {genre} in {language}. The {genre} should be {mood}. The {genre} should be based on the following prompt:
|
|
|
23 |
|
24 |
Make sure it contains realistic and emotional elements.
|
25 |
"""
|
26 |
+
|
27 |
+
# Call the API (the method might differ; check the documentation)
|
28 |
+
response = genai.generate([full_prompt]) # Cambiar aqu铆 si es necesario seg煤n la documentaci贸n
|
29 |
+
|
30 |
# Check if response is valid and return text
|
31 |
+
if response and response[0]: # Ajusta el 铆ndice seg煤n la respuesta de la API
|
32 |
+
return response[0].text
|
33 |
else:
|
34 |
raise ValueError("Sorry, But please try a different combination of inputs.")
|
35 |
|