Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -13,7 +13,7 @@ client = OpenAI(api_key=OPENAI_API_KEY) #INSERT KEY INSODE HE QUOTES IN THE BRAC
|
|
13 |
from docx import Document
|
14 |
|
15 |
|
16 |
-
# Function to parse the feedback into
|
17 |
def parse_feedback(feedback):
|
18 |
# You can customize this based on how GPT provides the feedback
|
19 |
# Here, I assume feedback includes specific scoring lines like 'Content Relevance: X/25'
|
@@ -41,10 +41,10 @@ def parse_feedback(feedback):
|
|
41 |
return scores
|
42 |
|
43 |
# Function to grade the essay using GPT-4
|
44 |
-
def grade_essay(essay, guided_data,
|
45 |
# Sample prompt for grading using GPT-4
|
46 |
prompt = f"""
|
47 |
-
You are an consultant that grades marketing and business proposal based on a provided
|
48 |
|
49 |
|
50 |
Đánh giá dựa trên những đầu mục lớn và từng đầu mục nhỏ
|
@@ -54,8 +54,8 @@ def grade_essay(essay, guided_data, rubric):
|
|
54 |
Đề xuất chiến lược tiếp cận: 1. Mức độ liên kết chặt chẽ giữa chiến lược mới với các phân tích trước đó 2. Mức độ phù hợp của chiến lược đối với Brand và đối tượng mục tiêu 3. Mức độ đan xen yếu tố Brand role vào chiến lược tiếp cận
|
55 |
"Ý tưởng lớn (Big Idea): 1. Giải quyết được vấn đề của thương hiệu, thể hiện được vai trò thương hiệu 2.Phù hợp với insight của đối tượng mục tiêu 3. Ý tưởng đột phá, sáng tạo, có tính khả thi
|
56 |
|
57 |
-
Here is the
|
58 |
-
{
|
59 |
|
60 |
Here are examples of previously graded essays and their scores: {guided_data}
|
61 |
|
@@ -85,8 +85,8 @@ def export_to_csv(data):
|
|
85 |
def main():
|
86 |
st.title("Marwuy Proposal feedback")
|
87 |
|
88 |
-
# Predefined
|
89 |
-
|
90 |
INSTRUCTIONS FOR GRADING
|
91 |
1. Research: 25
|
92 |
2. Xác định rõ vấn đề, mục tiêu và vai trò nhãn hàng trong chiến dịch: 20
|
@@ -115,7 +115,7 @@ def main():
|
|
115 |
# File uploader for corresponding scores (DOCX)
|
116 |
# scores_file = st.file_uploader("Upload the json file containing corresponding scores", type=["xlsx"])
|
117 |
# Open and read the JSON file with utf-8 encoding
|
118 |
-
with open('
|
119 |
scores_file = json.load(file)
|
120 |
|
121 |
# File uploader for new essays to be graded (DOCX)
|
@@ -126,10 +126,10 @@ def main():
|
|
126 |
if st.button("Grade Essays"):
|
127 |
if example_files and scores_file and new_file:
|
128 |
|
129 |
-
# Grading the new essay using the provided
|
130 |
-
result = grade_essay(new_file, example_files,
|
131 |
|
132 |
-
# Parse feedback into
|
133 |
parsed_scores = parse_feedback(result)
|
134 |
|
135 |
# Store results in session state
|
|
|
13 |
from docx import Document
|
14 |
|
15 |
|
16 |
+
# Function to parse the feedback into barem components
|
17 |
def parse_feedback(feedback):
|
18 |
# You can customize this based on how GPT provides the feedback
|
19 |
# Here, I assume feedback includes specific scoring lines like 'Content Relevance: X/25'
|
|
|
41 |
return scores
|
42 |
|
43 |
# Function to grade the essay using GPT-4
|
44 |
+
def grade_essay(essay, guided_data, barem):
|
45 |
# Sample prompt for grading using GPT-4
|
46 |
prompt = f"""
|
47 |
+
You are an consultant that grades marketing and business proposal based on a provided barem, ensuring an unbiased evaluation while considering clarity, originality, organization, and depth of analysis. Advise in Vietnamse, only use English for buzzwords.
|
48 |
|
49 |
|
50 |
Đánh giá dựa trên những đầu mục lớn và từng đầu mục nhỏ
|
|
|
54 |
Đề xuất chiến lược tiếp cận: 1. Mức độ liên kết chặt chẽ giữa chiến lược mới với các phân tích trước đó 2. Mức độ phù hợp của chiến lược đối với Brand và đối tượng mục tiêu 3. Mức độ đan xen yếu tố Brand role vào chiến lược tiếp cận
|
55 |
"Ý tưởng lớn (Big Idea): 1. Giải quyết được vấn đề của thương hiệu, thể hiện được vai trò thương hiệu 2.Phù hợp với insight của đối tượng mục tiêu 3. Ý tưởng đột phá, sáng tạo, có tính khả thi
|
56 |
|
57 |
+
Here is the barem for grading:
|
58 |
+
{barem}
|
59 |
|
60 |
Here are examples of previously graded essays and their scores: {guided_data}
|
61 |
|
|
|
85 |
def main():
|
86 |
st.title("Marwuy Proposal feedback")
|
87 |
|
88 |
+
# Predefined barem for grading
|
89 |
+
barem = """
|
90 |
INSTRUCTIONS FOR GRADING
|
91 |
1. Research: 25
|
92 |
2. Xác định rõ vấn đề, mục tiêu và vai trò nhãn hàng trong chiến dịch: 20
|
|
|
115 |
# File uploader for corresponding scores (DOCX)
|
116 |
# scores_file = st.file_uploader("Upload the json file containing corresponding scores", type=["xlsx"])
|
117 |
# Open and read the JSON file with utf-8 encoding
|
118 |
+
with open('barem.json', 'r', encoding='utf-8') as file:
|
119 |
scores_file = json.load(file)
|
120 |
|
121 |
# File uploader for new essays to be graded (DOCX)
|
|
|
126 |
if st.button("Grade Essays"):
|
127 |
if example_files and scores_file and new_file:
|
128 |
|
129 |
+
# Grading the new essay using the provided barem and example graded essays
|
130 |
+
result = grade_essay(new_file, example_files, barem)
|
131 |
|
132 |
+
# Parse feedback into barem components
|
133 |
parsed_scores = parse_feedback(result)
|
134 |
|
135 |
# Store results in session state
|