Spaces:
Build error
Build error
import gradio as gr | |
import requests | |
import os | |
##Bloom | |
API_URL = "https://api-inference.huggingface.co/models/bigscience/bloom" | |
HF_TOKEN = os.environ["HF_TOKEN"] | |
headers = {"Authorization": f"Bearer {HF_TOKEN}"} | |
def generate(prompt): | |
json_ = {"inputs": prompt, | |
"parameters": | |
{ | |
"top_p": 0.9, | |
"temperature": 1.1, | |
"max_new_tokens": 64, | |
"return_full_text": False, | |
}, | |
"options": | |
{"use_cache": True, | |
"wait_for_model": True, | |
},} | |
response = requests.post(API_URL, headers=headers, json=json_) | |
output = response.json() | |
output_tmp = output[0]['generated_text'] | |
return output_tmp | |
demo = gr.Blocks() | |
with demo: | |
gr.Markdown("<h1><center>Article Generation using Bloom</center></h1>") | |
with gr.Row(): | |
example_prompt = gr.Radio( [ | |
"The main cloud services provided by AWS are: ", | |
"The pricing of Amazon EC3 is: ", | |
"The main competitors of AWS are: ", ], label= "Try these prompts in sequence, or type any text of your choice") | |
with gr.Row(): | |
generated_txt = gr.Textbox() | |
b1 = gr.Button("Generate SQL") | |
b1.click(generate,inputs=example_prompt, outputs=generated_txt) | |
demo.launch(enable_queue=True) |