Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rtmt.py - pop gives the error when there are two message in the queue #73

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions app/backend/rtmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,12 @@ async def _process_message_to_client(self, msg: str, client_ws: web.WebSocketRes
})
if "response" in message:
replace = False
for i, output in enumerate(reversed(message["response"]["output"])):
# Iterate in reverse while calculating the correct index
for reverse_index, output in enumerate(reversed(message["response"]["output"])):
if output["type"] == "function_call":
message["response"]["output"].pop(i)
original_index = output_len - 1 - reverse_index # Map reversed index to the original
print("Len of message[response][output]:", output_len, ", output:", message["response"]["output"])
message["response"]["output"].pop(original_index)
replace = True
if replace:
updated_message = json.dumps(message)
Expand Down