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

Chat: feature to cancel active runs #1404

Merged
merged 1 commit into from
Jun 24, 2024

Conversation

adityaomar3
Copy link
Contributor

This PR adds a cancel feature to cancel the active run on Open AI, i.e. it helps cancelling the active prompt given by user.

@rmackay9
Copy link
Contributor

Thanks for this, I've tested and found a few little issues but once you fix those up (and re-test yourself) then I'll re-test and get this merged in

@adityaomar3
Copy link
Contributor Author

HI! @rmackay9 take a look, I have updated the fixes as told, I tested it, You please take a test too, if there is any edge cases missing or changes needed.


if (self.latest_run.status == "cancelled"):
return "cancelled successfully"
elif reply_messages is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker but the "elif" could be just an "if" because of the return one line higher

@rmackay9
Copy link
Contributor

Thanks for this. By the way, for future PRs could you specify what testing has been done? This is helpful for the reviewer.

I tested this and it works. I saw one bit of odd behaviour (see below) in which I cancelled a command, "arm and takeoff to 20m" and then successfully cancelled the command but then when I put in an innocuous command a moment later ("helo" <-- was meant to be "hello") it completed the cancelled command. I'm pretty sure this is an issue on the OpenAI side though and it didn't happen the next time. Let's just keep an eye on this potential issue.
image

@adityaomar3
Copy link
Contributor Author

Sure @rmackay9 thanks for the review, next time onwards I will surely add testing cases, reports from my side for a better review and tests.

Sometimes it does not cancel, maybe the reason is code latency, for some prompts(mostly in which function calling is not used) responses are generated by OpenAI very fast, while status being "in progress" when the code reaches cancel part it is already completed.

Comment on lines +108 to +109
if (run_status != "completed" and run_status != "cancelled" and
run_status != "cancelling"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (run_status != "completed" and run_status != "cancelled" and
run_status != "cancelling"):
if run_status not in ["completed", "cancelled", "cancelling"]:

@peterbarker peterbarker merged commit e1b0654 into ArduPilot:master Jun 24, 2024
2 checks passed
@peterbarker
Copy link
Contributor

Merged, thanks!

@adityaomar3 adityaomar3 deleted the cancel_active_run branch June 26, 2024 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants