File size: 1,255 Bytes
c92b89d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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)