Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
import streamlit as st
|
2 |
import torch
|
|
|
3 |
import csv
|
4 |
import re
|
5 |
import warnings
|
6 |
-
from transformers import pipeline
|
7 |
|
8 |
warnings.filterwarnings("ignore")
|
9 |
|
@@ -14,15 +14,17 @@ MAGICODER_PROMPT = """You are an exceptionally intelligent coding assistant that
|
|
14 |
@@ Response
|
15 |
"""
|
16 |
|
17 |
-
#
|
18 |
-
generator =
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
23 |
{torch.nn.Linear},
|
24 |
dtype=torch.qint8
|
25 |
)
|
|
|
26 |
|
27 |
# Function to generate response
|
28 |
def generate_response(instruction):
|
@@ -39,16 +41,6 @@ def save_to_csv(data, filename):
|
|
39 |
writer = csv.writer(csvfile)
|
40 |
writer.writerow(data)
|
41 |
|
42 |
-
# Function to process user feedback
|
43 |
-
def process_output(correct_output):
|
44 |
-
if correct_output.lower() == 'yes':
|
45 |
-
feedback = st.text_input("Do you want to provide any feedback?")
|
46 |
-
save_to_csv(["Correct", feedback], 'output_ratings.csv')
|
47 |
-
else:
|
48 |
-
correct_code = st.text_area("Please enter the correct code:")
|
49 |
-
feedback = st.text_input("Any other feedback you want to provide:")
|
50 |
-
save_to_csv(["Incorrect", feedback, correct_code], 'output_ratings.csv')
|
51 |
-
|
52 |
# Streamlit app
|
53 |
def main():
|
54 |
st.title("Magicoder Assistant")
|
@@ -60,7 +52,13 @@ def main():
|
|
60 |
st.text(generated_response)
|
61 |
|
62 |
correct_output = st.radio("Is the generated output correct?", ("Yes", "No"))
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
if __name__ == "__main__":
|
66 |
main()
|
|
|
1 |
import streamlit as st
|
2 |
import torch
|
3 |
+
from transformers import pipeline
|
4 |
import csv
|
5 |
import re
|
6 |
import warnings
|
|
|
7 |
|
8 |
warnings.filterwarnings("ignore")
|
9 |
|
|
|
14 |
@@ Response
|
15 |
"""
|
16 |
|
17 |
+
# Load Magicoder model and apply dynamic quantization
|
18 |
+
generator = pipeline(
|
19 |
+
model="ise-uiuc/Magicoder-S-DS-6.7B",
|
20 |
+
task="text-generation",
|
21 |
+
)
|
22 |
+
quantized_generator = torch.quantization.quantize_dynamic(
|
23 |
+
generator.model,
|
24 |
{torch.nn.Linear},
|
25 |
dtype=torch.qint8
|
26 |
)
|
27 |
+
generator.model = quantized_generator
|
28 |
|
29 |
# Function to generate response
|
30 |
def generate_response(instruction):
|
|
|
41 |
writer = csv.writer(csvfile)
|
42 |
writer.writerow(data)
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
# Streamlit app
|
45 |
def main():
|
46 |
st.title("Magicoder Assistant")
|
|
|
52 |
st.text(generated_response)
|
53 |
|
54 |
correct_output = st.radio("Is the generated output correct?", ("Yes", "No"))
|
55 |
+
if correct_output.lower() == 'yes':
|
56 |
+
feedback = st.text_input("Do you want to provide any feedback?")
|
57 |
+
save_to_csv(["Correct", feedback], 'output_ratings.csv')
|
58 |
+
else:
|
59 |
+
correct_code = st.text_area("Please enter the correct code:")
|
60 |
+
feedback = st.text_input("Any other feedback you want to provide:")
|
61 |
+
save_to_csv(["Incorrect", feedback, correct_code], 'output_ratings.csv')
|
62 |
|
63 |
if __name__ == "__main__":
|
64 |
main()
|