Spaces:
Configuration error
Configuration error
Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,20 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
-
from transformers import pipeline
|
3 |
|
4 |
-
|
5 |
|
6 |
-
def generate(text):
|
7 |
-
result = generator(text, max_length=100, num_return_sequences=3)
|
8 |
-
return result[0]["generated_text"]
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
[
|
13 |
-
]
|
14 |
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
demo.launch()
|
|
|
1 |
+
#level 5 text generator
|
2 |
import gradio as gr
|
|
|
3 |
|
4 |
+
api = gr.Interface.load("huggingface/EleutherAI/gpt-j-6B")
|
5 |
|
|
|
|
|
|
|
6 |
|
7 |
+
def complete_with_gpt(text):
|
8 |
+
# Use the last 50 characters of the text as context
|
9 |
+
return text[:-50] + api(text[-50:])
|
|
|
10 |
|
11 |
+
|
12 |
+
with gr.Blocks() as demo:
|
13 |
+
with gr.Row():
|
14 |
+
textbox = gr.Textbox(placeholder="Type here and press enter...", lines=4)
|
15 |
+
with gr.Column():
|
16 |
+
btn = gr.Button("Generate")
|
17 |
+
|
18 |
+
btn.click(complete_with_gpt, textbox, textbox)
|
19 |
|
20 |
demo.launch()
|