Guiyom commited on
Commit
f34905f
·
1 Parent(s): 2a2fe69

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -7,7 +7,7 @@ openai.api_key = os.environ.get('openai-api')
7
 
8
  #Functions
9
  def generate_story(character1, character2, character3, character4, localizer, agefor, language, wordstouse):
10
- agefor = min(max(agefor, 2), 20) # Ensure agefor is between 0 and 20
11
 
12
  # Define the prompt
13
  prompt = f'A story about {character1}, {character2}, {character3}, and {character4}, set in {localizer}.' \
@@ -30,7 +30,7 @@ def generate_story(character1, character2, character3, character4, localizer, ag
30
  )
31
 
32
  # Return the story
33
- return response.choices[0].text.strip()
34
 
35
  with gr.Blocks() as demo:
36
  gr.Markdown("Enter the details below and then click **Make me a story** to generate your story.")
@@ -46,7 +46,7 @@ with gr.Blocks() as demo:
46
  wordstouse = gr.Textbox(label="Words for reading", info="Put here the words you would like the child to train on, not compulstory", placeholder= "the then car if this ...")
47
  with gr.Row():
48
  localizer = gr.Textbox(label="Location", value="Hong Kong", placeholder="Location")
49
- agefor = gr.Slider(minimum=6, maximum=20, step=1, value=10, label="Age of the child")
50
  language = gr.Dropdown(choices=["Mandarin", "Cantonese", "French", "English", "Korean", "Italian", "German", "Russian"], label="Language of the story", value="English")
51
  with gr.Row():
52
  btn = gr.Button("Make me a bed time story")
 
7
 
8
  #Functions
9
  def generate_story(character1, character2, character3, character4, localizer, agefor, language, wordstouse):
10
+ agefor = min(max(agefor, 2), 12) # Ensure agefor is between 0 and 20
11
 
12
  # Define the prompt
13
  prompt = f'A story about {character1}, {character2}, {character3}, and {character4}, set in {localizer}.' \
 
30
  )
31
 
32
  # Return the story
33
+ return response['choices'][0]['message']['content']
34
 
35
  with gr.Blocks() as demo:
36
  gr.Markdown("Enter the details below and then click **Make me a story** to generate your story.")
 
46
  wordstouse = gr.Textbox(label="Words for reading", info="Put here the words you would like the child to train on, not compulstory", placeholder= "the then car if this ...")
47
  with gr.Row():
48
  localizer = gr.Textbox(label="Location", value="Hong Kong", placeholder="Location")
49
+ agefor = gr.Slider(minimum=2, maximum=12, step=1, value=6, label="Age of the child")
50
  language = gr.Dropdown(choices=["Mandarin", "Cantonese", "French", "English", "Korean", "Italian", "German", "Russian"], label="Language of the story", value="English")
51
  with gr.Row():
52
  btn = gr.Button("Make me a bed time story")