Skip to content

Commit

Permalink
Merge pull request #21 from marcburnie/fix/null-history-case
Browse files Browse the repository at this point in the history
fix for null history case
  • Loading branch information
rstrahan authored Nov 30, 2023
2 parents 8286966 + 9622fa7 commit 3a2ed33
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions lambdas/qna_bot_qbusiness_lambdahook/src/lambdahook.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,19 @@

def get_amazonq_response(prompt, context, amazonq_userid):
print(f"get_amazonq_response: prompt={prompt}, app_id={AMAZONQ_APP_ID}, context={context}")
input = {
"applicationId": AMAZONQ_APP_ID,
"userMessage": prompt,
"userId": amazonq_userid
}
if context:
input = {
"applicationId": AMAZONQ_APP_ID,
"conversationId": context["conversationId"],
"parentMessageId": context["parentMessageId"],
"userMessage": prompt,
"userId": amazonq_userid
}
if context["conversationId"]:
input["conversationId"] = context["conversationId"]
if context["parentMessageId"]:
input["parentMessageId"] = context["parentMessageId"]
else:
input = {
"applicationId": AMAZONQ_APP_ID,
"userMessage": prompt,
"userId": amazonq_userid,
"clientToken": str(uuid.uuid4())
}
input["clientToken"] = str(uuid.uuid4())

print("Amazon Q Input: ", json.dumps(input))
try:
resp = qbusiness_client.chat_sync(**input)
Expand Down

0 comments on commit 3a2ed33

Please sign in to comment.