Skip to content

Commit

Permalink
Milestone 5
Browse files Browse the repository at this point in the history
  • Loading branch information
motica1 authored Sep 26, 2024
1 parent a5e2cc6 commit f6699cf
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,16 @@ async def on_message(message: cl.Message):
if hasattr(movie_functions, function_name):
function_to_call = getattr(movie_functions, function_name)

expected_args = inspect.signature(function_to_call).parameters.keys()
adjusted_args = {k: v for k, v in function_args.items() if k in expected_args}
expected_args = list(inspect.signature(function_to_call).parameters.keys())
adjusted_args = {}
for k, v in function_args.items():
if k in expected_args:
adjusted_args[k] = v
else:
print(f"Unexpected argument: {k}")
print(f"Expected arguments: {expected_args}")
print(f"Adjusted arguments: {adjusted_args}")


try:
if inspect.iscoroutinefunction(function_to_call):
Expand All @@ -118,6 +126,12 @@ async def on_message(message: cl.Message):
"name": function_name,
"content": function_response
})

if function_name.__eq__("buy_ticket"):
message_history.append({
"role": "system",
"content": "Show user the ticket details and Confirm the details with the user before purchasing the ticket"
})
except Exception as e:
error_message = f"Error calling function {function_name}: {str(e)}"
message_history.append({
Expand Down

0 comments on commit f6699cf

Please sign in to comment.