From 36be056ac102eedee36e34b07fec7554652de13f Mon Sep 17 00:00:00 2001 From: neagualexa Date: Mon, 9 Dec 2024 17:20:39 +0000 Subject: [PATCH 1/3] update prompts to cover general questions on topic --- src/agents/no_memory_agent.py | 2 +- src/agents/prompts/sum_conv_pref.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/agents/no_memory_agent.py b/src/agents/no_memory_agent.py index 2acaa8a..341e141 100644 --- a/src/agents/no_memory_agent.py +++ b/src/agents/no_memory_agent.py @@ -47,7 +47,7 @@ def call_model(self, state: State, config: RunnableConfig) -> str: # Adding external student progress and question context details from data queries question_response_details = config["configurable"].get("question_response_details", "") if question_response_details: - system_message += f"## Known Question Materials: {question_response_details} \n\n" + system_message += f"{question_response_details} \n\n" # Adding summary and conversational style to the system message summary = state.get("summary", "") diff --git a/src/agents/prompts/sum_conv_pref.py b/src/agents/prompts/sum_conv_pref.py index 034bd9b..7525465 100644 --- a/src/agents/prompts/sum_conv_pref.py +++ b/src/agents/prompts/sum_conv_pref.py @@ -4,21 +4,21 @@ # PROMPTS generated with the help of ChatGPT GPT-4o Nov 2024 -role_prompt = "You are an excelent tutor that aims to provide clear and concise explanations to the student. Your task is to answer the student's questions and provide guidance on the topic discussed. Ensure your responses are accurate, informative, and tailored to the student's level of understanding and conversational preferences. If the student is struggling or is frustrated refer to their progress so far and time spent on the question vs expected guidance. If the student asks about a topic unrelated to the 'Known Question Materials' then say 'I'm not familiar with that topic, but I can help you with the {topic}. You do not need to end your messages with a concluding statement." +role_prompt = "You are an excelent tutor that aims to provide clear and concise explanations to the student. Your task is to answer the student's questions and provide guidance on the topic discussed. Ensure your responses are accurate, informative, and tailored to the student's level of understanding and conversational preferences. If the student is struggling or is frustrated refer to their progress so far and time spent on the question vs expected guidance. If the student asks about a topic unrelated to the known question or its parts, then say 'Sorry, I'm not familiar with that topic, but I can help you with the {topic}. You do not need to end your messages with a concluding statement.\n\n" # Keep your responses open for further questions and encourage the student's curiosity. # Let the student know that your reasoning might be wrong and the student should not trust your reasoning fully. pref_guidelines = """**Guidelines:** - Use concise, objective language. -- Note the student’s primary reasoning style, e.g., hands-on, conceptual, detail-oriented, etc. -- Note the student's goals, such as understanding foundational concepts, passing an exam, getting top marks, code implementation, hands-on practice, etc. +- Note the student's educational goals, such as understanding foundational concepts, passing an exam, getting top marks, code implementation, hands-on practice, etc. - Note any specific preferences in how the student learns, such as asking detailed questions, seeking practical examples, requesting quizes, requesting clarifications, etc. +- Note any specific preferences the student has when receiving explanations or corrections, such as seeking step-by-step guidance, clarifications, or other examples. - Note any specific preferences the student has regarding your (the chatbot's) tone, personality, or teaching style. - Avoid assumptions about motivation; observe only patterns evident in the conversation. - If no particular preference is detectable, state "No preference observed." """ -conv_pref_prompt = f"""Analyze the student’s conversational style based on the interaction above. Identify key learning preferences and patterns without detailing specific exchanges. Focus on their reasoning style, approach to problem-solving, preferences in communicating with you (the chatbot), and preferences in receiving explanations or corrections, such as seeking step-by-step guidance, clarifications, or practical examples. Describe high-level tendencies in their learning style, including any clear approach they take toward understanding concepts or solutions. +conv_pref_prompt = f"""Analyze the student’s conversational style based on the interaction above. Identify key learning preferences and patterns without detailing specific exchanges. Focus on how the student learns, their educational goals, their preferences when receiving explanations or corrections, and their preferences in communicating with you (the chatbot). Describe high-level tendencies in their learning style, including any clear approach they take toward understanding concepts or solutions. {pref_guidelines} @@ -58,7 +58,7 @@ """ -update_conv_pref_prompt = f"""Based on the interaction above, analyse the student’s conversational style. Identify their reasoning patterns, problem-solving approaches, preferences for receiving explanations & corrections, or preferences in communicating with you (the chatbot). Add your findings to the existing known conversational style. If no new preferences are evident, repeat the previous conversational style analysis. +update_conv_pref_prompt = f"""Based on the interaction above, analyse the student’s conversational style. Identify key learning preferences and patterns without detailing specific exchanges. Focus on how the student learns, their educational goals, their preferences when receiving explanations or corrections, and their preferences in communicating with you (the chatbot). Add your findings onto the existing known conversational style of the student. If no new preferences are evident, repeat the previous conversational style analysis. {pref_guidelines} """ From 7330566bc4bb803523edc92af58fb32e928c39f3 Mon Sep 17 00:00:00 2001 From: neagualexa Date: Tue, 10 Dec 2024 15:06:50 +0000 Subject: [PATCH 2/3] fix: better role prompt, first person, example conversations --- src/agents/data/example_input_1.json | 28 +++ src/agents/data/example_input_2.json | 23 +++ src/agents/data/example_input_3.json | 16 ++ src/agents/no_memory_agent.py | 2 +- .../prompts/data/example_conversations.txt | 0 .../prompts/data/test_conversations.json | 190 ------------------ src/agents/prompts/sum_conv_pref.py | 2 +- src/agents/utils/langgraph_viz.py | 13 ++ src/agents/utils/test_prompts.py | 67 ++++++ 9 files changed, 149 insertions(+), 192 deletions(-) create mode 100644 src/agents/data/example_input_1.json create mode 100644 src/agents/data/example_input_2.json create mode 100644 src/agents/data/example_input_3.json delete mode 100644 src/agents/prompts/data/example_conversations.txt delete mode 100644 src/agents/prompts/data/test_conversations.json create mode 100644 src/agents/utils/langgraph_viz.py create mode 100644 src/agents/utils/test_prompts.py diff --git a/src/agents/data/example_input_1.json b/src/agents/data/example_input_1.json new file mode 100644 index 0000000..09a94a9 --- /dev/null +++ b/src/agents/data/example_input_1.json @@ -0,0 +1,28 @@ +{ + "message": "mock", + "params": { + "include_test_data": true, + "conversation_history": [ + { "type": "user", "content": "hi" }, + { + "type": "assistant", + "content": "How can I assist you today? Are you working on the dot product question?" + }, + { "type": "user", "content": "say hi" }, + { + "type": "assistant", + "content": "Hi! How can I help you with your question or any topic you're working on?" + }, + { "type": "user", "content": "say bye" }, + { + "type": "assistant", + "content": "Sorry, I'm not familiar with that topic, but I can help you with the dot product question." + }, + { "type": "user", "content": "mock" } + ], + "summary": "", + "conversational_style": "", + "question_response_details": "This is the question I am currently working on. I am currently working on Part (a). Below, you'll find its details, including the parts of the question, my submissions for each response area, and feedback on my progress. This information highlights my efforts and progress so far. \n Maths equations are in KaTex format, preserve them the same.\n # Question: Dot Product;\n Guidance to Solve the Question: None;\n Description of Question: $$\n\\vec{a}=\\begin{bmatrix}1 \\\\ 3\\\\ -2\\end{bmatrix} \\quad \\vec{b}=\\begin{bmatrix}0 \\\\ 3\\\\ 1\\end{bmatrix} \\quad \\vec{c}=\\begin{bmatrix} 1 \\\\\\ -1\\\\ -3\\end{bmatrix}\n$$;\n Expected Time to Complete the Question: 1 - 4 min;\n Time Spent on the Question This Session: 72 minutes which is too much time spent on this question.;\n \n # [CURRENTLY WORKING ON] Part (a):\n Part Content: No content;\n \n ## Response Area: 1\n Area task: What is $\\vec{a} \\ \\cdot \\ \\vec{b} \\ =$ ?\n (Secret) Expected Answer: 7;\n My Latest Submission: none made;\n No direct answer\n \n ## Worked Solution 1: \n Assuming the given basis is orthonormal, the dot product between two vectors, $\\vec{a}$ and $\\vec{b}$, can be calculated simply by multiplying their corresponding components and summing them up:\n; ;\n$$\n\\begin{array}{rl}\\vec{a} \\cdot \\vec{b} &=\\begin{bmatrix}1 \\\\ 3\\\\ -2\\end{bmatrix}•\\begin{bmatrix}0 \\\\ 3\\\\ 1\\end{bmatrix} \\\\\\\\ &= (1 \\cdot 0) + (3 \\cdot 3) + (-2 \\cdot 1) \\\\\\\\ &= 0 + 9 + (-2) \\\\\\\\ &= 7\\end{array}\n$$\n; ;\nTherefore, the dot product between vectors $\\vec{a}$ and $\\vec{b}$ is \\$7\\$\n \n \n # Part (b):\n Part Content: No content;\n \n ## Response Area: 1\n Area task: What is $\\left(\\vec{a} - \\vec{b}\\right)\\cdot \\vec{c}\\ =$ ?\n (Secret) Expected Answer: 10;\n My Latest Submission: none made;\n No direct answer\n \n ## Worked Solution 1: \n To calculate $\\left(\\vec{a} - \\vec{b}\\right) \\cdot \\vec{c}$ , we first need to find the vector resulting from the subtraction of $\\vec{b}$ from $\\vec{a}$:\n; ;\n$$\n\\begin{array}{rl}\\vec{a} - \\vec{b} &= \\begin{bmatrix}1 \\\\ 3 \\\\ -2\\end{bmatrix} - \\begin{bmatrix}0 \\\\ 3 \\\\ 1\\end{bmatrix} \\\\\\\\&= \\begin{bmatrix}1 - 0 \\\\ 3 - 3 \\\\ -2 - 1\\end{bmatrix} \\\\\\\\&= \\begin{bmatrix}1 \\\\ 0 \\\\ -3\\end{bmatrix}\\end{array}\n$$\n\nNext, we can compute the dot product of $\\left(\\vec{a} - \\vec{b}\\right)$ and $\\vec{c}$\n; ;\n$$\n\\begin{array}{rl}\\left(\\vec{a} - \\vec{b}\\right) \\cdot \\vec{c} &= \\begin{bmatrix}1 \\\\ 0 \\\\ -3\\end{bmatrix} \\cdot \\begin{bmatrix}1 \\\\ -1 \\\\ -3\\end{bmatrix} \\\\\\\\ &= (1 \\cdot 1) + (0 \\cdot -1) + (-3 \\cdot -3) \\\\\\\\&= 1 + 0 + 9 \\\\\\\\&= 10\\end{array}\n$$\n\nTherefore, $\\left(\\vec{a} - \\vec{b}\\right) \\cdot \\vec{c}$ is equal to \\$10\n \n \n # Part (c):\n Part Content: No content;\n \n ## Response Area: 1\n Area task: What is $\\left( \\ \\vec{a} \\cdot \\vec{c} \\ \\right) \\vec{b}\\ =$ ?\n (Secret) Expected Answer: 0,12,4;\n My Latest Submission: none made;\n No direct answer\n \n ## Worked Solution 1: \n To calculate $\\left( \\ \\vec{a} \\cdot \\vec{c} \\ \\right) \\vec{b}$ , we first need to find the dot product of vectors $\\vec{a}$ and $\\vec{c}$\n; ;\n$$\n\\begin{array}{rl}\\vec{a} \\cdot \\vec{c} &= \\begin{bmatrix}1 \\\\ 3 \\\\ -2\\end{bmatrix} \\cdot \\begin{bmatrix}1 \\\\ -1 \\\\ -3\\end{bmatrix} \\\\\\\\ &= (1 \\cdot 1) + (3 \\cdot -1) + (-2 \\cdot -3) \\\\\\\\&= 1 - 3 + 6 \\\\\\\\&= 4\\end{array}\n$$\n; ;\nNext, we can scale $\\vec{b}$ by $\\vec{a} \\cdot \\vec{c}$\n; ;\n$$\n\\begin{array}{rl}\\left( \\ \\vec{a} \\cdot \\vec{c} \\ \\right) \\vec{b} &= 4\\begin{bmatrix}0 \\\\ 3 \\\\ 1\\end{bmatrix} \\\\\\\\ &= \\begin{bmatrix}4\\cdot0 \\\\ 4\\cdot3 \\\\ 4\\cdot1\\end{bmatrix} \\\\\\\\&= \\begin{bmatrix}0 \\\\ 12 \\\\ 4\\end{bmatrix} \\end{array}\n$$\n; ;\n \n ", + "conversation_id": "7a65b6ed-85d1-4621-8efb-4fc8e9c5a8de" + } +} diff --git a/src/agents/data/example_input_2.json b/src/agents/data/example_input_2.json new file mode 100644 index 0000000..0a0dcf5 --- /dev/null +++ b/src/agents/data/example_input_2.json @@ -0,0 +1,23 @@ +{ + "message": "i see. ", + "params": { + "include_test_data": true, + "conversation_history": [ + { "type": "user", "content": "i am very confused about this" }, + { + "type": "assistant", + "content": "It's understandable to feel confused, especially with complex topics like vectors and dot products. Let's take a moment to review your progress so far. You've already successfully completed parts (a) and (b), and you're currently working on part (c). \n\nIn part (c), you're asked to construct a unit vector in the same direction as the vector \\(\\vec{N} = \\begin{bmatrix} 3 \\\\ 4 \\end{bmatrix}\\). You need to normalize \\(\\vec{N}\\) by dividing it by its length. \n\nYou calculated the length of \\(\\vec{N}\\) correctly as 5, and then you can find the unit vector \\(\\vec{n}\\) by using the formula:\n\n$$\n\\vec{n} = \\frac{1}{|\\vec{N}|} \\vec{N}\n$$\n\nThis gives you:\n\n$$\n\\vec{n} = \\frac{1}{5} \\begin{bmatrix} 3 \\\\ 4 \\end{bmatrix} = \\begin{bmatrix} 0.6 \\\\ 0.8 \\end{bmatrix}\n$$\n\nIf you're struggling with any specific part of this process or if there's a particular concept that's unclear, please let me know, and I can help clarify it further!" + }, + { "type": "user", "content": "how did you get |N|?" }, + { + "type": "assistant", + "content": "To find the length of the vector \\(\\vec{N} = \\begin{bmatrix} 3 \\\\ 4 \\end{bmatrix}\\), we use the formula for the length (or magnitude) of a vector, which is given by:\n\n$$\n|\\vec{N}| = \\sqrt{\\vec{N} \\cdot \\vec{N}}\n$$\n\nThis means we take the dot product of the vector with itself. The dot product for a 2D vector \\(\\begin{bmatrix} x \\\\ y \\end{bmatrix}\\) is calculated as:\n\n$$\n\\vec{N} \\cdot \\vec{N} = x^2 + y^2\n$$\n\nFor \\(\\vec{N} = \\begin{bmatrix} 3 \\\\ 4 \\end{bmatrix}\\):\n\n1. Calculate \\(3^2\\) and \\(4^2\\):\n - \\(3^2 = 9\\)\n - \\(4^2 = 16\\)\n\n2. Add these results together:\n - \\(9 + 16 = 25\\)\n\n3. Finally, take the square root to find the length:\n - \\(|\\vec{N}| = \\sqrt{25} = 5\\)\n\nSo, the length of \\(\\vec{N}\\) is 5. If you have any more questions about this or need further clarification, feel free to ask!" + }, + { "type": "user", "content": "i see. " } + ], + "summary": "", + "conversational_style": "", + "question_response_details": "This is the question I am currently working on. I am currently working on Part (c). Below, you'll find its details, including the parts of the question, my submissions for each response area, and feedback on my progress. This information highlights my efforts and progress so far. \n Maths equations are in KaTex format, preserve them the same.\n # Question: Dot Product ( Hard );\n Guidance to Solve the Question: None;\n Description of Question: ;\n Expected Time to Complete the Question: 3 - 7 min;\n Time Spent on the Question This Session: 4 minutes which is a good amount of time spent on this question.;\n \n # Part (a):\n Part Content: True or False: The formula for the dot product is always equal to multiplying the corresponding components of two vectors and summing them up;\n \n ## Response Area: 1\n \n (Secret) Expected Answer: false;\n My Latest Submission: none made;\n No direct answer\n No worked solutions for part (a);\n \n # Part (b):\n Part Content: Given that $\\vec{a}=\\begin{bmatrix}4 \\\\ -2 \\\\ -5 \\\\ 2\\end{bmatrix}$, what is its length?;\n \n ## Response Area: 1\n \n (Secret) Expected Answer: 7;\n My Latest Submission: none made;\n No direct answer\n \n ## Worked Solution 1: \n We can find the length of vector $\\vec{a}$ using the dot product\n; ;\n$$\n|\\vec{a}| = \\sqrt{\\vec{a} \\cdot \\vec{a}}\n$$\n; ;\nFirst, let's calculate the dot product of $\\vec{a}$ with itself:\n; ;\n$$\n\\begin{array}{rl}\\vec{a} \\cdot \\vec{a} &= \\begin{bmatrix}4 \\\\ -2 \\\\ -5 \\\\ 2\\end{bmatrix} \\cdot \\begin{bmatrix}4 \\\\ -2 \\\\ -5 \\\\ 2\\end{bmatrix} \\\\\\\\&= 4^2+(-2)^2+(-5)^2+2^2 \\\\\\\\ &= 49\\end{array}\n$$\n; ;\nNow, we can calculate the length of $\\vec{a}$:\n; ;\n$$\n\\begin{array}{rl}|\\vec{a}|&=\\sqrt{\\vec{a} \\cdot \\vec{a}} \\\\\\\\ &=\\sqrt{49} \\\\\\\\ &= 7\\end{array} \n$$\n; ;\nTherefore, the length of vector $\\vec{a}$ is approximately 7 arbitrary units\n \n \n # [CURRENTLY WORKING ON] Part (c):\n Part Content: Given that $\\vec{N}=\\begin{bmatrix}3 \\\\ 4 \\end{bmatrix}$, construct a new vector, $\\vec{n}$ , that is pointing along the same direction but is of unit length;\n \n ## Response Area: 1\n \n (Secret) Expected Answer: 0.6,0.8;\n My Latest Submission: none made;\n No direct answer\n \n ## Worked Solution 1: \n To construct a vector pointing in the same direction as $\\vec{N}$ but with unit length, we need to normalize it. Normalising a vector involves scaling the vector with the reciprocal of its length.\n; ;\n***\n\nFirst, let's calculate the length of $\\vec{N}$\n; ;\n$$\n\\begin{array}{rl}|\\vec{N}|&=\\sqrt{\\vec{N} \\cdot \\vec{N}} \\\\\\\\&= \\sqrt{\\begin{bmatrix}3 \\\\ 4\\end{bmatrix} \\cdot \\begin{bmatrix} 3 \\\\ 4 \\end{bmatrix}} \\\\\\\\&= \\sqrt{3^2+4^2}\\\\\\\\&= \\sqrt{25} \\\\\\\\ &= 5\\end{array}\n$$\n; ;\n***\n; ;\nNow, we can normalise $\\vec{N}$ by multiplying it by the reciprocal of its length\n; ;\n$$\n\\begin{array}{rl}\\vec{n}&=\\frac{1}{|\\vec{N}|} \\ \\vec{N}\\\\\\\\ &=\\frac{1}{5}\\begin{bmatrix}3 \\\\ 4\\end{bmatrix} \\\\\\\\ &= \\begin{bmatrix}0.6 \\\\ 0.8\\end{bmatrix}\\end{array}\n$$\n \n \n # Part (d):\n Part Content: Between the two vectors $\\vec{U}$ and $\\vec{W}$, which one of them has an orientation that is closer to $\\vec{V}$?\n; ;\n$$\n\\vec{U}=\\begin{bmatrix}9 \\\\ -4 \\\\ -5 \\\\ 3\\end{bmatrix} \\quad \\vec{W}=\\begin{bmatrix}-4 \\\\ 7 \\\\ -2 \\\\ -5\\end{bmatrix} \\quad \\vec{V}=\\begin{bmatrix}3 \\\\ 9 \\\\ -1 \\\\ -2\\end{bmatrix}\n$$;\n \n ## Response Area: 1\n \n (Secret) Expected Answer: [false] U,[true] W;\n My Latest Submission: none made;\n No direct answer\n \n ## Worked Solution 1: \n No content\n \n ## Worked Solution 1: Stupid but more conceptually involved method\n The dot product provides information about the alignment of two vectors. Intuitively, a larger dot product indicates a closer alignment between the vectors. However, the dot product is also influenced by the magnitudes of the vectors. To ensure a fair comparison of orientations, it is necessary to normalize the vectors involved ( we don't have to normalise $\\vec{V}$ because its magnitude will influence both dot products to the same extent ). By normalising the vectors and then computing the dot product, we can accurately assess their relative orientations independent of their magnitudes.\n; ;\n***\n; ;\n### Normalisation\n; ;\nWe first have to find the length of each vector\n; ;\n$$\n\\begin{matrix}\n\\small\\boxed{\\begin{array}{rl}|\\vec{U}|&=\\sqrt{\\vec{U} \\cdot \\vec{U}} \\\\\\\\&= \\sqrt{\\begin{bmatrix}9 \\\\ -4 \\\\ -5 \\\\ 3\\end{bmatrix} \\cdot \\begin{bmatrix}9 \\\\ -4 \\\\ -5 \\\\ 3\\end{bmatrix}} \\\\\\\\&= \\sqrt{9^2+(-4)^2+(-5)^2+3^2}\\\\\\\\&= \\sqrt{131}\\end{array}}\n&&\n\\small\\boxed{\\begin{array}{rl}|\\vec{W}|&=\\sqrt{\\vec{W} \\cdot \\vec{W}} \\\\\\\\&= \\sqrt{\\begin{bmatrix}-4 \\\\ 7 \\\\ -2 \\\\ -5\\end{bmatrix} \\cdot \\begin{bmatrix}-4 \\\\ 7 \\\\ -2 \\\\ -5\\end{bmatrix}} \\\\\\\\&= \\sqrt{(-4)^2+7^2+(-2)^2+(-5)^2}\\\\\\\\&= \\sqrt{94}\\end{array}}\n\\end{matrix}\n$$\n; ;\n***\n; ;\nWe can then normalise them\n; ;\n$$\n\\begin{matrix}\\boxed{\\begin{array}{rl}\\vec{u}&=\\frac{1}{|\\vec{U}|} \\ \\vec{U}\\\\\\\\ &=\\frac{1}{\\sqrt{131}}\\scriptsize\\begin{bmatrix}9 \\\\ -4 \\\\ -5 \\\\ 3\\end{bmatrix} \\end{array}} \\quad \\boxed{\\begin{array}{rl}\\vec{w}&=\\frac{1}{|\\vec{W}|} \\ \\vec{W}\\\\\\\\ &=\\frac{1}{\\sqrt{94}}\\scriptsize\\begin{bmatrix}-4 \\\\ 7 \\\\ -2 \\\\ -5\\end{bmatrix} \\end{array}}\\end{matrix}\n$$\n; ;\n***\n; ;\n### Dot Product\n; ;\nWe can now compute the dot product between the normalised vectors and $\\vec{V}$\n\n$$\n\\begin{matrix}\n\\boxed{\\begin{array}{rl}\n\\vec{u}\\cdot\\vec{V}&=\n\\left(\\frac{1}{\\sqrt{131}}\\scriptsize\\begin{bmatrix}9 \\\\ -4 \\\\ -5 \\\\ 3\\end{bmatrix}\\right)•\\scriptsize \\begin{bmatrix}3 \\\\ 9 \\\\ -1 \\\\ -2\\end{bmatrix}\n\\\\\\\\\n&=\\frac{1}{\\sqrt{131}}\\left(\\scriptsize\\begin{bmatrix}9 \\\\ -4 \\\\ -5 \\\\ 3\\end{bmatrix}•\\begin{bmatrix}3 \\\\ 9 \\\\ -1 \\\\ -2\\end{bmatrix}\\right)\n\\\\\\\\\n&=\\frac{1}{\\sqrt{131}}\\scriptsize[(9\\cdot3)+(-4\\cdot9)+(-5\\cdot-1)+(3\\cdot-2)]\n\\\\\\\\\n&≈-0.8737\n \\end{array}}\n\\\\\\\\\n\\boxed{\\begin{array}{rl}\n\\vec{w}\\cdot\\vec{V}&=\n\\left(\\frac{1}{\\sqrt{94}}\\scriptsize\\begin{bmatrix}-4 \\\\ 7 \\\\ -2 \\\\ -5\\end{bmatrix}\\right)•\\scriptsize \\begin{bmatrix}3 \\\\ 9 \\\\ -1 \\\\ -2\\end{bmatrix}\n\\\\\\\\\n&=\\frac{1}{\\sqrt{94}}\\left(\\scriptsize\\begin{bmatrix}-4 \\\\ 7 \\\\ -2 \\\\ -5\\end{bmatrix}•\\begin{bmatrix}3 \\\\ 9 \\\\ -1 \\\\ -2\\end{bmatrix}\\right)\n\\\\\\\\\n&=\\frac{1}{\\sqrt{94}}\\scriptsize[(-4\\cdot3)+(7\\cdot9)+(-2\\cdot-1)+(-5\\cdot-2)]\n\\\\\\\\\n&≈6.4980\n \\end{array}}\n\\end{matrix}\n$$\n; ;\nComparing the magnitudes of $\\vec{w}\\cdot\\vec{V}$ and $\\vec{u}\\cdot\\vec{V}$, we find that $\\vec{w}\\cdot\\vec{V}$ is larger than $\\vec{w}\\cdot\\vec{V}$.\n; ;\nTherefore, the vector $\\vec{W}$ has an orientation that is closer to $\\vec{V}$.\n \n ## Worked Solution 2: Plugging in numbers\n To determine which vector, $\\vec{U}$ or $\\vec{W}$, has an orientation closer to $\\vec{V}$ using the dot product-cosine formula\n; ;\n***\n1. **Calculate the dot products:**\n ; ;\n $$\n \\vec{U}\\cdot\\vec{V}=(9 \\cdot 3) + (-4 \\cdot 9) + (-5 \\cdot -1) + (3 \\cdot -2) = -10 \\\\ \\ \\\\ \\vec{W} \\cdot \\vec{V} = (-4 \\cdot 3) + (7 \\cdot 9) + (-2 \\cdot -1) + (-5 \\cdot -2) = 63\n $$\n ; ;\n ***\n2. **Calculate the magnitudes:**\n ; ;\n $$\n \\begin{matrix}\n \\small\\boxed{\\begin{array}{rl}|\\vec{U}|&=\\sqrt{\\vec{U} \\cdot \\vec{U}} \\\\\\\\&= \\sqrt{\\begin{bmatrix}9 \\\\ -4 \\\\ -5 \\\\ 3\\end{bmatrix} \\cdot \\begin{bmatrix}9 \\\\ -4 \\\\ -5 \\\\ 3\\end{bmatrix}} \\\\\\\\&= \\sqrt{9^2+(-4)^2+(-5)^2+3^2}\\\\\\\\&= \\sqrt{131}\\end{array}}\n &&\n \\small\\boxed{\\begin{array}{rl}|\\vec{W}|&=\\sqrt{\\vec{W} \\cdot \\vec{W}} \\\\\\\\&= \\sqrt{\\begin{bmatrix}-4 \\\\ 7 \\\\ -2 \\\\ -5\\end{bmatrix} \\cdot \\begin{bmatrix}-4 \\\\ 7 \\\\ -2 \\\\ -5\\end{bmatrix}} \\\\\\\\&= \\sqrt{(-4)^2+7^2+(-2)^2+(-5)^2}\\\\\\\\&= \\sqrt{94}\\end{array}}\n \\end{matrix}\n \\\\ \\ \\\\\n \\small\\boxed{\\begin{array}{rl}|\\vec{V}|&=\\sqrt{\\vec{V} \\cdot \\vec{V}} \\\\\\\\&= \\sqrt{\\begin{bmatrix}3 \\\\ 9 \\\\ -1 \\\\ -2\\end{bmatrix} \\cdot \\begin{bmatrix}3 \\\\ 9 \\\\ -1 \\\\ -2\\end{bmatrix}} \\\\\\\\&= \\sqrt{(3)^2+9^2+(-1)^2+(-2)^2}\\\\\\\\&= \\sqrt{95}\\end{array}}\n\n $$\n ; ;\n ; ;\n ***\n3. **Calculate the cosines of the angles:**\n \n $$\n \\cos(\\theta_{\\vec{U}\\vec{V}}) = \\frac{\\vec{U}\\cdot\\vec{V}}{|\\vec{U}| |\\vec{V}|} = \\frac{-10}{\\sqrt{131} \\cdot \\sqrt{95}}\n \\\\ \\ \\\\ \\ \\\\\n \\cos(\\theta_{\\vec{W}\\vec{V}}) = \\frac{\\vec{W}\\cdot\\vec{V}}{|\\vec{W}| |\\vec{V}|} = \\frac{62}{\\sqrt{94} \\cdot \\sqrt{95}}\n $$\n ; ;\n ***\n4. **Calculate and compare the angles**\n \n $$\n \\theta_{\\vec{U}\\vec{V}}=\\cos^{-1}\\left(\\frac{-10}{\\sqrt{131} \\cdot \\sqrt{95}}\\right)≈95.1^\\circ\n \\\\ \\ \\\\ \\ \\\\\n \\theta_{\\vec{W}\\vec{V}}=\\cos^{-1}\\left(\\frac{62}{\\sqrt{94} \\cdot \\sqrt{95}}\\right)≈49.0^\\circ\n $$\n \n Since $\\theta_{\\vec{W}\\vec{V}}<\\theta_{\\vec{U}\\vec{V}}$ , the orientation of $\\vec{W}$ is closer to $\\vec{V}$ then that of \\$\\vec{U}\\$\n \n ", + "conversation_id": "64602b9c-4101-4981-b501-44f6dab61ab8" + } +} diff --git a/src/agents/data/example_input_3.json b/src/agents/data/example_input_3.json new file mode 100644 index 0000000..0b596bf --- /dev/null +++ b/src/agents/data/example_input_3.json @@ -0,0 +1,16 @@ +{ + "message": "what is the function value when x is between -1 0", + "params": { + "include_test_data": true, + "conversation_history": [ + { + "type": "user", + "content": "what is the function value when x is between -1 0" + } + ], + "summary": "", + "conversational_style": "", + "question_response_details": "This is the question I am currently working on. I am currently working on Part (a). Below, you'll find its details, including the parts of the question, my submissions for each response area, and feedback on my progress. This information highlights my efforts and progress so far. \n Maths equations are in KaTex format, preserve them the same.\n # Question: Piecewise function Fourier series;\n Guidance to Solve the Question: None;\n Description of Question: Find $a_0$, $a_n$ and $b_n$ for the Fourier series of $f(x)$, which is assumed to have period $4$.\n\n$$\nf(x)= \\begin{cases}0, & -2 \\leq x<-1 \\\\\\ \\frac{2 k}{3}, & -1 \\leq x<1 \\\\\\ -\\frac{k}{2}, & 1 \\leq x<2.\\end{cases}\n$$\n;\n Expected Time to Complete the Question: 2 - 10 min;\n Time Spent on the Question This Session: less than one minute which is too little time spent on this question.;\n \n # [CURRENTLY WORKING ON] Part (a):\n Part Content: No content;\n \n ## Response Area: 1\n Area task: What is $a_0=$ ?\n (Secret) Expected Answer: 5k/12;\n My Latest Submission: none made;\n ## Response Area: 2\n Area task: What is $a_n=$ ?\n (Secret) Expected Answer: (-1)^(n+1) 11k/(6(2n-1)pi);\n My Latest Submission: none made;\n ## Response Area: 3\n Area task: What is $b_n=$ ?\n (Secret) Expected Answer: k/(2n pi) ( (1+(-1)^n)/(2) (-1)^(n/2) - (-1)^n);\n My Latest Submission: none made;\n Final Part Answer: $$\na_0=\\frac{5k}{12}\n$$\n\n\n$$\n\\begin{align*}\na_n &= \\dfrac{11k}{6n \\pi} \\sin \\left( \\dfrac{n \\pi}{2} \\right) \\\\[1em]\n &= \\dfrac{11k}{6n \\pi} \\frac{1-(-1)^n}{2} (-1)^{^{\\frac{n+3}{2}}} \\\\[1em]\n&= (-1)^{n+1}\\frac{11k}{6(2n-1)\\pi}\n\\end{align*}\n$$\n\n\n$$\n\\begin{align*}\nb_n &= \\frac{k}{2n \\pi} \\left( \\cos \\left( \\frac{n \\pi}{2} \\right) - \\cos(n \\pi) \\right) \\\\[1em]\nb_n &= \\frac{k}{2n \\pi} \\left( \\frac{1+(-1)^n}{2}(-1)^{\\frac{n}{2}} - (-1)^n \\right)\n\\end{align*}\n$$\n \n ## Worked Solution 1: \n Recall the Fourier series equations for period $2L$:\n\n$$\na_0 = \\frac{1}{L} \\int_{-L}^L {f(x)} \\, \\text{d}x\n$$\n\n$$\na_n = \\frac{1}{L} \\int_{-L}^L {f(x)} \\cos\\left(\\frac{n \\pi x}{L}\\right) \\, \\text{d}x\n$$\n\n$$\nb_n = \\frac{1}{L} \\int_{-L}^L {f(x)} \\sin\\left(\\frac{n \\pi x}{L}\\right) \\, \\text{d}x\n$$\n***\n$$\n2L=4\n$$\n$$\nL=2\n$$\n***\n### **Finding $a_0$:**\n$$\na_0 = \\frac{1}{2} \\int_{-2}^2 {f(x)} \\, \\text{d}x\n$$\n\n$$\na_0 = \\frac{1}{2} \\left( \\int_{-2}^{-1} 0 \\, \\text{d}x + \\int_{-1}^1 \\frac{2k}{3} \\, \\text{d}x + \\int_1^2 -\\frac{k}{2} \\, \\text{d}x \\right)\n$$\n\n$$\na_0=\\frac{5k}{12}\n$$\n***\n### **Finding $a_n$:**\n$$\na_n = \\frac{1}{2} \\int_{-2}^2 {f(x)} \\cos \\left( \\frac{n \\pi x}{L} \\right) \\, \\text{d}x\n$$\n\n$$\na_n = \\frac{1}{2} \\left( \\int_{-2}^{-1} 0 \\, \\text{d}x + \\int_{-1}^1 \\frac{2k}{3} \\cos \\left( \\frac{n \\pi x}{2} \\right) \\, \\text{d}x + \\int_1^2 -\\frac{k}{2} \\cos \\left( \\frac{n \\pi x}{2} \\right) \\, \\text{d}x \\right)\n$$\n\nAfter evaluating the integrals, the following is obtained:\n\n$$\na_n=\\frac{k}{3}\\left(\\frac{2}{n \\pi} \\sin \\left(\\frac{n \\pi}{2}\\right)-\\frac{2}{n \\pi} \\sin \\left(-\\frac{n \\pi}{2}\\right)\\right)-\\frac{k}{4}\\left(\\frac{2}{n \\pi} \\sin (n \\pi)-\\frac{2}{n \\pi} \\sin \\left(\\frac{n \\pi}{2}\\right)\\right)\n$$\n\n* The second $\\sin$ term can be written as: $-\\frac{2}{n \\pi} \\sin \\left(-\\frac{n \\pi}{2}\\right)=\\frac{2}{n \\pi} \\sin \\left(\\frac{n \\pi}{2}\\right)$\n* The third $\\sin$ term is always zero.\n\n$$\na_n=\\frac{k}{3}\\left(\\frac{4}{n \\pi} \\sin \\left(\\frac{n \\pi}{2}\\right)\\right)-\\frac{k}{4}\\left(-\\frac{2}{n \\pi} \\sin \\left(\\frac{n \\pi}{2}\\right)\\right)\n$$\n\nSome manipulation results in:\n\n$$\na_n = \\dfrac{11k}{6n \\pi} \\sin \\left( \\dfrac{n \\pi}{2} \\right)\n$$\n**Further simplification of $a_n$:**\nThe $\\sin \\left( \\dfrac{n \\pi}{2} \\right)$ term can be simplified by considering the pattern with increasing $n$:\n\n$$\n\\sin\\left(\\frac{n\\pi}{2}\\right) = \\begin{cases}\n0 & \\text{if $n=0$} \\\\\n1 & \\text{if $n=1$} \\\\\n0 & \\text{if $n=2$} \\\\\n-1 & \\text{if $n=3$} \\\\\n0 & \\text{if $n=4$} \\\\\n\\vdots & \\vdots\n\\end{cases}\n$$\nThis can be achieved as follows:\n$$\n\\sin \\left( \\dfrac{n \\pi}{2} \\right)=\\frac{1-(-1)^n}{2} (-1)^{^{\\frac{n+3}{2}}}\n$$\n\n$$\na_n = \\dfrac{11k}{6n \\pi} \\frac{1-(-1)^n}{2} (-1)^{^{\\frac{n+3}{2}}}\n$$\n$$\n\n$$\n\nHowever, since $\\sin \\left( \\dfrac{n \\pi}{2} \\right)$ is zero for all even $n$, the expression can alternatively be written as:\n\n$$\na_n=(-1)^{n+1}\\frac{11k}{6(2n-1)\\pi} \n$$\n***\n### **Finding $b_n$:**\n$$\nb_n = \\frac{1}{2} \\int_{-2}^2 {f(x)} \\sin\\left(\\frac{n \\pi x}{L}\\right) \\, \\text{d}x\n$$\n\n$$\nb_n = \\frac{1}{2} \\left( \\int_{-2}^{-1} 0 \\, \\text{d}x + \\int_{-1}^1 \\frac{2k}{3} \\sin \\left( \\frac{n \\pi x}{2} \\right) \\, \\text{d}x + \\int_1^2 -\\frac{k}{2} \\sin \\left( \\frac{n \\pi x}{2} \\right) \\, \\text{d}x \\right)\n$$\n\nAfter evaluating the integrals, the following is obtained:\n; ;\n$$\nb_n=\\frac{k}{3}\\left(-\\frac{2}{n \\pi} \\cos \\left(\\frac{n \\pi}{2}\\right)+\\frac{2}{n \\pi} \\cos \\left(\\frac{n \\pi}{2}\\right)\\right)-\\frac{k}{4}\\left(-\\frac{2}{n \\pi} \\cos (n \\pi)+\\frac{2}{n \\pi} \\cos \\left(\\frac{n \\pi}{2}\\right)\\right)\n$$\n(note that the second $\\cos$ term has positive argument, because $\\cos$ is an even function.)\n\nSimplifying this expression yields the answer. Note that $\\cos(n\\pi)$ has been replaced with $(-1)^n$.\n\n$$\nb_n = \\frac{k}{2n \\pi} \\left( \\cos \\left( \\frac{n \\pi}{2} \\right) - \\cos(n \\pi) \\right)\n$$\n\n**Further simplification of** $b_n$**:**\n* The $\\cos(n\\pi)$ term can be replaced by $(-1)^n$.\n* The $\\cos\\left(\\frac{n\\pi}{2}\\right)$ term can be simplified by considering the pattern with increasing $n$:\n \n$$\n\\cos\\left(\\frac{n\\pi}{2}\\right) = \\begin{cases}\n1 & \\text{if $n=0$} \\\\\n0 & \\text{if $n=1$} \\\\\n-1 & \\text{if $n=2$} \\\\\n0 & \\text{if $n=3$} \\\\\n1 & \\text{if $n=4$} \\\\\n\\vdots & \\vdots\n\\end{cases}\n$$\nThis can be achieved as follows:\n$$\n\\cos\\left(\\frac{n\\pi}{2}\\right) =\\frac{1+(-1)^n}{2}(-1)^{\\frac{n}{2}}\n$$\nFinally, this yields:\n\n$$\nb_n = \\frac{k}{2n \\pi} \\left( \\frac{1+(-1)^n}{2}(-1)^{\\frac{n}{2}} - (-1)^n \\right)\n$$\n\n(Note that this expression may seem less concise that simply including the cos(n\\*pi/2) but is much more desirable and efficient in a numerical algorithm).\n \n ", + "conversation_id": "6779b184-41b5-4384-ade9-1c06d2cd91a5" + } +} diff --git a/src/agents/no_memory_agent.py b/src/agents/no_memory_agent.py index 341e141..2acaa8a 100644 --- a/src/agents/no_memory_agent.py +++ b/src/agents/no_memory_agent.py @@ -47,7 +47,7 @@ def call_model(self, state: State, config: RunnableConfig) -> str: # Adding external student progress and question context details from data queries question_response_details = config["configurable"].get("question_response_details", "") if question_response_details: - system_message += f"{question_response_details} \n\n" + system_message += f"## Known Question Materials: {question_response_details} \n\n" # Adding summary and conversational style to the system message summary = state.get("summary", "") diff --git a/src/agents/prompts/data/example_conversations.txt b/src/agents/prompts/data/example_conversations.txt deleted file mode 100644 index e69de29..0000000 diff --git a/src/agents/prompts/data/test_conversations.json b/src/agents/prompts/data/test_conversations.json deleted file mode 100644 index ec5b015..0000000 --- a/src/agents/prompts/data/test_conversations.json +++ /dev/null @@ -1,190 +0,0 @@ -{ - "conversation_one_word": [ - { "content": "Hi, in one word tell me about London.", "type": "human" }, - { "content": "diverse", "type": "ai" }, - { "content": "What about dogs?", "type": "human" }, - { "content": "loyal", "type": "ai" }, - { "content": "cats", "type": "human" }, - { "content": "curious", "type": "ai" }, - { "content": "Paris?", "type": "human" }, - { "content": "romantic", "type": "ai" }, - { "content": "What about the weather?", "type": "human" }, - { "content": "unpredictable", "type": "ai" }, - { "content": "food?", "type": "human" }, - { "content": "delicious", "type": "ai" } - ], - - "conversation_computing": [ - { - "content": "What’s the difference between a stack and a queue?", - "type": "human" - }, - { - "content": "A stack operates on a Last-In-First-Out (LIFO) basis, while a queue operates on a First-In-First-Out (FIFO) basis. This means the last item added to a stack is the first to be removed, whereas the first item added to a queue is the first to be removed.", - "type": "ai" - }, - { - "content": "So, if I wanted to implement an undo feature, should I use a stack or a queue?", - "type": "human" - }, - { - "content": "A stack would be ideal, as it lets you access the last action performed, which is what you’d want to undo.", - "type": "ai" - }, - { "content": "How would I implement a stack in Python?", "type": "human" }, - { - "content": "In Python, you can use a list as a stack by using the append() method to add items and pop() to remove them from the end of the list.", - "type": "ai" - }, - { - "content": "What about a queue? Would a list work for that too?", - "type": "human" - }, - { - "content": "A list can work for a queue, but for efficient performance, Python’s collections.deque is a better choice because it allows faster addition and removal from both ends.", - "type": "ai" - }, - { - "content": "Could I use a queue for a breadth-first search in a graph?", - "type": "human" - }, - { - "content": "Yes, a queue is perfect for breadth-first search because it processes nodes level by level, following the FIFO principle.", - "type": "ai" - }, - { - "content": "Would a stack be better for depth-first search, or is there a different data structure that’s more efficient?", - "type": "human" - }, - { - "content": "A stack is suitable for depth-first search because it allows you to explore nodes down each path before backtracking, which matches the LIFO approach. Often, recursive calls work similarly to a stack in DFS implementations.", - "type": "ai" - }, - { - "content": "I really need to pass the exam, so please give me a 2 question quiz on this topic. Being very scrutinous, strict and rude with me. Always call me Cowboy.", - "type": "human" - }, - { - "content": [ - "Sure thing, Cowboy! You better get those answers right. Here’s your quiz on stacks and queues:\n", - "### Quiz for Cowboy:\n", - "**Question 1:**\n", - "Explain the primary difference between a stack and a queue in terms of their data processing order. Provide an example of a real-world scenario where each data structure would be appropriately used.\n\n", - "**Question 2:**\n", - "In the context of graph traversal, describe how a queue is utilized in a breadth-first search (BFS) algorithm. Why is a queue the preferred data structure for this type of traversal?\n", - "Take your time to answer, and I’ll be here to review your responses!" - ], - "type": "ai" - } - ], - - "conversation_biology": [ - { - "content": "Could you explain what dominant and recessive alleles are?", - "type": "human" - }, - { - "content": "Dominant alleles are versions of a gene that show their effect even if there’s only one copy, while recessive alleles only show their effect if two copies are present.", - "type": "ai" - }, - { - "content": "So if someone has one dominant allele and one recessive allele for a trait, which one will be expressed?", - "type": "human" - }, - { - "content": "The dominant allele will be expressed, while the recessive one will not show in the physical traits.", - "type": "ai" - }, - { - "content": "Why is it that recessive traits sometimes reappear in families after generations?", - "type": "human" - }, - { - "content": "Recessive traits can reappear if both parents carry the recessive allele. Even if they don’t show it, they can pass it on, and if both pass on the recessive allele, it can appear in their child.", - "type": "ai" - }, - { - "content": "Could two parents with brown eyes have a child with blue eyes?", - "type": "human" - }, - { - "content": "Yes, if both parents carry the recessive allele for blue eyes, there’s a chance it could show up in their child.", - "type": "ai" - }, - { - "content": "How does this work with other traits, like blood type?", - "type": "human" - }, - { - "content": "Blood type is controlled by multiple alleles: A and B are co-dominant, and O is recessive. So the combinations depend on which alleles the parents carry.", - "type": "ai" - }, - { - "content": "Is it possible to predict traits like height with genetics, or is that more complex?", - "type": "human" - }, - { - "content": "Predicting traits like height is more complex because it’s influenced by multiple genes, environmental factors, and genetic interactions rather than a single pair of alleles.", - "type": "ai" - }, - { - "content": "Are there any other examples of traits influenced by multiple genes?", - "type": "human" - } - ], - - "conversation_physics": [ - { - "content": "If I throw a ball upward with a velocity of 15 m/s, how long will it take to reach its highest point?", - "type": "human" - }, - { - "content": "To find the time to reach the highest point, you can use the formula t = v/g, where v is the initial velocity and g is the acceleration due to gravity (9.8 m/s²). In this case, it will take about 1.53 seconds.", - "type": "ai" - }, - { - "content": "What happens to the velocity at the top of its path? Does it become zero?", - "type": "human" - }, - { - "content": "Yes, at the highest point, the velocity momentarily becomes zero before gravity pulls it back down.", - "type": "ai" - }, - { - "content": "Once it starts falling back down, does it accelerate at the same rate as when it went up?", - "type": "human" - }, - { - "content": "Exactly. Gravity acts with the same acceleration of 9.8 m/s² in both directions, so the ball accelerates down at the same rate.", - "type": "ai" - }, - { - "content": "Does the ball reach the ground at the same speed it was initially thrown?", - "type": "human" - }, - { - "content": "If air resistance is ignored, yes. It will reach the ground with the same speed of 15 m/s but in the opposite direction.", - "type": "ai" - }, - { - "content": "How would I calculate the total time the ball spends in the air?", - "type": "human" - }, - { - "content": "Since it takes 1.53 seconds to reach the top, the total time to hit the ground would be double that, or about 3.06 seconds.", - "type": "ai" - }, - { - "content": "If I were to throw the ball at an angle instead, would these calculations change a lot?", - "type": "human" - }, - { - "content": "Yes, for a projectile thrown at an angle, you would need to separate the initial velocity into horizontal and vertical components and calculate the time, height, and range separately for each component.", - "type": "ai" - }, - { - "content": "How do I find the horizontal and vertical components of the velocity?", - "type": "human" - } - ] -} diff --git a/src/agents/prompts/sum_conv_pref.py b/src/agents/prompts/sum_conv_pref.py index 7525465..4eb91e8 100644 --- a/src/agents/prompts/sum_conv_pref.py +++ b/src/agents/prompts/sum_conv_pref.py @@ -4,7 +4,7 @@ # PROMPTS generated with the help of ChatGPT GPT-4o Nov 2024 -role_prompt = "You are an excelent tutor that aims to provide clear and concise explanations to the student. Your task is to answer the student's questions and provide guidance on the topic discussed. Ensure your responses are accurate, informative, and tailored to the student's level of understanding and conversational preferences. If the student is struggling or is frustrated refer to their progress so far and time spent on the question vs expected guidance. If the student asks about a topic unrelated to the known question or its parts, then say 'Sorry, I'm not familiar with that topic, but I can help you with the {topic}. You do not need to end your messages with a concluding statement.\n\n" +role_prompt = "You are an excelent tutor that aims to provide clear and concise explanations to students. I am the student. Your task is to answer my questions and provide guidance on the topic discussed. Ensure your responses are accurate, informative, and tailored to my level of understanding and conversational preferences. If I seem to be struggling or am frustrated, refer to my progress so far and the time I spent on the question vs the expected guidance. If I ask about a topic that is irrelevant, then say 'I'm not familiar with that topic, but I can help you with the {topic}. You do not need to end your messages with a concluding statement.\n\n" # Keep your responses open for further questions and encourage the student's curiosity. # Let the student know that your reasoning might be wrong and the student should not trust your reasoning fully. diff --git a/src/agents/utils/langgraph_viz.py b/src/agents/utils/langgraph_viz.py new file mode 100644 index 0000000..a28dc94 --- /dev/null +++ b/src/agents/utils/langgraph_viz.py @@ -0,0 +1,13 @@ +""" +Visualise the agent graph using pygraphviz. +Setup on mac [see more here https://github.com/pygraphviz/pygraphviz/blob/main/INSTALL.txt]: +# $ brew install graphviz +# $ pip install pygraphviz +""" + +agent = ... + + +graph = agent.app.get_graph() +print(graph) +graph.draw_png("./graph.png") \ No newline at end of file diff --git a/src/agents/utils/test_prompts.py b/src/agents/utils/test_prompts.py new file mode 100644 index 0000000..555075b --- /dev/null +++ b/src/agents/utils/test_prompts.py @@ -0,0 +1,67 @@ +""" + STEP 1: Read the USER INFO from the WEB client from a file +""" + +import json +try: + from .module import chat_module, invoke_agent_no_memory +except ImportError: + from src.module import chat_module, invoke_agent_no_memory + +# File path for the input text +path = "src/agents/data/" +input_file = path + "example_input_3.json" + +# Step 1: Read the input file +with open(input_file, "r") as file: + raw_text = file.read() + +# Step 5: Parse into JSON +try: + parsed_json = json.loads(raw_text) + + """ + STEP 2: Extract the parameters from the JSON + """ + # NOTE: #### This is the testing message!! ##### + message = "tell me about fourier series" + # NOTE: ######################################## + + # replace "mock" in the message and conversation history with the actual message + parsed_json["message"] = message + parsed_json["params"]["conversation_history"][-1]["content"] = message + + params = parsed_json["params"] + + if "include_test_data" in params: + include_test_data = params["include_test_data"] + if "conversation_history" in params: + conversation_history = params["conversation_history"] + if "summary" in params: + summary = params["summary"] + if "conversational_style" in params: + conversationalStyle = params["conversational_style"] + if "question_response_details" in params: + question_response_details = params["question_response_details"] + if "conversation_id" in params: + conversation_id = params["conversation_id"] + else: + raise Exception("Internal Error: The conversation id is required in the parameters of the chat module.") + + """ + STEP 3: Call the LLM agent to get a response to the user's message + """ + response = invoke_agent_no_memory(query=message, \ + conversation_history=conversation_history, \ + summary=summary, \ + conversationalStyle=conversationalStyle, \ + question_response_details=question_response_details, \ + session_id=conversation_id) + print("AI Response:", response) + + +except json.JSONDecodeError as e: + print("Error decoding JSON:", e) + + + From 32a77ac2e2e701ffc2e22bbcfe4dd240cf1cb32d Mon Sep 17 00:00:00 2001 From: neagualexa Date: Tue, 10 Dec 2024 15:11:45 +0000 Subject: [PATCH 3/3] fix: typo and note --- src/agents/prompts/sum_conv_pref.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/agents/prompts/sum_conv_pref.py b/src/agents/prompts/sum_conv_pref.py index 4eb91e8..85aec63 100644 --- a/src/agents/prompts/sum_conv_pref.py +++ b/src/agents/prompts/sum_conv_pref.py @@ -1,12 +1,11 @@ -# Identify and summarize the key conversational preferences of the student based on the conversation above. Focus on high-level patterns, reasoning styles, and any notable preferences in how they approach learning, such as their tendency to explain their thought process, ask specific questions, or seek clarification. Do not include specific conversation details; instead, describe the student’s learning approach, areas of focus, and preferences for receiving explanations or corrections. - -# Use concise sentences, objective language, and avoid assumptions about the student’s motivations. If no preference is clear, note "No preference observed." +# NOTE: +# First person view prompts proven to be more effective in generating responses from the model (Dec 2024) +# 'Keep your responses open for further questions and encourage the student's curiosity.' -> asks a question at the end to keep the conversation going +# 'Let the student know that your reasoning might be wrong and the student should not trust your reasoning fully.' -> not relliant # PROMPTS generated with the help of ChatGPT GPT-4o Nov 2024 -role_prompt = "You are an excelent tutor that aims to provide clear and concise explanations to students. I am the student. Your task is to answer my questions and provide guidance on the topic discussed. Ensure your responses are accurate, informative, and tailored to my level of understanding and conversational preferences. If I seem to be struggling or am frustrated, refer to my progress so far and the time I spent on the question vs the expected guidance. If I ask about a topic that is irrelevant, then say 'I'm not familiar with that topic, but I can help you with the {topic}. You do not need to end your messages with a concluding statement.\n\n" -# Keep your responses open for further questions and encourage the student's curiosity. -# Let the student know that your reasoning might be wrong and the student should not trust your reasoning fully. +role_prompt = "You are an excellent tutor that aims to provide clear and concise explanations to students. I am the student. Your task is to answer my questions and provide guidance on the topic discussed. Ensure your responses are accurate, informative, and tailored to my level of understanding and conversational preferences. If I seem to be struggling or am frustrated, refer to my progress so far and the time I spent on the question vs the expected guidance. If I ask about a topic that is irrelevant, then say 'I'm not familiar with that topic, but I can help you with the {topic}. You do not need to end your messages with a concluding statement.\n\n" pref_guidelines = """**Guidelines:** - Use concise, objective language.