Blessin commited on
Commit
d953ba2
·
1 Parent(s): d789bea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -5
app.py CHANGED
@@ -1,14 +1,25 @@
 
1
  import openai
2
 
3
- def test_generate_story(names, story_title, api_key):
4
  openai.api_key = api_key
5
  response = openai.Completion.create(
6
  engine="gpt-3.5-turbo",
7
- prompt=f"Title: {story_title}\n\nIn a fantasy world, {names} embarked on a journey.",
8
  max_tokens=150
9
  )
10
  story = response.choices[0].text.strip()
11
- print(story)
12
 
13
- # Call the function with some test values
14
- test_generate_story("Alice, Bob", "The Enchanted Forest", "YOUR_OPENAI_API_KEY_HERE")
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
  import openai
3
 
4
+ def generate_story(names, story_title, api_key):
5
  openai.api_key = api_key
6
  response = openai.Completion.create(
7
  engine="gpt-3.5-turbo",
8
+ prompt=f"Title: {story_title}\n\nIn a fantasy world, {names} embarked on an absurd and funny journey. {names}",
9
  max_tokens=150
10
  )
11
  story = response.choices[0].text.strip()
12
+ return story
13
 
14
+ iface = gr.Interface(
15
+ fn=generate_story,
16
+ inputs=[
17
+ gr.components.Textbox(label="Enter names (comma-separated for multiple)"),
18
+ gr.components.Textbox(label="Enter story title"),
19
+ gr.components.Textbox(label="OpenAI API Key", type="password")
20
+ ],
21
+ outputs="text",
22
+ live=True
23
+ )
24
+
25
+ iface.launch()