| from history import History | |
| from roles import Roles | |
| from utils import call_chatgpt_api | |
| TEACHER_BASE = """A tutor and a student work together to solve the following math word problem. | |
| Math problem: {problem} | |
| The correct solution is as follows: | |
| {ground_truth} | |
| The following is a conversation with a teacher. The teacher is polite, helpful, professional, on topic, and factually correct. | |
| """ | |
| class ChatGPTTeacher(object): | |
| def __init__(self): | |
| self.persona = Roles.TEACHER | |
| self.name = "GPT Robot" | |
| def reset(self): | |
| pass | |
| def response(self, history: History, question: str, ground_truth_solution: str): | |
| prompt = TEACHER_BASE.format(problem=question, ground_truth=ground_truth_solution) | |
| messages = history.to_gpt_messages({Roles.TEACHER: "assistant", Roles.STUDENT: "user"}) | |
| response = call_chatgpt_api(messages, prompt, stop=["Student:", "student:"]) | |
| generated_response = response["choices"][0]["message"]["content"].strip() | |
| return generated_response | |
Xet Storage Details
- Size:
- 1.03 kB
- Xet hash:
- 1d018d405ebf91f50ee4846c5dd220aa69054430dcc8f0935e9765b1cffe072c
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.