Gabriel commited on
Commit
8bf28d6
1 Parent(s): f99e432

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -13
app.py CHANGED
@@ -1,22 +1,17 @@
1
  import gradio as gr
2
 
 
3
 
4
- def flip_text(x):
5
- return x[::-1]
6
 
 
 
 
7
 
8
- demo = gr.Blocks()
9
 
10
- with demo:
11
- gr.Markdown(
12
- """
13
- # Flip Text!
14
- Start typing below to see the output.
15
- """
16
- )
17
- input = gr.Textbox(placeholder="Flip this text")
18
- output = gr.Textbox()
19
 
20
- input.change(fn=flip_text, inputs=input, outputs=output)
21
 
22
  demo.launch()
 
1
  import gradio as gr
2
 
3
+ api = gr.Interface.load("huggingface/EleutherAI/gpt-j-6B")
4
 
 
 
5
 
6
+ def complete_with_gpt(text):
7
+ # Use the last 50 characters of the text as context
8
+ return text[:-50] + api(text[-50:])
9
 
 
10
 
11
+ with gr.Blocks() as demo:
12
+ textbox = gr.Textbox(placeholder="Type here and press enter...", lines=4)
13
+ btn = gr.Button("Generate")
 
 
 
 
 
 
14
 
15
+ btn.click(complete_with_gpt, textbox, textbox)
16
 
17
  demo.launch()