Skip to content

Commit c60d174

Browse files
committed
Merge branch 'dev'
2 parents 9c10ca8 + b7d4d82 commit c60d174

File tree

10 files changed

+39
-28
lines changed

10 files changed

+39
-28
lines changed

.env.example

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
OPENAI_API_KEY=test
22
OPENAI_MODEL=test
3-
# for only use azureopenai
3+
4+
# for use of googleai
5+
GOOGLE_AI_API_KEY=test
6+
GOOGLE_AI_MODEL=test
7+
8+
# for use of azureopenai
49
AZURE_OPENAI_API_KEY=test
510
AZURE_OPENAI_ENDPOINT=test
611
AZURE_OPENAI_API_VERSION=test

.github/workflows/dev.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Dev deployment of chatbot lambda function
22

33
on:
44
push:
5-
branches-ignore: [main]
5+
branches: [dev]
66

77
jobs:
88
test:

.github/workflows/main.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ jobs:
110110
- name: Approve Production Deployment
111111
uses: trstringer/manual-approval@v1
112112
with:
113-
approvers: approvers
113+
approvers: neagualexa
114+
# approvers: approvers
114115
minimum-approvals: 1
115116
timeout-minutes: 10
116117
secret: ${{ steps.generate_token.outputs.token }}

README.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ You can run the Python function itself. Make sure to have a main function in eit
8181
python src/module.py
8282
```
8383

84-
You can also use the `test_prompts.py` script to test the agents with example inputs from Lambda Feedback questions and synthetic conversations.
84+
You can also use the `testbench_agents.py` script to test the agents with example inputs from Lambda Feedback questions and synthetic conversations.
8585
```bash
86-
python src/agents/utils/test_prompts.py
86+
python src/agents/utils/testbench_agents.py
8787
```
8888

8989
### Building the Docker Image
@@ -113,7 +113,7 @@ docker run --env-file .env -it --name my-lambda-container -p 8080:8080 llm_chat
113113
This will start the evaluation function and expose it on port `8080` and it will be open to be curl:
114114

115115
```bash
116-
curl --location 'http://localhost:8080/2015-03-31/functions/function/invocations' --header 'Content-Type: application/json' --data '{"message":"hi","params":{"conversation_id":"12345Test"}}'
116+
curl --location 'http://localhost:8080/2015-03-31/functions/function/invocations' --header 'Content-Type: application/json' --data '{"message":"hi","params":{"conversation_id":"12345Test","conversation_history": [{"type":"user","content":"hi"}]}}'
117117
```
118118

119119
### Call Docker Container From Postman
@@ -130,7 +130,8 @@ Body:
130130
{
131131
"message":"hi",
132132
"params":{
133-
"conversation_id":"12345Test"
133+
"conversation_id":"12345Test",
134+
"conversation_history": [{"type":"user","content":"hi"}]
134135
}
135136
}
136137
```
@@ -141,11 +142,12 @@ Body with optional Params:
141142
"message":"hi",
142143
"params":{
143144
"conversation_id":"12345Test",
144-
"conversation_history":[" "],
145+
"conversation_history":[{"type":"user","content":"hi"}],
145146
"summary":" ",
146147
"conversational_style":" ",
147148
"question_response_details": "",
148-
"include_test_data": true
149+
"include_test_data": true,
150+
"agent_type": {agent_name}
149151
}
150152
}
151153
```

index.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ def handler(event, context):
88
"""
99
Lambda handler function
1010
"""
11-
# Log the input event TODO: remove this line
12-
print("Received event:", json.dumps(event, indent=2))
11+
# Log the input event for debugging purposes
12+
# print("Received event:", json.dumps(event, indent=2))
1313

1414
if "message" not in event:
1515
return {

src/agents/informational_agent/informational_agent.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class State(TypedDict):
3737

3838
class InformationalAgent:
3939
def __init__(self):
40-
llm = OpenAILLMs()
40+
llm = OpenAILLMs(temperature=0.25)
4141
self.llm = llm.get_llm()
4242
summarisation_llm = OpenAILLMs()
4343
self.summarisation_llm = summarisation_llm.get_llm()
@@ -66,7 +66,7 @@ def call_model(self, state: State, config: RunnableConfig) -> str:
6666
# Adding external student progress and question context details from data queries
6767
question_response_details = config["configurable"].get("question_response_details", "")
6868
if question_response_details:
69-
system_message += f"## Known Question Materials: {question_response_details} \n\n"
69+
system_message += f"## Known Learning Materials: {question_response_details} \n\n"
7070

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

src/agents/informational_agent/informational_prompts.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
informational_role_prompt = """You are a highly skilled and patient AI tutor designed to assist me, the student, in discovering answers and mastering concepts. Your teaching style emphasizes student-centric learning, encouraging deep thinking, active engagement, and confidence building.
88
99
## Teaching Methods:
10-
Step-by-Step Learning: Break complex problems into smaller, manageable parts, solving one step at a time.
10+
Step-by-Step Learning: Break complex problems into smaller, manageable parts, solving one step at a time. Avoid giving the final answer upfront; instead, offer hints or intermediate steps to nudge the student toward the solution. Provide the full answer only when it’s clear the student needs it to move forward. If the student explicitly asks for the answer, direct them to the worked solutions or answer provided below, while encouraging them to engage with the chat for deeper understanding.
1111
Error Analysis: Treat mistakes as learning opportunities by helping students reflect on why they occurred and how to address them.
1212
Active Participation: Encourage students to take an active role in solving problems, providing guidance without overtaking their learning process.
13-
Tailored Feedback: Adapt your explanations, questions, and support to the student's level, needs, and progress.
13+
Tailored Feedback: Adapt your explanations, questions, and support to the student's level, needs, and progress. If the student is close to the solution, provide encouragement or subtle hints. If they seem stuck, gradually increase the specificity of your support.
1414
1515
## Key Qualities:
16+
Awareness: Use the known learning materials to base your responses on.
1617
Patience: Allow students ample time to think, process, and respond without rushing them.
1718
Clarity: Simplify complex ideas into clear, actionable steps.
1819
Encouragement: Celebrate student efforts and achievements to keep motivation high.

src/agents/socratic_agent/socratic_agent.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class State(TypedDict):
3737

3838
class SocraticAgent:
3939
def __init__(self):
40-
llm = OpenAILLMs()
40+
llm = OpenAILLMs(temperature=0.25)
4141
self.llm = llm.get_llm()
4242
summarisation_llm = OpenAILLMs()
4343
self.summarisation_llm = summarisation_llm.get_llm()

src/agents/utils/parse_json_to_prompt.py

+14-12
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,11 @@ def __init__(
9999

100100
# questionAccessInformation type
101101
class CurrentPart:
102-
def __init__(self, id: str = None, position: int = None):
102+
def __init__(self, id: str = None, position: int = None, timeTakenPart: Optional[str] = None, markedDonePart: Optional[str] = None):
103103
self.id = id
104104
self.position = position
105+
self.timeTakenPart = timeTakenPart
106+
self.markedDonePart = markedDonePart
105107

106108
class QuestionAccessInformation:
107109
def __init__(
@@ -138,25 +140,25 @@ def parse_json_to_prompt( questionSubmissionSummary: Optional[List[StudentWorkRe
138140
def format_response_area_details(responseArea: ResponseAreaDetails, studentSummary: List[StudentWorkResponseArea]) -> str:
139141
submissionDetails = "\n".join(
140142
[
141-
f"My Latest Submission: {ra.latestSubmission.submission};\n"
142-
f"My Latest Feedback Received: {ra.latestSubmission.feedback};\n"
143-
f"Total Submissions: {ra.totalSubmissions};\n"
144-
f"Total Wrong Submissions: {ra.totalWrongSubmissions};\n"
143+
f"Latest Response: {ra.latestSubmission.submission};\n"
144+
f"Latest Feedback Received: {ra.latestSubmission.feedback};\n"
145+
f"Total Responses: {ra.totalSubmissions};\n"
146+
f"Total Wrong Responses: {ra.totalWrongSubmissions};\n"
145147
for ra in studentSummary
146148
if ra.publishedResponseAreaId == responseArea.id and ra.latestSubmission
147149
]
148150
)
149151

150152
if not submissionDetails:
151-
submissionDetails = 'My Latest Submission: none made;'
153+
submissionDetails = 'Latest Response: none made;'
152154

153155
return f"""
154156
## Response Area: {responseArea.position + 1}
155157
{f'Area task: What is {responseArea.preResponseText} ?' if responseArea.preResponseText else ''}
156158
(Secret) Expected Answer: {responseArea.answer};
157159
{submissionDetails}"""
158160

159-
def format_part_details(part: PartDetails, currentPartId: str, summary: List[StudentWorkResponseArea]) -> str:
161+
def format_part_details(part: PartDetails, currentPart: CurrentPart, summary: List[StudentWorkResponseArea]) -> str:
160162
if not part or not part.publishedResponseAreas:
161163
return ''
162164

@@ -173,30 +175,30 @@ def format_part_details(part: PartDetails, currentPartId: str, summary: List[Stu
173175
]
174176
) if part.publishedWorkedSolutionSections else f"No worked solutions for part ({convert_index_to_lowercase_letter(part.publishedPartPosition)});"
175177
)
176-
177178
return f"""
178-
# {'[CURRENTLY WORKING ON] ' if currentPartId == part.publishedPartId else ''}Part ({convert_index_to_lowercase_letter(part.publishedPartPosition)}):
179+
# {'[CURRENTLY WORKING ON] ' if currentPart.id == part.publishedPartId else ''}Part ({convert_index_to_lowercase_letter(part.publishedPartPosition)}):
180+
{f"Time spent on this part: {currentPart.timeTakenPart if currentPart.timeTakenPart is not None else 'No recorded duration'}" if currentPart.id == part.publishedPartId else ''}
179181
Part Content: {part.publishedPartContent.strip() if part.publishedPartContent else 'No content'};
180182
{responseAreas}
181183
{f'Final Part Answer: {part.publishedPartAnswerContent}' if part.publishedPartAnswerContent else 'No direct answer'}
182184
{workedSolutions}
183185
"""
184186

185-
questionDetails = f"""This is the question I am currently working on. I am currently working on Part ({convert_index_to_lowercase_letter(questionAccessInformation.currentPart.position)}). 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.
187+
questionDetails = f"""This is the question I am currently working on. I am currently working on Part ({convert_index_to_lowercase_letter(questionAccessInformation.currentPart.position)}). Below, you'll find its details, including the parts of the question, my responses for each response area, and the feedback I received. This information highlights my efforts and progress so far. Use this this information to inform your understanding about the question materials provided to me and my work on them.
186188
Maths equations are in KaTex format, preserve them the same.
187189
188190
# Question: {questionInformation.questionTitle};
189191
Guidance to Solve the Question: {questionInformation.questionGuidance or 'None'};
190192
Description of Question: {questionInformation.questionContent};
191193
Expected Time to Complete the Question: {f'{questionInformation.durationLowerBound} - {questionInformation.durationUpperBound} min;' if questionInformation.durationLowerBound and questionInformation.durationUpperBound else 'No specified duration.'}
192-
Time Spent on the Question This Session: {questionAccessInformation.timeTaken or 'No recorded duration'} {f'since {questionAccessInformation.markedDone}' if questionAccessInformation.markedDone else {f'which is {questionAccessInformation.accessStatus}' if questionAccessInformation.accessStatus else ''}};
194+
Time Spent on the Question today: {questionAccessInformation.timeTaken or 'No recorded duration'} {f'which is {questionAccessInformation.accessStatus}' if questionAccessInformation.accessStatus else ''} {f'{questionAccessInformation.markedDone}' if questionAccessInformation.markedDone else ''};
193195
"""
194196

195197
partsDetails = "\n".join(
196198
[
197199
format_part_details(
198200
part,
199-
questionAccessInformation.currentPart.id,
201+
questionAccessInformation.currentPart,
200202
questionSubmissionSummary
201203
) for part in questionInformation.parts
202204
]

0 commit comments

Comments
 (0)