Spaces:
Runtime error
Runtime error
Commit ·
731282b
1
Parent(s): 0953d01
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import openai
|
| 2 |
import gradio as gr
|
| 3 |
-
from gradio.components import Textbox, Image,
|
| 4 |
|
| 5 |
# Set up OpenAI API credentials
|
| 6 |
openai.api_key = "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"
|
|
@@ -34,12 +34,18 @@ def generate_image(prompt):
|
|
| 34 |
|
| 35 |
# Define the Gradio interface
|
| 36 |
prompt_input = Textbox("Enter a prompt", lines=3)
|
| 37 |
-
text_output =
|
| 38 |
image_output = Image()
|
| 39 |
|
|
|
|
|
|
|
|
|
|
| 40 |
def update_text_output(text, image_url):
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
iface = gr.Interface(
|
| 45 |
generate_image,
|
|
|
|
| 1 |
import openai
|
| 2 |
import gradio as gr
|
| 3 |
+
from gradio.components import Textbox, Image, Label
|
| 4 |
|
| 5 |
# Set up OpenAI API credentials
|
| 6 |
openai.api_key = "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"
|
|
|
|
| 34 |
|
| 35 |
# Define the Gradio interface
|
| 36 |
prompt_input = Textbox("Enter a prompt", lines=3)
|
| 37 |
+
text_output = Label("Generated text will appear here.")
|
| 38 |
image_output = Image()
|
| 39 |
|
| 40 |
+
# Initialize a variable to store the previous messages
|
| 41 |
+
previous_messages = ""
|
| 42 |
+
|
| 43 |
def update_text_output(text, image_url):
|
| 44 |
+
global previous_messages
|
| 45 |
+
# Concatenate the generated text with the previous messages
|
| 46 |
+
previous_messages += "\n" + text
|
| 47 |
+
# Set the text of the output Label to the concatenated string
|
| 48 |
+
text_output.text = previous_messages
|
| 49 |
|
| 50 |
iface = gr.Interface(
|
| 51 |
generate_image,
|