sandeepmajumdar commited on
Commit
c92b89d
·
1 Parent(s): 9e4442b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -3
app.py CHANGED
@@ -1,3 +1,45 @@
1
- import gradio as gr
2
- iface = gr.Interface.load("huggingface/bigscience/bloom-1b1", examples=[['The main cloud services provided by AWS are '], ['The pricing of Amazon S3 is ']])
3
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
11
+ def generate(prompt):
12
+ json_ = {"inputs": prompt,
13
+ "parameters":
14
+ {
15
+ "top_p": 0.9,
16
+ "temperature": 1.1,
17
+ "max_new_tokens": 64,
18
+ "return_full_text": False,
19
+ },
20
+ "options":
21
+ {"use_cache": True,
22
+ "wait_for_model": True,
23
+ },}
24
+ response = requests.post(API_URL, headers=headers, json=json_)
25
+ output = response.json()
26
+ output_tmp = output[0]['generated_text']
27
+ return output_tmp
28
+
29
+ demo = gr.Blocks()
30
+
31
+ with demo:
32
+ gr.Markdown("<h1><center>Article Generation using Bloom</center></h1>")
33
+ with gr.Row():
34
+ example_prompt = gr.Radio( [
35
+ "The main cloud services provided by AWS are: ",
36
+ "The pricing of Amazon EC3 is: ",
37
+ "The main competitors of AWS are: ", ], label= "Try these prompts in sequence, or type any text of your choice")
38
+
39
+ with gr.Row():
40
+ generated_txt = gr.Textbox()
41
+
42
+ b1 = gr.Button("Generate SQL")
43
+ b1.click(generate,inputs=example_prompt, outputs=generated_txt)
44
+
45
+ demo.launch(enable_queue=True)