Skip to content

Commit 3d5950b

Browse files
committed
fix: summary prompting
1 parent 349d884 commit 3d5950b

File tree

7 files changed

+22
-14
lines changed

7 files changed

+22
-14
lines changed

src/agents/base_agent/base_agent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ def summarize_conversation(self, state: State, config: RunnableConfig) -> dict:
120120
conversationalStyle_message = self.conversation_preference_prompt
121121

122122
# STEP 1: Summarize the conversation
123-
messages = [SystemMessage(content=summary_message)] + state["messages"][:-1]
123+
messages = state["messages"][:-1] + [HumanMessage(content=summary_message)]
124124
valid_messages = self.check_for_valid_messages(messages)
125125
summary_response = self.summarisation_llm.invoke(valid_messages)
126126

127127
# STEP 2: Analyze the conversational style
128-
messages = [SystemMessage(content=conversationalStyle_message)] + state["messages"][:-1]
128+
messages = state["messages"][:-1] + [HumanMessage(content=conversationalStyle_message)]
129129
valid_messages = self.check_for_valid_messages(messages)
130130
conversationalStyle_response = self.summarisation_llm.invoke(valid_messages)
131131

src/agents/base_agent/base_prompts.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@
6868
Structured: Organize the summary into sections such as 'Topics Discussed' and 'Top 3 Key Detailed Ideas'.
6969
Neutral and Accurate: Avoid adding interpretations or opinions; focus only on the content shared.
7070
When summarizing: If the conversation is technical, highlight significant concepts, solutions, and terminology. If context involves problem-solving, detail the problem and the steps or solutions provided. If the user asks for creative input, briefly describe the ideas presented.
71-
Last messages: Include the most recent 4 messages to provide context for the summary.
71+
Last messages: Include the most recent 5 messages to provide context for the summary.
7272
7373
Provide the summary in a bulleted format for clarity. Avoid redundant details while preserving the core intent of the discussion."""
7474

75-
summary_prompt = f"""Summarize the conversation between a student and a tutor. Your summary should highlight the major topics discussed during the session, followed by a detailed recollection of the last five significant points or ideas. Ensure the summary flows smoothly to maintain the continuity of the discussion."""
75+
summary_prompt = f"""Summarize the conversation between a student and a tutor. Your summary should highlight the major topics discussed during the session, followed by a detailed recollection of the last five significant points or ideas. Ensure the summary flows smoothly to maintain the continuity of the discussion.
76+
77+
{summary_guidelines}"""
7678

7779
update_summary_prompt = f"""Update the summary by taking into account the new messages above.
7880

src/agents/google_learnLM_agent/google_learnLM_agent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ def summarize_conversation(self, state: State, config: RunnableConfig) -> dict:
124124
conversationalStyle_message = self.conversation_preference_prompt
125125

126126
# STEP 1: Summarize the conversation
127-
messages = [SystemMessage(content=summary_message)] + state["messages"][:-1]
127+
messages = state["messages"][:-1] + [HumanMessage(content=summary_message)]
128128
valid_messages = self.check_for_valid_messages(messages)
129129
summary_response = self.summarisation_llm.invoke(valid_messages)
130130

131131
# STEP 2: Analyze the conversational style
132-
messages = [SystemMessage(content=conversationalStyle_message)] + state["messages"][:-1]
132+
messages = state["messages"][:-1] + [HumanMessage(content=conversationalStyle_message)]
133133
valid_messages = self.check_for_valid_messages(messages)
134134
conversationalStyle_response = self.summarisation_llm.invoke(valid_messages)
135135

src/agents/google_learnLM_agent/google_learnLM_prompts.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@
6868
Structured: Organize the summary into sections such as 'Topics Discussed' and 'Top 3 Key Detailed Ideas'.
6969
Neutral and Accurate: Avoid adding interpretations or opinions; focus only on the content shared.
7070
When summarizing: If the conversation is technical, highlight significant concepts, solutions, and terminology. If context involves problem-solving, detail the problem and the steps or solutions provided. If the user asks for creative input, briefly describe the ideas presented.
71-
Last messages: Include the most recent 4 messages to provide context for the summary.
71+
Last messages: Include the most recent 5 messages to provide context for the summary.
7272
7373
Provide the summary in a bulleted format for clarity. Avoid redundant details while preserving the core intent of the discussion."""
7474

75-
summary_prompt = f"""Summarize the conversation between a student and a tutor. Your summary should highlight the major topics discussed during the session, followed by a detailed recollection of the last five significant points or ideas. Ensure the summary flows smoothly to maintain the continuity of the discussion."""
75+
summary_prompt = f"""Summarize the conversation between a student and a tutor. Your summary should highlight the major topics discussed during the session, followed by a detailed recollection of the last five significant points or ideas. Ensure the summary flows smoothly to maintain the continuity of the discussion.
76+
77+
{summary_guidelines}"""
7678

7779
update_summary_prompt = f"""Update the summary by taking into account the new messages above.
7880

