Spaces:
Sleeping
Sleeping
Update prompt_templates.py
Browse files- prompt_templates.py +48 -164
prompt_templates.py
CHANGED
@@ -1,199 +1,83 @@
|
|
1 |
# prompt_templates.py
|
2 |
-
from langchain.prompts import ChatPromptTemplate
|
3 |
|
4 |
class PromptTemplates:
|
5 |
"""
|
6 |
-
Encapsulates various prompt templates
|
7 |
-
|
|
|
8 |
"""
|
9 |
|
10 |
@staticmethod
|
11 |
def get_quiz_solving_prompt():
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
{context}
|
19 |
-
|
20 |
-
User's question:
|
21 |
-
{question}
|
22 |
-
|
23 |
-
Your response:
|
24 |
-
'''
|
25 |
-
return ChatPromptTemplate.from_messages([
|
26 |
-
("system", quiz_solving_prompt),
|
27 |
-
("human", "{question}")
|
28 |
-
])
|
29 |
|
30 |
@staticmethod
|
31 |
def get_assignment_solving_prompt():
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
{context}
|
38 |
-
|
39 |
-
Assignment Details:
|
40 |
-
{question}
|
41 |
-
|
42 |
-
Your response:
|
43 |
-
'''
|
44 |
-
return ChatPromptTemplate.from_messages([
|
45 |
-
("system", assignment_solving_prompt),
|
46 |
-
("human", "{question}")
|
47 |
-
])
|
48 |
|
49 |
@staticmethod
|
50 |
def get_paper_solving_prompt():
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
{context}
|
57 |
-
|
58 |
-
Paper Information:
|
59 |
-
{question}
|
60 |
-
|
61 |
-
Your response:
|
62 |
-
'''
|
63 |
-
return ChatPromptTemplate.from_messages([
|
64 |
-
("system", paper_solving_prompt),
|
65 |
-
("human", "{question}")
|
66 |
-
])
|
67 |
|
68 |
@staticmethod
|
69 |
def get_quiz_creation_prompt():
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
Retrieved context:
|
75 |
-
{context}
|
76 |
-
|
77 |
-
Quiz Details:
|
78 |
-
Topic: {question}
|
79 |
-
|
80 |
-
Your quiz:
|
81 |
-
'''
|
82 |
-
return ChatPromptTemplate.from_messages([
|
83 |
-
("system", quiz_creation_prompt),
|
84 |
-
("human", "{question}")
|
85 |
-
])
|
86 |
|
87 |
@staticmethod
|
88 |
def get_assignment_creation_prompt():
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
Retrieved context:
|
94 |
-
{context}
|
95 |
-
|
96 |
-
Assignment Details:
|
97 |
-
Topic: {question}
|
98 |
-
|
99 |
-
Your assignment:
|
100 |
-
'''
|
101 |
-
return ChatPromptTemplate.from_messages([
|
102 |
-
("system", assignment_creation_prompt),
|
103 |
-
("human", "{question}")
|
104 |
-
])
|
105 |
|
106 |
@staticmethod
|
107 |
def get_paper_creation_prompt():
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
Retrieved context:
|
113 |
-
{context}
|
114 |
-
|
115 |
-
Paper Details:
|
116 |
-
Subject/Topic: {question}
|
117 |
-
|
118 |
-
Your paper:
|
119 |
-
'''
|
120 |
-
return ChatPromptTemplate.from_messages([
|
121 |
-
("system", paper_creation_prompt),
|
122 |
-
("human", "{question}")
|
123 |
-
])
|
124 |
|
125 |
@staticmethod
|
126 |
def get_university_chatbot_prompt():
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
{context}
|
133 |
-
|
134 |
-
User's question:
|
135 |
-
{question}
|
136 |
-
|
137 |
-
Your response:
|
138 |
-
'''
|
139 |
-
return ChatPromptTemplate.from_messages([
|
140 |
-
("system", university_prompt),
|
141 |
-
("human", "{question}")
|
142 |
-
])
|
143 |
|
144 |
@staticmethod
|
145 |
def get_check_quiz_prompt():
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
Student Answer:
|
151 |
-
{student_answer}
|
152 |
-
|
153 |
-
Answer Key:
|
154 |
-
{answer_key}
|
155 |
-
|
156 |
-
Your evaluation:
|
157 |
-
'''
|
158 |
-
return ChatPromptTemplate.from_messages([
|
159 |
-
("system", check_quiz_prompt),
|
160 |
-
("human", "Provide your evaluation.")
|
161 |
-
])
|
162 |
|
163 |
@staticmethod
|
164 |
def get_check_assignment_prompt():
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
Student Answer:
|
170 |
-
{student_answer}
|
171 |
-
|
172 |
-
Answer Key:
|
173 |
-
{answer_key}
|
174 |
-
|
175 |
-
Your evaluation:
|
176 |
-
'''
|
177 |
-
return ChatPromptTemplate.from_messages([
|
178 |
-
("system", check_assignment_prompt),
|
179 |
-
("human", "Provide your evaluation.")
|
180 |
-
])
|
181 |
|
182 |
@staticmethod
|
183 |
def get_check_paper_prompt():
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
Student Answer:
|
189 |
-
{student_answer}
|
190 |
-
|
191 |
-
Answer Key:
|
192 |
-
{answer_key}
|
193 |
-
|
194 |
-
Your evaluation:
|
195 |
-
'''
|
196 |
-
return ChatPromptTemplate.from_messages([
|
197 |
-
("system", check_paper_prompt),
|
198 |
-
("human", "Provide your evaluation.")
|
199 |
-
])
|
|
|
1 |
# prompt_templates.py
|
|
|
2 |
|
3 |
class PromptTemplates:
|
4 |
"""
|
5 |
+
Encapsulates various prompt templates as plain strings.
|
6 |
+
Each template uses placeholders for {context}, {chat_history}, and {question}
|
7 |
+
(or {student_answer} and {answer_key} for checking prompts).
|
8 |
"""
|
9 |
|
10 |
@staticmethod
|
11 |
def get_quiz_solving_prompt():
|
12 |
+
return (
|
13 |
+
"You are an assistant specialized in solving quizzes. Your goal is to provide accurate, concise, "
|
14 |
+
"and contextually relevant answers. Use the following retrieved context to answer the user's question. "
|
15 |
+
"If the context lacks sufficient information, respond with \"I don't know.\" Do not fabricate answers. "
|
16 |
+
"Retrieved context: {context} Chat History: {chat_history} User's question: {question} Your response:"
|
17 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
@staticmethod
|
20 |
def get_assignment_solving_prompt():
|
21 |
+
return (
|
22 |
+
"You are an expert assistant specializing in solving academic assignments with clarity and precision. "
|
23 |
+
"Provide step-by-step solutions and detailed explanations. Retrieved context: {context} Chat History: {chat_history} "
|
24 |
+
"Assignment Details: {question} Your response:"
|
25 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
@staticmethod
|
28 |
def get_paper_solving_prompt():
|
29 |
+
return (
|
30 |
+
"You are an expert assistant specialized in solving academic papers with precision. Provide well-structured "
|
31 |
+
"answers to the questions in the paper. Retrieved context: {context} Chat History: {chat_history} "
|
32 |
+
"Paper Information: {question} Your response:"
|
33 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
@staticmethod
|
36 |
def get_quiz_creation_prompt():
|
37 |
+
return (
|
38 |
+
"You are an expert assistant specializing in creating engaging and educational quizzes. Design a quiz based on the "
|
39 |
+
"specified topic. Retrieved context: {context} Chat History: {chat_history} Quiz Details (Topic): {question} Your quiz:"
|
40 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
@staticmethod
|
43 |
def get_assignment_creation_prompt():
|
44 |
+
return (
|
45 |
+
"You are an expert assistant specializing in designing assignments. Create a comprehensive assignment based on the provided topic. "
|
46 |
+
"Retrieved context: {context} Chat History: {chat_history} Assignment Details (Topic): {question} Your assignment:"
|
47 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
@staticmethod
|
50 |
def get_paper_creation_prompt():
|
51 |
+
return (
|
52 |
+
"You are an expert assistant specializing in creating academic papers. Design a complete paper based on the specified topic and format. "
|
53 |
+
"Retrieved context: {context} Chat History: {chat_history} Paper Details (Subject/Topic): {question} Your paper:"
|
54 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
@staticmethod
|
57 |
def get_university_chatbot_prompt():
|
58 |
+
return (
|
59 |
+
"You are a university chatbot. Your role is to answer questions related to admissions, programs, campus life, and academic services. "
|
60 |
+
"Your responses should be accurate, friendly, and informative. Retrieved context: {context} Chat History: {chat_history} "
|
61 |
+
"User's question: {question} Your response:"
|
62 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
@staticmethod
|
65 |
def get_check_quiz_prompt():
|
66 |
+
return (
|
67 |
+
"You are an evaluator bot specialized in checking quiz answers. Compare the student answer with the original answer key and "
|
68 |
+
"provide constructive feedback. Student Answer: {student_answer} Answer Key: {answer_key} Your evaluation:"
|
69 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
@staticmethod
|
72 |
def get_check_assignment_prompt():
|
73 |
+
return (
|
74 |
+
"You are an evaluator bot specialized in checking assignment answers. Compare the student answer with the original answer key and "
|
75 |
+
"provide detailed feedback with explanations. Student Answer: {student_answer} Answer Key: {answer_key} Your evaluation:"
|
76 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
@staticmethod
|
79 |
def get_check_paper_prompt():
|
80 |
+
return (
|
81 |
+
"You are an evaluator bot specialized in checking academic paper answers. Compare the student answer with the original answer key and "
|
82 |
+
"offer detailed feedback, highlighting strengths and areas for improvement. Student Answer: {student_answer} Answer Key: {answer_key} Your evaluation:"
|
83 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|