Skip to content

Commit 242caa6

Browse files
authored
student-tutor sythetic conversation basic (with student personal and basic fluency) (#8)
1 parent 70b0f1c commit 242caa6

File tree

3 files changed

+28
-25
lines changed

3 files changed

+28
-25
lines changed

src/agents/student_agent/student_agent.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
try:
22
from ..llm_factory import OpenAILLMs
33
from .student_prompts import \
4-
base_student_prompt, curious_student_prompt, contradicting_student_prompt, reliant_student_prompt, confused_student_prompt, unrelated_student_prompt, \
4+
base_student_persona, curious_student_persona, contradicting_student_persona, reliant_student_persona, confused_student_persona, unrelated_student_persona, \
55
process_prompt
66
from ..utils.types import InvokeAgentResponseType
77
except ImportError:
88
from src.agents.llm_factory import OpenAILLMs
99
from src.agents.student_agent.student_prompts import \
10-
base_student_prompt, curious_student_prompt, contradicting_student_prompt, reliant_student_prompt, confused_student_prompt, unrelated_student_prompt, \
10+
base_student_persona, curious_student_persona, contradicting_student_persona, reliant_student_persona, confused_student_persona, unrelated_student_persona, \
1111
process_prompt
1212
from src.agents.utils.types import InvokeAgentResponseType
1313

@@ -42,20 +42,20 @@ def __init__(self, student_type: str):
4242
self.conversationalStyle = ""
4343
self.type = student_type
4444

45-
# Define Agent's specific Parameters
45+
# Define Agent's specific Personas
4646
self.role_prompt = process_prompt
4747
if self.type == "base":
48-
self.role_prompt += base_student_prompt
48+
self.role_prompt += base_student_persona
4949
elif self.type == "curious":
50-
self.role_prompt += curious_student_prompt
50+
self.role_prompt += curious_student_persona
5151
elif self.type == "contradicting":
52-
self.role_prompt += contradicting_student_prompt
52+
self.role_prompt += contradicting_student_persona
5353
elif self.type == "reliant":
54-
self.role_prompt += reliant_student_prompt
54+
self.role_prompt += reliant_student_persona
5555
elif self.type == "confused":
56-
self.role_prompt += confused_student_prompt
56+
self.role_prompt += confused_student_persona
5757
elif self.type == "unrelated":
58-
self.role_prompt += unrelated_student_prompt
58+
self.role_prompt += unrelated_student_persona
5959
else:
6060
raise Exception("Unknown Student Agent Type")
6161
# Define a new graph for the conversation & compile it
@@ -75,7 +75,8 @@ def call_model(self, state: State, config: RunnableConfig) -> str:
7575
# convert "my" to "your" in the question_response_details to preserve the student agent as the user
7676
question_response_details = question_response_details.replace("My", "Your")
7777
question_response_details = question_response_details.replace("my", "your")
78-
system_message += f"\n\n## Known Question Materials: {question_response_details} \n\n"
78+
question_response_details = question_response_details.replace("I am", "you are")
79+
system_message += f"\n\n## Known Learning Materials: {question_response_details} \n\n"
7980

8081
# Adding summary and conversational style to the system message
8182
summary = state.get("summary", "")

src/agents/student_agent/student_prompts.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55

66
# PROMPTS generated with the help of ChatGPT GPT-4o Nov 2024
77

8-
process_prompt = "Keep the flow of the conversation and respond to my latest message. If I do not provide an open response, then you can ask a follow-up question. Keep your response one sentence long. \n\n"
9-
10-
base_student_prompt = "You are a student who seeks help. Focus on asking about clarifications of the foundational concepts or seeking simple explanations."
11-
curious_student_prompt = "You are a curious and inquisitive student eager to explore and deeply understand any topic. You ask thoughtful and detailed questions to clarify concepts, uncover real-life applications, and explore their complexities. You actively seek knowledge, are unafraid to challenge assumptions, and confidently ask for clarification whenever needed. Your goal is to learn through curiosity and active engagement."
12-
contradicting_student_prompt = "You are a skeptical student who frequently questions my reasoning. You do not fully trust my explanations and are quick to identify and point out potential mistakes or flaws in my responses. You confidently challenge me directly and seek clarification whenever something seems unclear or incorrect."
13-
reliant_student_prompt = "You are a student who relies heavily on my help as your tutor. You fully trust my reasoning and frequently ask for assistance, even for the smallest problems. You are not afraid to ask questions or request clarification to ensure you understand everything thoroughly."
14-
confused_student_prompt = "You are a student who is confused about the topic and unsure how to proceed. You feel stuck and uncertain about both the material and the tutor's reasoning. You frequently ask questions and seek clarification, even when unsure of what to ask, to better understand the topic."
15-
unrelated_student_prompt = "You are a student who engages in casual, chit-chat conversations with me, your tutor. Instead of focusing on the material, you talk about unrelated topics, sharing thoughts, asking lighthearted questions, or discussing personal or general interests."
8+
process_prompt = "Maintain the flow of the conversation by responding directly to the latest message in one sentence. Stay in character as "
9+
10+
base_student_persona = "a student who seeks assistance. Ask questions from a first-person perspective, requesting clarification on how to solve the promblem from the known materials."
11+
curious_student_persona = "a curious and inquisitive student. Ask thoughtful, detailed questions from a first-person perspective to clarify concepts, explore real-life applications, and uncover complexities. Don’t hesitate to challenge assumptions and ask for clarification when needed."
12+
contradicting_student_persona = "a skeptical student. Ask questions from a first-person perspective, questioning my reasoning, identifying potential flaws, and challenging explanations. Request clarification whenever something seems unclear or incorrect."
13+
reliant_student_persona = "a student who relies heavily on your help. Ask questions from a first-person perspective, seeking help for even small problems, and requesting clarification or further assistance to ensure understanding."
14+
confused_student_persona = "a student who feels confused and uncertain about the topic. Ask questions from a first-person perspective, expressing uncertainty about the material and requesting clarification on both the topic and the tutor’s reasoning."
15+
unrelated_student_persona = "a student who engages in casual conversation. Ask lighthearted or unrelated questions from a first-person perspective, discussing personal interests or unrelated topics rather than focusing on the material."
16+
17+
# flow_prompt = "Refer to the previous message or topic discussed. Ask about the current topic, but there’s a 30% chance you’ll shift to a new topic. Ensure the change in topic makes sense and flows logically."

src/agents/utils/synthetic_conversation_generation.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,21 @@ def generate_synthetic_conversations(raw_text: str, num_turns: int, student_agen
7070
for i in range(0,num_turns):
7171
print(f"Turn {i+1} of {num_turns}")
7272
if len(conversation_history) == 0:
73-
message = "Ask a question."
73+
message = "Ask me a question regarding your thoughts on the learning materials that you are currently woking on."
7474
else:
7575
message = conversation_history[-1]["content"]
7676

7777
if i % 2 == 0:
7878
# Student starts
7979
student_response = invoke_student_agent(message, conversation_history[:-1], summary, student_agent_type, question_response_details_prompt, conversation_id)
8080
conversation_history.append({
81-
"type": "user",
81+
"role": "assistant",
8282
"content": student_response["output"]
8383
})
8484
else:
8585
tutor_response = invoke_tutor_agent(message, conversation_history[:-1], summary, conversational_style, question_response_details_prompt, conversation_id)
8686
conversation_history.append({
87-
"type": "assistant",
87+
"role": "assistant",
8888
"content": tutor_response["output"]
8989
})
9090

@@ -102,11 +102,11 @@ def generate_synthetic_conversations(raw_text: str, num_turns: int, student_agen
102102

103103

104104
if __name__ == "__main__":
105-
# Define Conversation Parameters
106-
num_turns = 10
107-
tutor_agent_types = ["informational", "socratic", "google_learnlm"] # Can be "informational", "socratic", "google_learnlm"
108-
student_agent_types = ["curious", "contradicting", "reliant", "confused"]
105+
num_turns = 6
106+
# Can be "informational", "socratic", "google_learnlm"
107+
tutor_agent_types = ["socratic"]
109108
# Can be "base", "curious", "contradicting", "reliant", "confused", "unrelated"
109+
student_agent_types = ["base", "curious", "contradicting", "reliant", "confused", "unrelated"]
110110

111111
# Read all question files
112112
questions = []

0 commit comments

Comments
 (0)