diff --git a/app/domain/status/text_exercise_chat_status_update_dto.py b/app/domain/status/text_exercise_chat_status_update_dto.py index dd063ff7..a825e92f 100644 --- a/app/domain/status/text_exercise_chat_status_update_dto.py +++ b/app/domain/status/text_exercise_chat_status_update_dto.py @@ -2,4 +2,4 @@ class TextExerciseChatStatusUpdateDTO(StatusUpdateDTO): - result: str = [] + result: str diff --git a/app/pipeline/prompts/text_exercise_chat_prompts.py b/app/pipeline/prompts/text_exercise_chat_prompts.py index 229e97eb..477e4c4e 100644 --- a/app/pipeline/prompts/text_exercise_chat_prompts.py +++ b/app/pipeline/prompts/text_exercise_chat_prompts.py @@ -1,3 +1,6 @@ +import textwrap + + def fmt_extract_sentiments_prompt( exercise_name: str, course_name: str, @@ -6,7 +9,8 @@ def fmt_extract_sentiments_prompt( previous_message: str, user_input: str, ) -> str: - return """ + return textwrap.dedent( + """ You extract and categorize sentiments of the user's input into three categories describing relevance and appropriateness in the context of a particular writing exercise. @@ -44,7 +48,8 @@ def fmt_extract_sentiments_prompt( Given this context, what are the sentiments of the user's input? {user_input} - """.format( + """ + ).format( exercise_name=exercise_name, course_name=course_name, course_description=course_description, @@ -60,12 +65,14 @@ def fmt_sentiment_analysis_prompt(respond_to: list[str], ignore: list[str]) -> s prompt += "Respond helpfully and positively to these sentiments in the user's input:\n" prompt += "\n".join(respond_to) + "\n\n" if ignore: - prompt += """ + prompt += textwrap.dedent( + """ The following sentiments in the user's input are not relevant or appropriate to the writing exercise and should be ignored. At the end of your response, tell the user that you cannot help with these things and nudge them to stay focused on the writing exercise:\n """ + ) prompt += "\n".join(ignore) return prompt @@ -80,7 +87,8 @@ def fmt_system_prompt( current_date: str, current_submission: str, ) -> str: - return """ + return textwrap.dedent( + """ You are a writing tutor. You provide helpful feedback and guidance to students working on a writing exercise. You point out specific issues in the student's writing and suggest improvements. You never provide answers or write the student's work for them. @@ -99,7 +107,8 @@ def fmt_system_prompt( (If they have written anything else since submitting, it is not shown here.) {current_submission} - """.format( + """ + ).format( exercise_name=exercise_name, course_name=course_name, course_description=course_description, diff --git a/app/pipeline/text_exercise_chat_pipeline.py b/app/pipeline/text_exercise_chat_pipeline.py index 9549f2eb..95e1ea1a 100644 --- a/app/pipeline/text_exercise_chat_pipeline.py +++ b/app/pipeline/text_exercise_chat_pipeline.py @@ -1,6 +1,6 @@ import logging from datetime import datetime -from typing import Optional +from typing import Optional, List, Tuple from app.llm import CapabilityRequestHandler, RequirementList, CompletionArguments from app.pipeline import Pipeline @@ -51,7 +51,7 @@ def __call__( def categorize_sentiments_by_relevance( self, dto: TextExerciseChatPipelineExecutionDTO - ) -> (list[str], list[str], list[str]): + ) -> Tuple[List[str], List[str], List[str]]: """ Extracts the sentiments from the user's input and categorizes them as "Ok", "Neutral", or "Bad" in terms of relevance to the text exercise at hand. @@ -91,7 +91,7 @@ def categorize_sentiments_by_relevance( def respond( self, dto: TextExerciseChatPipelineExecutionDTO, - sentiments: (list[str], list[str], list[str]), + sentiments: Tuple[List[str], List[str], List[str]], ) -> str: """ Actually respond to the user's input.