Skip to content

Commit

Permalink
fix: Not crash if LLM fails to return "customer_response" var
Browse files Browse the repository at this point in the history
GPT-3.5 Turbo often forget to include it.
  • Loading branch information
clemlesne committed Jan 15, 2024
1 parent fd588bc commit 5ce906a
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,22 +680,42 @@ async def gpt_chat(call: CallModel) -> ActionModel:
elif name == IndentAction.UPDATED_CLAIM:
intent = IndentAction.UPDATED_CLAIM
parameters = json.loads(arguments)
content += parameters[customer_response_prop] + " "

if not customer_response_prop in parameters:
_logger.warn(
f"Missing {customer_response_prop} prop in {arguments}, please fix this!"
)
else:
content += parameters[customer_response_prop] + " "

setattr(call.claim, parameters["field"], parameters["value"])
model.content = f"Updated claim field \"{parameters['field']}\" with value \"{parameters['value']}\"."

elif name == IndentAction.NEW_CLAIM:
intent = IndentAction.NEW_CLAIM
parameters = json.loads(arguments)
content += parameters[customer_response_prop] + " "

if not customer_response_prop in parameters:
_logger.warn(
f"Missing {customer_response_prop} prop in {arguments}, please fix this!"
)
else:
content += parameters[customer_response_prop] + " "

call.claim = ClaimModel()
call.reminders = []
model.content = "Claim and reminders created reset."

elif name == IndentAction.NEW_OR_UPDATED_REMINDER:
intent = IndentAction.NEW_OR_UPDATED_REMINDER
parameters = json.loads(arguments)
content += parameters[customer_response_prop] + " "

if not customer_response_prop in parameters:
_logger.warn(
f"Missing {customer_response_prop} prop in {arguments}, please fix this!"
)
else:
content += parameters[customer_response_prop] + " "

updated = False
for reminder in call.reminders:
Expand Down

0 comments on commit 5ce906a

Please sign in to comment.