Patrick079 commited on
Commit
a8487ac
·
verified ·
1 Parent(s): 9da51e4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -1,10 +1,10 @@
1
  import random
2
  import os
3
  import gradio as gr
4
- import google.generativeai as genai # Importing the Gemini API module
5
 
6
  # Initialize the Gemini model
7
- Model = genai.GenerativeModel('gemini-1.5-flash') # Initialize the generative model
8
 
9
  def chat_short_story(length, genre, theme, tone, writing_style):
10
  """
@@ -39,9 +39,9 @@ def chat_short_story(length, genre, theme, tone, writing_style):
39
 
40
  # Generate a response using the Gemini model
41
  try:
42
- chat = Model.start_chat() # Start a chat session
43
- response = chat.send_message(prompt) # Send the prompt to the model
44
- return response.text # Extract the content of the response
45
  except Exception as e:
46
  return f"Error: Failed to generate story. Details: {e}"
47
 
@@ -80,7 +80,7 @@ iface = gr.Interface(
80
  gr.Dropdown(label="Story Tone", choices=Tones)
81
  ],
82
  outputs=gr.Textbox(label="Generated Story"),
83
- title="Patrick's Story Generator",
84
  description="Generate creative short stories tailored to your preferences."
85
  )
86
 
 
1
  import random
2
  import os
3
  import gradio as gr
4
+ import google.generativeai as genai
5
 
6
  # Initialize the Gemini model
7
+ Model = genai.GenerativeModel('gemini-1.5-flash')
8
 
9
  def chat_short_story(length, genre, theme, tone, writing_style):
10
  """
 
39
 
40
  # Generate a response using the Gemini model
41
  try:
42
+ chat = Model.start_chat()
43
+ response = chat.send_message(prompt)
44
+ return response.text
45
  except Exception as e:
46
  return f"Error: Failed to generate story. Details: {e}"
47
 
 
80
  gr.Dropdown(label="Story Tone", choices=Tones)
81
  ],
82
  outputs=gr.Textbox(label="Generated Story"),
83
+ title="Welcome to Patrick's Story Generator",
84
  description="Generate creative short stories tailored to your preferences."
85
  )
86