mherlie commited on
Commit
76f4a28
Β·
1 Parent(s): afe13f7

edit code again

Browse files
Files changed (1) hide show
  1. app.py +13 -19
app.py CHANGED
@@ -24,7 +24,6 @@ def generate_text(prompt, model, max_tokens, temperature):
24
  "temperature": temperature,
25
  },
26
  )
27
- # βœ… Extract and return generated text
28
  if response and response.candidates:
29
  return response.candidates[0].content.parts[0].text
30
  else:
@@ -36,35 +35,30 @@ def generate_text(prompt, model, max_tokens, temperature):
36
  # βœ… Streamlit Page Configuration
37
  st.set_page_config(page_title="Gemini AI Text Generator", layout="centered")
38
 
39
- # βœ… UI Layout - Title & Description
40
- st.title("πŸ“ Creative AI Assistant")
41
- st.markdown("#### Generate AI-powered text with ease. Simply enter a prompt and customize the settings!")
42
 
43
- # βœ… User Input Fields
44
- st.markdown("##### ✍🏼 Enter Your Prompt")
45
- user_input = st.text_area("Write something...", height=150, placeholder="Example: Write a formal article about climate change.")
46
 
47
- # βœ… Layout for Options
48
- col1, col2 = st.columns(2)
 
49
 
50
- with col1:
51
- model = st.selectbox("πŸ€– Choose AI Model", ["gemini-pro", "gemini-pro-code"])
52
- max_tokens = st.slider("πŸ“ Max Tokens (Word Length)", min_value=50, max_value=1000, value=300, step=50)
53
 
54
- with col2:
55
- temperature = st.slider("🎨 Creativity Level (1-10)", min_value=1, max_value=10, value=5) / 10 # Scaling to 0.1 - 1.0
56
-
57
- # βœ… Generate Button
58
- st.markdown("### ")
59
  if st.button("πŸš€ Generate Text"):
60
  if user_input.strip():
61
  with st.spinner("✨ Generating response..."):
62
  result = generate_text(user_input, model, max_tokens, temperature)
63
- st.markdown("### 🎯 Generated Response")
64
  st.write(result)
65
  else:
66
  st.warning("⚠️ Please enter a prompt before generating text.")
67
 
68
  # βœ… Footer
69
  st.markdown("---")
70
- st.caption("πŸ”Ή *Powered by Gemini AI* | πŸ”Ή *Developed with Streamlit*")
 
24
  "temperature": temperature,
25
  },
26
  )
 
27
  if response and response.candidates:
28
  return response.candidates[0].content.parts[0].text
29
  else:
 
35
  # βœ… Streamlit Page Configuration
36
  st.set_page_config(page_title="Gemini AI Text Generator", layout="centered")
37
 
38
+ # βœ… Title & Description
39
+ st.title("πŸ€– Gemini AI Text Generator")
40
+ st.write("Generate AI-powered text by entering a prompt and customizing the settings.")
41
 
42
+ # βœ… Input Prompt
43
+ user_input = st.text_area("πŸ“ Enter Your Prompt:", height=150, placeholder="Example: Write a formal article about climate change.")
 
44
 
45
+ # βœ… Sliders (Aligned Below Prompt)
46
+ temperature = st.slider("🎨 Creativity Level (1-10)", min_value=1, max_value=10, value=5) / 10
47
+ max_tokens = st.slider("πŸ“ Max Tokens (Word Length)", min_value=50, max_value=1000, value=300, step=50)
48
 
49
+ # βœ… AI Model Selection (Below Sliders)
50
+ model = st.selectbox("πŸ€– Choose AI Model", ["gemini-pro", "gemini-pro-code"])
 
51
 
52
+ # βœ… Generate Button (Below Model Selection)
 
 
 
 
53
  if st.button("πŸš€ Generate Text"):
54
  if user_input.strip():
55
  with st.spinner("✨ Generating response..."):
56
  result = generate_text(user_input, model, max_tokens, temperature)
57
+ st.subheader("🎯 Generated Response")
58
  st.write(result)
59
  else:
60
  st.warning("⚠️ Please enter a prompt before generating text.")
61
 
62
  # βœ… Footer
63
  st.markdown("---")
64
+ st.write("πŸ”Ή *Powered by Gemini AI* | πŸ”Ή *Developed with Streamlit*")