File size: 496 Bytes
70865a3
605dfb9
 
1b2e00f
605dfb9
07e878c
70865a3
 
 
07e878c
70865a3
 
 
7648d2b
70865a3
 
 
 
07e878c
61dd4fb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#level 5 text generator
import gradio as gr

api = gr.Interface.load("huggingface/EleutherAI/gpt-neo-2.7B")


def complete_with_gpt(text):
    # Use the last 50 characters of the text as context
    return text[:-50] + api(text[-50:])


with gr.Blocks() as demo:
    with gr.Row():
        textbox = gr.Textbox(placeholder="Type here and press enter...", lines=8)
        with gr.Column():
            btn = gr.Button("Generate")

    btn.click(complete_with_gpt, textbox, textbox)

demo.launch()