Skip to content

Commit

Permalink
Apply coderabbit suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelOwenDyer committed Oct 11, 2024
1 parent 28b0282 commit 6ecedba
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/domain/status/text_exercise_chat_status_update_dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class TextExerciseChatStatusUpdateDTO(StatusUpdateDTO):
result: str = []
result: str
19 changes: 14 additions & 5 deletions app/pipeline/prompts/text_exercise_chat_prompts.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import textwrap


def fmt_extract_sentiments_prompt(
exercise_name: str,
course_name: str,
Expand All @@ -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.
Expand Down Expand Up @@ -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,
Expand All @@ -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

Expand All @@ -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.
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions app/pipeline/text_exercise_chat_pipeline.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 6ecedba

Please sign in to comment.