sandeepmajumdar commited on
Commit
9a9a4a3
1 Parent(s): cd029b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -40
app.py CHANGED
@@ -1,44 +1,17 @@
1
  import gradio as gr
2
- import requests
3
- import os
4
 
5
- ##Bloom
6
- API_URL = "https://api-inference.huggingface.co/models/bigscience/bloom"
7
- HF_TOKEN = os.environ["HF_TOKEN"]
8
- headers = {"Authorization": f"Bearer {HF_TOKEN}"}
9
 
10
- def generate(prompt):
11
- json_ = {"inputs": prompt,
12
- "parameters":
13
- {
14
- "top_p": 0.9,
15
- "temperature": 1.1,
16
- "max_new_tokens": 64,
17
- "return_full_text": False,
18
- },
19
- "options":
20
- {"use_cache": True,
21
- "wait_for_model": True,
22
- },}
23
- response = requests.post(API_URL, headers=headers, json=json_)
24
- output = response.json()
25
- output_tmp = output[0]['generated_text']
26
- return output_tmp
27
 
28
- demo = gr.Blocks()
29
-
30
- with demo:
31
- gr.Markdown("<h1><center>Article Generation using Bloom</center></h1>")
32
- with gr.Row():
33
- example_prompt = gr.Radio( [
34
- "The main cloud services provided by AWS are: ",
35
- "The pricing of Amazon EC3 is: ",
36
- "The main competitors of AWS are: ", ], label= "Try these prompts in sequence, or type any text of your choice")
37
-
38
- with gr.Row():
39
- generated_txt = gr.Textbox()
40
-
41
- b1 = gr.Button("Generate SQL")
42
- b1.click(generate,inputs=example_prompt, outputs=generated_txt)
43
-
44
- demo.launch(enable_queue=True)
 
1
  import gradio as gr
2
+ from transformers import pipeline
 
3
 
4
+ def convert(Sentence):
5
+ model = pipeline('text-generation', model='bigscience/bloom-1b1')
6
+ result = model(Sentence)
7
+ return result[0]['label'])
8
 
9
+ with gr.Blocks() as bls:
10
+ gr.Markdown("Here is a Text Generation app")
11
+ with gr.Row():
12
+ inp = gr.Textbox(label="Type your prompt here and click Run", placeholder='Example: The main cloud services of AWS are:')
13
+ out = gr.Textbox(label="The sentiment is:")
14
+ btn = gr.Button("Run")
15
+ btn.click(fn=convert, inputs=inp, outputs=out)
 
 
 
 
 
 
 
 
 
 
16
 
17
+ bls.launch()