Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,31 +1,14 @@
|
|
| 1 |
-
import
|
| 2 |
-
import
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
return x[::-1]
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
def flip_image(x):
|
| 10 |
-
return np.fliplr(x)
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
with gr.Blocks() as demo:
|
| 14 |
-
gr.Markdown("Flip text or image files using this demo.")
|
| 15 |
-
with gr.Tab("Flip Text"):
|
| 16 |
-
text_input = gr.Textbox()
|
| 17 |
-
text_output = gr.Textbox()
|
| 18 |
-
text_button = gr.Button("Flip")
|
| 19 |
-
with gr.Tab("Flip Image"):
|
| 20 |
-
with gr.Row():
|
| 21 |
-
image_input = gr.Image()
|
| 22 |
-
image_output = gr.Image()
|
| 23 |
-
image_button = gr.Button("Flip")
|
| 24 |
-
|
| 25 |
-
with gr.Accordion("Open for More!"):
|
| 26 |
-
gr.Markdown("Look at me...")
|
| 27 |
-
|
| 28 |
-
text_button.click(flip_text, inputs=text_input, outputs=text_output)
|
| 29 |
-
image_button.click(flip_image, inputs=image_input, outputs=image_output)
|
| 30 |
|
|
|
|
|
|
|
| 31 |
demo.launch()
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import openai
|
| 3 |
|
| 4 |
+
def gpt(api_key):
|
| 5 |
+
completion = openai.ChatCompletion.create(
|
| 6 |
+
model="gpt-3.5-turbo",
|
| 7 |
+
messages=[{"role": "user", "content": "Generate a fake news story"}]
|
| 8 |
+
)
|
| 9 |
|
| 10 |
+
return completion.choices[0].message.content
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
demo = gr.Interface(fn=gpt, inputs="text", outputs="text")
|
| 13 |
+
|
| 14 |
demo.launch()
|