open-interpreter icon indicating copy to clipboard operation
open-interpreter copied to clipboard

create new cli entry point and update poetry script

Open MikeBirdTech opened this issue 1 year ago • 2 comments

Describe the changes you have made:

  • created a new file cli.py that is the terminal interface entry point
  • removed the logic that served this from core.py
  • updated poetry script to call the new function

I tested it as a CLI app and as an imported library and both worked as expected without changing the user experience. Since the user experience didn't change, I didn't update any docs but if the inner workings are documented publicly, let me know and I can update them.

Reference any relevant issues (e.g. "Fixes #000"):

Pre-Submission Checklist (optional but appreciated):

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

OS Tests (optional but appreciated):

  • [ ] Tested on Windows
  • [x] Tested on MacOS
  • [ ] Tested on Linux

Note on tests, in order to test that importing still works, I did:

import sys
sys.path.insert(0, "/Users/mike/Code/open-interpreter")

from interpreter import interpreter


def run(prompt, key):
    interpreter.llm.api_key = key
    output = interpreter.chat(prompt, stream=True)
    for chunk in output:
        print(chunk)


run("hello", "sk-XXXX")

MikeBirdTech avatar Jan 19 '24 15:01 MikeBirdTech

Oh, nice! Appreciate you reading that comment and fixing this Mike.

Is there any way we can put it into the /terminal_interface instead of /interpreter? Can poetry handle that..? Let me know if not, I'll still merge.

I really struggle with relative import stuff so thank you for separating it out— this already makes much more sense to me.

KillianLucas avatar Jan 19 '24 20:01 KillianLucas

Oh, nice! Appreciate you reading that comment and fixing this Mike.

Is there any way we can put it into the /terminal_interface instead of /interpreter? Can poetry handle that..? Let me know if not, I'll still merge.

I really struggle with relative import stuff so thank you for separating it out— this already makes much more sense to me.

Done!

Does the file/function naming still make sense to you now that it's within the terminal_interface directory?

MikeBirdTech avatar Jan 19 '24 20:01 MikeBirdTech

Nice! This makes me realize we should just fold this into start_terminal_interface— that should be our poetry entry-point, and it should create interpreter just as this beautiful cli.py does. I'll accept the PR then make that change.

Great work, merging now!

KillianLucas avatar Jan 20 '24 01:01 KillianLucas