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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -15
app.py CHANGED
@@ -1,7 +1,6 @@
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",
@@ -9,17 +8,8 @@ def generate_story(names, story_title, api_key):
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()
 
 
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",
 
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 API key
15
+ test_generate_story("Alice, Bob", "The Enchanted Forest", "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")