mirror of
https://github.com/gradio-app/gradio.git
synced 2024-11-27 01:40:20 +08:00
38b16beb16
* Switch model and fix demo * fix remaining demos --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
16 lines
426 B
Python
16 lines
426 B
Python
import gradio as gr
|
|
|
|
api = gr.load("huggingface/gpt2-xl")
|
|
|
|
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:
|
|
textbox = gr.Textbox(placeholder="Type here and press enter...", lines=4)
|
|
btn = gr.Button("Generate")
|
|
|
|
btn.click(complete_with_gpt, textbox, textbox)
|
|
|
|
if __name__ == "__main__":
|
|
demo.launch() |