src/agents/informational_agent/informational_agent.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ def summarize_conversation(self, state: State, config: RunnableConfig) -> dict:
122122
conversationalStyle_message = self.conversation_preference_prompt
123123

124124
# STEP 1: Summarize the conversation
125-
messages = [SystemMessage(content=summary_message)] + state["messages"][:-1]
125+
messages = state["messages"][:-1] + [HumanMessage(content=summary_message)]
126126
valid_messages = self.check_for_valid_messages(messages)
127127
print(f"valid_messages SUMMARY:: {valid_messages}")
128128
summary_response = self.summarisation_llm.invoke(valid_messages)
129129

130130
# STEP 2: Analyze the conversational style
131-
messages = [SystemMessage(content=conversationalStyle_message)] + state["messages"][:-1]
131+
messages = state["messages"][:-1] + [HumanMessage(content=conversationalStyle_message)]
132132
valid_messages = self.check_for_valid_messages(messages)
133133
conversationalStyle_response = self.summarisation_llm.invoke(valid_messages)
134134

@@ -194,6 +194,8 @@ def invoke_informational_agent(query: str, conversation_history: list, summary:
194194
summary = agent.get_summary()
195195
conversationalStyle = agent.get_conversational_style()
196196

197+
print(f'SUMMARY: {summary}')
198+
197199
return {
198200
"input": query,
199201
"output": pretty_printed_response,

src/agents/socratic_agent/socratic_agent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ def summarize_conversation(self, state: State, config: RunnableConfig) -> dict:
122122
# conversationalStyle_message = self.conversation_preference_prompt
123123

124124
# STEP 1: Summarize the conversation
125-
messages = [SystemMessage(content=summary_message)] + state["messages"][:-1]
125+
messages = state["messages"][:-1] + [HumanMessage(content=summary_message)]
126126
valid_messages = self.check_for_valid_messages(messages)
127127
summary_response = self.summarisation_llm.invoke(valid_messages)
128128

129129
# STEP 2: Analyze the conversational style
130-
# messages = [SystemMessage(content=conversationalStyle_message)] + state["messages"][:-1]
130+
# messages = state["messages"][:-1] + [HumanMessage(content=conversationalStyle_message)]
131131
# valid_messages = self.check_for_valid_messages(messages)
132132
# conversationalStyle_response = self.summarisation_llm.invoke(valid_messages)
133133

src/agents/socratic_agent/socratic_prompts.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,13 @@
9292
Structured: Organize the summary into sections such as 'Topics Discussed' and 'Top 3 Key Detailed Ideas'.
9393
Neutral and Accurate: Avoid adding interpretations or opinions; focus only on the content shared.
9494
When summarizing: If the conversation is technical, highlight significant concepts, solutions, and terminology. If context involves problem-solving, detail the problem and the steps or solutions provided. If the user asks for creative input, briefly describe the ideas presented.
95-
Last messages: Include the most recent 4 messages to provide context for the summary.
95+
Last messages: Include the most recent 5 messages to provide context for the summary.
9696
9797
Provide the summary in a bulleted format for clarity. Avoid redundant details while preserving the core intent of the discussion."""
9898

99-
summary_prompt = f"""Summarize the conversation between a student and a tutor. Your summary should highlight the major topics discussed during the session, followed by a detailed recollection of the last five significant points or ideas. Ensure the summary flows smoothly to maintain the continuity of the discussion."""
99+
summary_prompt = f"""Summarize the conversation between a student and a tutor. Your summary should highlight the major topics discussed during the session, followed by a detailed recollection of the last five significant points or ideas. Ensure the summary flows smoothly to maintain the continuity of the discussion.
100+
101+
{summary_guidelines}"""
100102

101103
update_summary_prompt = f"""Update the summary by taking into account the new messages above.
102104

0 commit comments

Comments
 (0)