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

Streaming Out OpenInterpreter's Output + Trigger (Y/N) Remotely #1259

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

fire17
Copy link

@fire17 fire17 commented May 8, 2024

Describe the changes you have made:

This PR Adds the following Abilities:

### 1. Streaming Out all of OpenInterpreter's Output (to another UI for example)
### 2. Remotely Triggering (Y/N) Confirmation Input
        2.2 Allows to Manually Revise The Code Before Executuion
### 3. Request OI to make changes directly from the confirmation input (Y/N/Other), 
            Answers (Other than Y/N) are treated as User Messages

Reference any relevant issues:

Fixes #419 and allows Operation of OI from another GUI

Snapshots from MagicLLight which uses stream_out to get OI's output and async_input to trigger OI's (Y/N/Other) confirmation input

image
Screen Shot 2024-05-08 at 22 08 01
Screen Shot 2024-04-28 at 13 43 07
Screen Shot 2024-04-29 at 20 24 03
Screen Shot 2024-04-29 at 21 15 54
Screen Shot 2024-04-29 at 23 16 53
Screen Shot 2024-04-27 at 22 08 33
MagicLLight code coming soon to a repo near you

This PR will help others Integrate and build on top of OpenInterpreter

You can stream out all the output from Open Interpreter by adding stream_output=function in an interpreter.chat() call (optional).

You can also trigger OpenInterpreter's (Y/N) Confirmation Input REMOTELY by passing async_input={"input":None, "code_revision":None} changing the dict['input'] will trigger the (Y/N) confirmation, place your answer there

Additionally, you can pass New Code to dict['code_revision'] and it will be executed instead of the last codeblock (usefull for manual editing)

## ↓ THIS FUNCTION IS CALLED ON ALL OI'S OUTPUTS
def stream_out_hook(partial, debug = False, *a, **kw):
    ''' THIS FUNCTION PROCESSES ALL THE OUTPUTS FROM OPEN INTERPRETER '''
    if debug: print("STREAMING OUT! ",partial)
    # Replace this function with one that will send the output to YOUR APPLICATION

## ↓ THIS IS OBJECT BEING WATCHED FOR TRIGGERING INPUT
async_input_data = {"input":None, "code_revision":None}
## ↑ CHANGING async_input_data["input"] WILL TRIGGER OI'S (Y/N/OTHER) CONFIRMATION INPUT

interpreter.chat(stream_out = stream_out_hook, async_input = async_input_data)

For a more comprehensive & full example, please checkout examples/stream_out.py


Pre-Submission Checklist (optional but appreciated):

  • [v] I have included relevant documentation updates (stored in /docs)
  • [v] I have read docs/CONTRIBUTING.md
  • [v] I have read docs/ROADMAP.md

OS Tests (optional but appreciated):

  • [v] Tested on MacOS ( only added pythonic code, should be the same on all platforms)

Made sure to make the code well documented and clean :)
Thanks a lot and all the best! 🌈

Tami and others added 6 commits May 7, 2024 21:23
… = myFunction) to process all of OI's output
… (Y/N/changes) from External process, Enabled Manual Code Changes, Enabled Make Changes Before Running (with ai) - Pre-Cleanup
…(Y/N/changes) from External process, Enabled Manual Code Changes, Enabled Make Changes Before Running (with ai) - Cleanup Done
…(Y/N/changes) from External process, Enabled Manual Code Changes, Enabled Make Changes Before Running (with ai) - Cleanup Done! Added Example/stream_out.py
@hossain666
Copy link

↓ THIS FUNCTION IS CALLED ON ALL OI'S OUTPUTS

def stream_out_hook(partial, debug = False, *a, **kw):
''' THIS FUNCTION PROCESSES ALL THE OUTPUTS FROM OPEN INTERPRETER '''
if debug: print("STREAMING OUT! ",partial)
# Replace this function with one that will send the output to YOUR APPLICATION

↓ THIS IS OBJECT BEING WATCHED FOR TRIGGERING INPUT

async_input_data = {"input":None, "code_revision":None}

↑ CHANGING async_input_data["input"] WILL TRIGGER OI'S (Y/N/OTHER) CONFIRMATION INPUT

interpreter.chat(stream_out = stream_out_hook, async_input = async_input_data)

@fire17
Copy link
Author

fire17 commented May 8, 2024

Hi @KillianLucas :)
This PR's tldr is:

  1. Adds hook to stream output (without needing to call chat() as generator)
  2. Adds Ability to Remotely Trigger (Y/N/Other) Confirmation Input()
    2.2 Allows users to Manually Revise The Code Before Executuion
  3. Request OI to make changes directly from the confirmation input (Y/N/Other), added as User Message and runs llm again

Please let me know what you think about MagicLLight, and about this PR, I think it will really help others build on top of OpenInterpreter.

I currently can't publish MagicLLight with OI as a requirement until this PR is pushed, so I would love it if we could get this merged :)

Thanks a lot and all the best! 🌸

PS - would love to get an interview when possible 😇

Copy link

@hossain666 hossain666 left a comment

Choose a reason for hiding this comment

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

interpreter/core/core.py

@fire17 fire17 mentioned this pull request May 9, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to hook into the Text Stream
2 participants