Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
|
|
| 1 |
import openai
|
| 2 |
|
| 3 |
-
def
|
| 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
|
| 8 |
max_tokens=150
|
| 9 |
)
|
| 10 |
story = response.choices[0].text.strip()
|
| 11 |
-
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|