Spaces:
Runtime error
Runtime error
Download src/chains/general.py from Logisx/EssayEvaluation: direct link, hf CLI and curl.
- Browser
- Download file 3.68 kB
-
https://huggingface.co/spaces/Logisx/EssayEvaluation/resolve/main/src/chains/general.py
- Command line
-
hf download hf://spaces/Logisx/EssayEvaluation/src/chains/general.py
-
curl -L -o general.py https://huggingface.co/spaces/Logisx/EssayEvaluation/resolve/main/src/chains/general.py
3.68 kB
| from .chain_creation import Chain | |
| class General_Chain(Chain): | |
| """ | |
| A class representing the General Chain for essay evaluation. | |
| This chain is responsible for evaluating an essay text based on specific criteria and providing detailed feedback. | |
| Attributes: | |
| template (str): The template for the evaluation instructions, response structure, essay topic, and essay text. | |
| Methods: | |
| __init__(): Initializes the General_Chain object. | |
| get_general_template(): Returns the template for the evaluation instructions, response structure, essay topic, and essay text. | |
| invoke(essay_topic, essay_text): Invokes the General_Chain and returns the evaluation result. | |
| """ | |
| def __init__(self): | |
| """ | |
| Initializes the General_Chain object. | |
| It sets the template attribute by calling the get_general_template() method and passes it to the parent class's __init__() method. | |
| """ | |
| self.template = self.get_general_template() | |
| super().__init__(self.template) | |
| def get_general_template(self): | |
| """ | |
| Returns the template for the evaluation instructions, response structure, essay topic, and essay text. | |
| Returns: | |
| str: The template string. | |
| """ | |
| GENERAL_TEMPLATE = """ | |
| You are a professional essay evaluator. | |
| Your task is to evaluate an essay text that I provided below. Ensure the essay meets the basic requirements in structure, length, coherence, and language proficiency. Then, provide detailed feedback on the essay. | |
| The essay topic is optionally available below. The feedback should not be influenced by the availability of the topic. Use the topic only as a context for evaluation. | |
| More detailed evaluation instructions and the essay text are provided below: | |
| ### EVALUATION INSTRUCTIONS: | |
| 1. Check if the essay conforms to the standard essay format, including introduction, body paragraphs, and conclusion. | |
| Ensure the essay is of appropriate length (minimum 50 words). | |
| Evaluate whether the essay addresses the given topic comprehensively and logically. | |
| 2. Provide specific feedback, highlighting strengths and areas for improvement. | |
| Offer advice on how the essay can be enhanced to achieve a higher score in each category. | |
| Suggest alternative vocabulary, sentence structures, or argumentative strategies where applicable. | |
| 3. Strictly follow the response structure below, do not say something after you give the scores and feedback. If you have nothing to say, leave it blank. If the text is completely not related to an essay (e.g it is just one sentence) you may not follow the structure and point out the issue. | |
| ### RESPONSE STRUCTURE | |
| Use only the following answer structure and do not include any personal opinions or biases in the evaluation: | |
| " | |
| Feedback Summary: [Provide a brief summary of the feedback] | |
| Detailed Feedback: [Provide detailed feedback here] | |
| " | |
| ### ESSAY TOPIC (OPTIONAL): | |
| {essay_topic} | |
| ### ESSAY TEXT: | |
| {essay_text} | |
| """ | |
| return GENERAL_TEMPLATE | |
| def invoke(self, essay_topic, essay_text): | |
| """ | |
| Invokes the General_Chain and returns the evaluation result. | |
| Args: | |
| essay_topic (str): The topic of the essay. | |
| essay_text (str): The text of the essay. | |
| Returns: | |
| str: The evaluation result. | |
| """ | |
| return super().invoke(essay_topic, essay_text) |