Spaces:
Running
Running
Delete app.py with huggingface_hub
Browse files
app.py
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import os
|
3 |
-
|
4 |
-
# save your HF API token from https:/hf.co/settings/tokens as an env variable to avoid rate limiting
|
5 |
-
auth_token = os.getenv("auth_token")
|
6 |
-
|
7 |
-
# load a model from https://hf.co/models as an interface, then use it as an api
|
8 |
-
# you can remove the api_key parameter if you don't care about rate limiting.
|
9 |
-
api = gr.Interface.load("huggingface/EleutherAI/gpt-j-6B", api_key=auth_token)
|
10 |
-
|
11 |
-
def complete_with_gpt(text):
|
12 |
-
return text[:-50] + api(text[-50:])
|
13 |
-
|
14 |
-
with gr.Blocks() as demo:
|
15 |
-
textbox = gr.Textbox(placeholder="Type here...", lines=4)
|
16 |
-
btn = gr.Button("Autocomplete")
|
17 |
-
|
18 |
-
# define what will run when the button is clicked, here the textbox is used as both an input and an output
|
19 |
-
btn.click(fn=complete_with_gpt, inputs=textbox, outputs=textbox, queue=False)
|
20 |
-
|
21 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|