Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
import
|
2 |
from google import genai
|
3 |
import os
|
4 |
|
@@ -15,22 +15,18 @@ def generate_content(prompt):
|
|
15 |
model="gemini-2.0-flash",
|
16 |
contents=[prompt]
|
17 |
)
|
18 |
-
|
|
|
|
|
|
|
|
|
19 |
|
20 |
-
#
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
# Button to trigger content generation
|
28 |
-
if st.button("Generate Content"):
|
29 |
-
if prompt:
|
30 |
-
# Get the response from the model
|
31 |
-
result = generate_content(prompt)
|
32 |
-
st.subheader("AI Response:")
|
33 |
-
st.markdown(result)
|
34 |
-
else:
|
35 |
-
st.warning("Please enter a prompt.")
|
36 |
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
from google import genai
|
3 |
import os
|
4 |
|
|
|
15 |
model="gemini-2.0-flash",
|
16 |
contents=[prompt]
|
17 |
)
|
18 |
+
|
19 |
+
# Format the result for better readability
|
20 |
+
result_text = response.text.strip() # Remove extra spaces and line breaks
|
21 |
+
formatted_response = f"**AI Generated Content:**\n\n{result_text}"
|
22 |
+
return formatted_response
|
23 |
|
24 |
+
# Gradio interface
|
25 |
+
interface = gr.Interface(fn=generate_content,
|
26 |
+
inputs="text",
|
27 |
+
outputs="markdown", # Output as markdown for better formatting
|
28 |
+
title="Gemini AI Content Generator",
|
29 |
+
description="Provide a prompt and get an explanation from Gemini AI.\n\nThe AI will return a well-formatted response.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
+
# Launch Gradio interface
|
32 |
+
interface.launch()
|