Skip to content

Commit 8523088

Browse files
authored
fix equations rendering, get gemini to work (#3)
* try fix max_retries from google call * try fix llm with retry * test set versions for packages * revert testing changes * update readme to match template * updated index * new $ equations prompt * fix equations generated
1 parent 78bbd0e commit 8523088

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

index.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,38 @@
11
import json
22
try:
33
from .src.module import chat_module
4-
from .src.agents.utils.types import JsonType
54
except ImportError:
65
from src.module import chat_module
7-
from src.agents.utils.types import JsonType
86

9-
def handler(event: JsonType, context):
7+
def handler(event, context):
108
"""
119
Lambda handler function
12-
Args:
13-
event (JsonType): The AWS Lambda event received by the gateway.
14-
context (Any): The AWS Lambda context object.
15-
1610
"""
1711
# Log the input event for debugging purposes
18-
print("Received event:", json.dumps(event, indent=2))
12+
# print("Received event:", " ".join(json.dumps(event, indent=2).splitlines()))
1913

20-
if "body" not in event:
21-
return {
22-
"statusCode": 400,
23-
"body": "Missing 'body' key in event. Please confirm the key in the json body."
24-
}
25-
body = json.loads(event["body"])
26-
27-
if "message" not in body:
14+
if "body" in event:
15+
try:
16+
event = json.loads(event["body"])
17+
except json.JSONDecodeError:
18+
return {
19+
"statusCode": 400,
20+
"body": "Invalid JSON format in the body or body not found. Please check the input."
21+
}
22+
23+
if "message" not in event:
2824
return {
2925
"statusCode": 400,
3026
"body": "Missing 'message' key in event. Please confirm the key in the json body."
3127
}
32-
if "params" not in body:
28+
if "params" not in event:
3329
return {
3430
"statusCode": 400,
3531
"body": "Missing 'params' key in event. Please confirm the key in the json body. Make sure it contains the necessary conversation_id."
3632
}
3733

38-
message = body["message"]
39-
params = body["params"]
34+
message = event.get("message", None)
35+
params = event.get("params", None)
4036

4137
try:
4238
chatbot_response = chat_module(message, params)
@@ -49,7 +45,10 @@ def handler(event: JsonType, context):
4945
# Create a response
5046
response = {
5147
"statusCode": 200,
52-
"body": json.dumps(chatbot_response)
48+
"body": chatbot_response
5349
}
5450

51+
# Log the response for debugging purposes
52+
print("Returning response:", " ".join(json.dumps(response, indent=2).splitlines()))
53+
5554
return response

src/agents/utils/prompt_context_templates.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ def format_question_header(
7373
- Description: {content}
7474
{duration_text}
7575
76-
> Note: Mathematical equations are in KaTeX format, preserve them the same. Use British English spellings.
77-
76+
> Note: Mathematical equations are in KaTeX format, preserve them the same. Ensure mathematical equations are surrounded by one '$' for in-line equations and '$$' for block equations.
77+
Example: '$E=mc^2$' or '$$E=mc^2$$'.
78+
Use British English spellings.
7879
---
7980
"""
8081

0 commit comments

Comments
 (0)