Skip to content

Commit dea304a

Browse files
committed
fix: optional response areas support & gemini
1 parent d43b0eb commit dea304a

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

Diff for: index.py

+3
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,7 @@ def handler(event, context):
3939
"body": chatbot_response
4040
}
4141

42+
# Log the response for debugging purposes
43+
print("Returning response:", json.dumps(response, indent=2))
44+
4245
return response

Diff for: src/agents/informational_agent/informational_agent.py

+1-1
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 = GoogleAILLMs()
4141
self.llm = llm.get_llm()
4242
summarisation_llm = OpenAILLMs()
4343
self.summarisation_llm = summarisation_llm.get_llm()

Diff for: src/agents/utils/parse_json_to_prompt.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ def parse_json_to_prompt( questionSubmissionSummary: Optional[List[StudentWorkRe
142142
questionInformation = QuestionDetails(**questionInformation)
143143
questionAccessInformation = QuestionAccessInformation(**questionAccessInformation)
144144

145-
if not questionSubmissionSummary or not questionInformation or not questionAccessInformation:
146-
return None
145+
if not questionInformation or not questionAccessInformation:
146+
return "There must have been an error in fetching the question details. So ask me about the question I am working on such that you can still help me."
147147

148148
def format_response_area_details(responseArea: ResponseAreaDetails, studentSummary: List[StudentWorkResponseArea]) -> str:
149149
submissionDetails = "\n".join(
@@ -163,7 +163,7 @@ def format_response_area_details(responseArea: ResponseAreaDetails, studentSumma
163163
return f"""
164164
## Response Area: {responseArea.position + 1}
165165
{f'Area task: What is {responseArea.preResponseText} ?' if responseArea.preResponseText else ''}
166-
(Secret) Expected Answer: {responseArea.answer};
166+
(Secret - not to be shared) Expected Answer: {responseArea.answer};
167167
{submissionDetails}"""
168168

169169
def format_part_details(part: PartDetails, currentPart: CurrentPart, summary: List[StudentWorkResponseArea]) -> str:
@@ -188,7 +188,7 @@ def format_part_details(part: PartDetails, currentPart: CurrentPart, summary: Li
188188
{f"Time spent on this part: {currentPart.timeTakenPart if currentPart.timeTakenPart is not None else 'No recorded duration'}" if currentPart.id == part.publishedPartId else ''}
189189
Part Content: {part.publishedPartContent.strip() if part.publishedPartContent else 'No content'};
190190
{responseAreas}
191-
{f'Final Part Answer: {part.publishedPartAnswerContent}' if part.publishedPartAnswerContent else 'No direct answer'}
191+
{f'Final Part Answer: {part.publishedPartAnswerContent}' if part.publishedPartAnswerContent else 'No direct answer for this part.'}
192192
{workedSolutions}
193193
"""
194194

Diff for: src/module.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,16 @@ def chat_module(message: Any, params: Params) -> Result:
5757
question_submission_summary = question_response_details["questionSubmissionSummary"] if "questionSubmissionSummary" in question_response_details else []
5858
question_information = question_response_details["questionInformation"] if "questionInformation" in question_response_details else {}
5959
question_access_information = question_response_details["questionAccessInformation"] if "questionAccessInformation" in question_response_details else {}
60-
question_response_details_prompt = parse_json_to_prompt(
61-
question_submission_summary,
62-
question_information,
63-
question_access_information
64-
)
60+
try:
61+
question_response_details_prompt = parse_json_to_prompt(
62+
question_submission_summary,
63+
question_information,
64+
question_access_information
65+
)
66+
print("INFO:: ", question_response_details_prompt)
67+
except Exception as e:
68+
print("ERROR:: ", e)
69+
raise Exception("Internal Error: The question response details could not be parsed.")
6570
if "agent_type" in params:
6671
agent_type = params["agent_type"]
6772
if "conversation_id" in params:

0 commit comments

Comments
 (0)