Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#Back to Lesson 2, time flies!
|
2 |
+
from text_generation import Client
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
hf_api_key = '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'
|
6 |
+
|
7 |
+
#FalcomLM-instruct endpoint on the text_generation library
|
8 |
+
client = Client("https://api-inference.huggingface.co/models/tiiuae/falcon-40b-instruct", headers={"Authorization": f"Bearer {hf_api_key}"}, timeout=120)
|
9 |
+
|
10 |
+
def generate(input, slider):
|
11 |
+
output = client.generate(input, max_new_tokens=slider).generated_text
|
12 |
+
return output
|
13 |
+
|
14 |
+
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")])
|
15 |
+
demo.launch()
|