Spaces:
Runtime error
Runtime error
import gradio | |
import gradio as gr | |
import os | |
from transformers import pipeline | |
summarizer = pipeline("summarization") | |
def my_inference_function(text,key: str): | |
if len(str(text)) < 10: | |
return "Error, text is too short!" | |
if key != os.environ.get("key"): | |
return "Error, the key is incorrect!" | |
return summarizer(text) | |
gradio_interface = gradio.Interface( | |
fn = my_inference_function, | |
inputs =[gr.Textbox( | |
label="prompt", placeholder="What is the capital of France"), | |
gr.Textbox(label="key")], | |
outputs = "text" | |
) | |
gradio_interface.launch() | |