Spaces:
Running
Running
This should work now
Browse filesI am now actually calling BLOOM.
app.py
CHANGED
@@ -1,7 +1,45 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import requests
|
3 |
+
import os
|
4 |
|
5 |
+
API_URL = "https://api-inference.huggingface.co/models/bigscience/bloom"
|
6 |
+
HF_TOKEN = os.environ["HF_TOKEN"]
|
7 |
+
headers = {"Authorization": f"Bearer {HF_TOKEN}"}
|
8 |
|
9 |
+
def get_results(prompt):
|
10 |
+
json_ = {"inputs": p,
|
11 |
+
"parameters":
|
12 |
+
{
|
13 |
+
"top_p": 0.9,
|
14 |
+
"typical_p":0.2
|
15 |
+
"temperature": 1.1,
|
16 |
+
"max_new_tokens": 250,
|
17 |
+
"return_full_text": True
|
18 |
+
}, "options":
|
19 |
+
{
|
20 |
+
"use_cache": True,
|
21 |
+
"wait_for_model":True
|
22 |
+
},}
|
23 |
+
try:
|
24 |
+
response = requests.post(API_URL, headers=headers, json=json_)
|
25 |
+
output = response.json()
|
26 |
+
output_tmp = output[0]['generated_text']
|
27 |
+
except:
|
28 |
+
output_tmp = "Not able to work"
|
29 |
+
return output_tmp
|
30 |
+
|
31 |
+
|
32 |
+
def learn_goals(topic, text):
|
33 |
+
prompt = "Topic: " + topic + '\n'
|
34 |
+
prompt = prompt + text + '\n'
|
35 |
+
prompt = prompt + """Some examples of learning goals from above are:
|
36 |
+
1. The student will be able to"""
|
37 |
+
|
38 |
+
return get_results(prompt)
|
39 |
+
|
40 |
+
|
41 |
+
topic = gr.Textbox(lines = 1, placeholder="Topic")
|
42 |
+
text = gr.Textbox(lines = 5, placeholder="Text")
|
43 |
+
|
44 |
+
iface = gr.Interface(fn=learn_goals, inputs=[topic, text], outputs="text")
|
45 |
iface.launch()
|