PowerShell / ProjectMercury

An interactive shell to work with AI-powered assistance providers
MIT License
43 stars 11 forks source link

Interpreter Agent PR #107

Closed jshigetomi closed 4 months ago

jshigetomi commented 5 months ago

PR Summary

PR Context

jshigetomi commented 4 months ago

Left some comments. Not done yet. Will be reviewing the Model code.

A feedback from Steve: image

You display powershell: and python: for the code about to run to let the user know what code that is. The feedback is to make that a comment of the corresponding language. For both powershell and python, a comment starts with #, so it would be nice if you can change the above display to be like:

# powershell
az --version

and similarly, for any python code, make it # python instead of python:

I made the changes in the function calling model. However, the text based model, the code is displayed in the AI's response. I will modify the response rules and see how well that works.

jshigetomi commented 4 months ago

https://github.com/PowerShell/ShellCopilot/pull/107#discussion_r1575405573

When user cancels code execution Run will throw a canceled exception. This is caught in CodeExecutionService and returns a "Code run cancelled message" to be logged in chat history.

In subprocesslanguage, the code continues to run and populates OutputQueue and done could be set or not set.

On the next code execution cycle, OutputQueue is cleared and Done is reset. This prevents old code output.

However If the code is taking a long time, like find all prime numbers between 1 and 2 million and you cancelled out of this. This would still be running by the next execution cycle... There must be a way to send CTRL ^C to the process to stop the code from running. Will look into this further...

jshigetomi commented 4 months ago

-Added KeyboardInterrupt detection in HandleErrorOutput method for python process. -Ctrl^C is forwarded to pwsh process and will cancel the code. No detection seems to be needed. -Now long running code like "print all primes from 1 to 2 million" can be cancelled for python and powershell. -Ctrl^C immediately stops execution and renders "Code run cancelled". -Because code execution immediately stopped, no more output is expected.

StevenBucher98 commented 4 months ago

@jshigetomi please add your README.md file to this PR so I can add comments/review

jshigetomi commented 4 months ago

@StevenBucher98 ReadMe Added

jshigetomi commented 4 months ago

Thank you Dongbo for combing through my code and teaching me all kinds of tips and tricks!

Thank you Steven for the robust ReadMe updates!

I appreciate ya'll taking your time with my project.