Skip to content

Commit

Permalink
Put default values for response json in mechscriptbot (#47)
Browse files Browse the repository at this point in the history
Co-authored-by: laurasgkadri98 <[email protected]>
  • Loading branch information
karthik-sridhar-123 and laurasgkadri98 authored Jan 28, 2025
1 parent 13f3945 commit 552b40f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/allie/flowkit/endpoints/mechscriptbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,18 @@ async def triggermechscriptbot(request: MechScriptBotRequest, api_key: str = Hea

response_dict = requests.get(url=url, json=request_dict_copy).json()

output = f"```{response_dict['output']}"
output = f"```{response_dict.get('output', '')}"

human_new_mem, ai_new_mem = tuple(response_dict["new_memory"])
human_new_mem, ai_new_mem = tuple(response_dict.get("new_memory", []))
updated_human_memory = request.full_human_memory + [human_new_mem]
updated_ai_memory = request.full_ai_memory + [ai_new_mem]

new_variables_list = [f"{var_name}:{var_type}" for var_name, var_type in (response_dict["new_variables"]).items()]
new_variables_list = [
f"{var_name}:{var_type}" for var_name, var_type in (response_dict.get("new_variables", {})).items()
]
updated_variables = request.full_variables + new_variables_list

updated_mechanical_objects = request.full_mechanical_objects + response_dict["new_mechanical_objects"]
updated_mechanical_objects = request.full_mechanical_objects + response_dict.get("new_mechanical_objects", [])

return MechScriptBotResponse(
output=output,
Expand Down

0 comments on commit 552b40f

Please sign in to comment.