Spaces:
Sleeping
Sleeping
Commit
·
8cfb467
1
Parent(s):
b54fe3d
Update app.py
Browse files
app.py
CHANGED
@@ -37,6 +37,16 @@ with st.spinner(text="Please wait while the model is loading...."):
|
|
37 |
tokenizer = load_tokenizer('nafisehNik/girt-t5-base')
|
38 |
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
def compute(sample, top_p, top_k, do_sample, max_length, min_length):
|
41 |
|
42 |
inputs = tokenizer(sample, return_tensors="pt").to('cpu')
|
@@ -90,19 +100,24 @@ with st.sidebar:
|
|
90 |
in_name = st.text_input("Name Metadata: ", placeholder="e.g., Bug Report or Feqture Request or Question", on_change=None)
|
91 |
in_about = st.text_input("About Metadata: ", placeholder="e.g., File a bug report", on_change=None)
|
92 |
|
93 |
-
|
94 |
if empty_title == False:
|
95 |
in_title = st.text_input("Title Metadata: ", placeholder="e.g., [Bug]: ", on_change=None)
|
96 |
-
|
|
|
97 |
|
98 |
empty_labels = st.checkbox('without labels')
|
99 |
if empty_labels == False:
|
100 |
in_labels = st.text_input("Labels Metadata: ", placeholder="e.g., feature, enhancement", on_change=None)
|
101 |
-
|
|
|
|
|
102 |
empty_assignees = st.checkbox('without Assignees')
|
103 |
if empty_assignees == False:
|
104 |
in_assignees = st.text_input("Assignees Metadata: ", placeholder="e.g., USER_1, USER_2", on_change=None)
|
105 |
-
|
|
|
|
|
106 |
# if no headlines is selected, force the headlines to be empty as well.
|
107 |
in_headline_type = st.selectbox(
|
108 |
'How would you like to be your Headlines?',
|
@@ -110,6 +125,7 @@ with st.sidebar:
|
|
110 |
|
111 |
if in_headline_type!='No headlines':
|
112 |
in_headlines = st.text_area("Headlines: ", placeholder="Enter each headline in one line. e.g.,\nWelcome\nConcise Description\nAdditional Info", on_change=None, height=200)
|
|
|
113 |
else:
|
114 |
in_headline_type = '<|EMPTY|>'
|
115 |
in_headlines = '<|EMPTY|>'
|
@@ -127,6 +143,14 @@ with st.sidebar:
|
|
127 |
top_p = st.slider("top_p", 0.0, 1.0, 0.92)
|
128 |
top_k = st.slider("top_k", 0, 100, 0)
|
129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
|
131 |
tab1, tab2 = st.tabs(["Design GitHub Issue Template", "Manual Prompt"])
|
132 |
|
|
|
37 |
tokenizer = load_tokenizer('nafisehNik/girt-t5-base')
|
38 |
|
39 |
|
40 |
+
def create_instruction(name, about, title, labels, assignees, headline_type, headline, summary):
|
41 |
+
val_list = [name, about, title, labels, assignees, headline_type, headline]
|
42 |
+
|
43 |
+
val_list = ['<|MASK|>' if not element else element for element in val_list]
|
44 |
+
if not summary:
|
45 |
+
summary = '<|EMPTY|>'
|
46 |
+
|
47 |
+
instruction = f'name: {value_list[0]}\nabout: {value_list[1]}\ntitle: {value_list[2]}\nlabels: {value_list[3]}\nassignees: {value_list[4]}\nheadlines_type: {value_list[5]}\nheadlines: {value_list[6]}\nsummary: {summary}'
|
48 |
+
return instruction
|
49 |
+
|
50 |
def compute(sample, top_p, top_k, do_sample, max_length, min_length):
|
51 |
|
52 |
inputs = tokenizer(sample, return_tensors="pt").to('cpu')
|
|
|
100 |
in_name = st.text_input("Name Metadata: ", placeholder="e.g., Bug Report or Feqture Request or Question", on_change=None)
|
101 |
in_about = st.text_input("About Metadata: ", placeholder="e.g., File a bug report", on_change=None)
|
102 |
|
103 |
+
empty_title = st.checkbox('without title')
|
104 |
if empty_title == False:
|
105 |
in_title = st.text_input("Title Metadata: ", placeholder="e.g., [Bug]: ", on_change=None)
|
106 |
+
else:
|
107 |
+
in_title = '<|EMPTY|>'
|
108 |
|
109 |
empty_labels = st.checkbox('without labels')
|
110 |
if empty_labels == False:
|
111 |
in_labels = st.text_input("Labels Metadata: ", placeholder="e.g., feature, enhancement", on_change=None)
|
112 |
+
else:
|
113 |
+
in_labels = '<|EMPTY|>'
|
114 |
+
|
115 |
empty_assignees = st.checkbox('without Assignees')
|
116 |
if empty_assignees == False:
|
117 |
in_assignees = st.text_input("Assignees Metadata: ", placeholder="e.g., USER_1, USER_2", on_change=None)
|
118 |
+
else:
|
119 |
+
in_assignees = '<|EMPTY|>'
|
120 |
+
|
121 |
# if no headlines is selected, force the headlines to be empty as well.
|
122 |
in_headline_type = st.selectbox(
|
123 |
'How would you like to be your Headlines?',
|
|
|
125 |
|
126 |
if in_headline_type!='No headlines':
|
127 |
in_headlines = st.text_area("Headlines: ", placeholder="Enter each headline in one line. e.g.,\nWelcome\nConcise Description\nAdditional Info", on_change=None, height=200)
|
128 |
+
in_headlines = in_headlines.split('\n').strip()
|
129 |
else:
|
130 |
in_headline_type = '<|EMPTY|>'
|
131 |
in_headlines = '<|EMPTY|>'
|
|
|
143 |
top_p = st.slider("top_p", 0.0, 1.0, 0.92)
|
144 |
top_k = st.slider("top_k", 0, 100, 0)
|
145 |
|
146 |
+
|
147 |
+
clicked = st.button("Submit", key='prompt')
|
148 |
+
|
149 |
+
with st.spinner("Please Wait..."):
|
150 |
+
prompt = create_instruction(in_name, in_about, in_title, in_labels, in_assignees, in_headline_type, in_headlines, in_summary)
|
151 |
+
|
152 |
+
res = compute(prompt, top_p, top_k, do_sample=True, max_length, min_length)
|
153 |
+
st.code(res, language="python")
|
154 |
|
155 |
tab1, tab2 = st.tabs(["Design GitHub Issue Template", "Manual Prompt"])
|
156 |
|