aimaswx commited on
Commit
7f1bb53
·
1 Parent(s): 7173dbe

create new file

Browse files
Files changed (1) hide show
  1. app.py +13 -0
app.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Back to Lesson 2, time flies!
2
+ from text_generation import Client
3
+ import gradio as gr
4
+ #FalcomLM-instruct endpoint on the text_generation library
5
+ client = Client("https://api-inference.huggingface.co/models/tiiuae/falcon-40b-instruct", headers={"Authorization": f"Bearer {hf_api_key}"}, timeout=120)
6
+ hf_api_key = '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'
7
+
8
+ def generate(input, slider):
9
+ output = client.generate(input, max_new_tokens=slider).generated_text
10
+ return output
11
+
12
+ demo = gr.Interface(fn=generate, inputs=[gr.Textbox(label="Prompt"), gr.Slider(label="Max new tokens", value=20, maximum=1024, minimum=1)], outputs=[gr.Textbox(label="Completion")])
13
+ demo.launch()