GithubHelp home page GithubHelp logo

Comments (9)

AndreVianna avatar AndreVianna commented on August 27, 2024

Thanks Tom.

The CTRL+D and CTRL+Z are a quick temporary solution for the multiline input my intention is to use CTRL+ENTER to submit for both Linux and Windows.

But I will look into it to see how to fix it on windows.
I have been using the Linux environment and so far, it seems to work there.

from codingcrew.

twelsh37 avatar twelsh37 commented on August 27, 2024

Let me take a look at that. I have both windows and linux (Ubuntu) desktops so can test on both.

I will try and get a fix today

from codingcrew.

twelsh37 avatar twelsh37 commented on August 27, 2024

I took another look at this.
On windows you need to press CTRL +Z and then ENTER and it will end the multiline input. I am guessing it works fine on Linux as is.

i did play around a bit with utils.py and specifically the read_text() function.

I came upon with the following which takes 'Shift+ENTER' as a terminator but I then had issues displaying text. probably just some silliness on my end.

i did need to import two additional libs
Keyboard
readchar

Here is the commented code I came up with. maybe you can salvage something from it.

def read_text() -> Iterable[str]:
    """
    Allows the user to enter a multiline string ending by pressing Shift+Enter.
    Returns:
        list[str]: The multiline string entered by the user.
    """
    print("Start typing your text. Press 'Shift+Enter' to finish.")
    multiline = list[str]()
    line = ''
    while True:
    
        # If shift+enter is pressed
        if keyboard.is_pressed('shift+enter'):  
            break
        else:
            c = readchar.readchar()
    
            # print character as soon as it's typed
            print(c, end="", flush=True)  
            line += c
    
            # Enter key
            if c == '\n':  
    
                # Shift wasn't pressed, move to next line and continue typing on console
                multiline.append(line.rstrip())
                line = ''
    
    # Add the last line if it does not end with '\n'
    multiline.append(line.rstrip())  
    
    # Debug to see whats returned
    print(f'DEBUG1: {multiline}')
    return multiline

from codingcrew.

AndreVianna avatar AndreVianna commented on August 27, 2024

from codingcrew.

twelsh37 avatar twelsh37 commented on August 27, 2024

from codingcrew.

AndreVianna avatar AndreVianna commented on August 27, 2024

Can you create a Pull Request from your fork into the dev branch of the original?
I can do a code review for that.

from codingcrew.

AndreVianna avatar AndreVianna commented on August 27, 2024

Oh. I've just tried the code on Linux.
Here is what I've got:

Traceback (most recent call last):
  File "/home/andre/projects/coding-crew/src/main.py", line 16, in <module>
    wkf.invoke({}, debug=is_debugging)
  File "/home/andre/.local/lib/python3.11/site-packages/langgraph/pregel/__init__.py", line 1249, in invoke
    for chunk in self.stream(
  File "/home/andre/.local/lib/python3.11/site-packages/langgraph/pregel/__init__.py", line 835, in stream
    _panic_or_proceed(done, inflight, step)
  File "/home/andre/.local/lib/python3.11/site-packages/langgraph/pregel/__init__.py", line 1338, in _panic_or_proceed
    raise exc
  File "/home/andre/.conda/envs/coding-crew/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/andre/.local/lib/python3.11/site-packages/langgraph/pregel/retry.py", line 66, in run_with_retry
    task.proc.invoke(task.input, task.config)
  File "/home/andre/.local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 2499, in invoke
    input = step.invoke(
            ^^^^^^^^^^^^
  File "/home/andre/.local/lib/python3.11/site-packages/langgraph/utils.py", line 89, in invoke
    ret = context.run(self.func, input, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/andre/projects/coding-crew/src/nodes/start_project.py", line 63, in create
    lines += read_text()
             ^^^^^^^^^^^
  File "/home/andre/projects/coding-crew/src/utils.py", line 202, in read_text
    key = keyboard.read_key()
          ^^^^^^^^^^^^^^^^^^^
  File "/home/andre/.conda/envs/coding-crew/lib/python3.11/site-packages/keyboard/__init__.py", line 935, in read_key
    event = read_event(suppress)
            ^^^^^^^^^^^^^^^^^^^^
  File "/home/andre/.conda/envs/coding-crew/lib/python3.11/site-packages/keyboard/__init__.py", line 924, in read_event
    hooked = hook(queue.put, suppress=suppress)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/andre/.conda/envs/coding-crew/lib/python3.11/site-packages/keyboard/__init__.py", line 461, in hook
    append(callback)
  File "/home/andre/.conda/envs/coding-crew/lib/python3.11/site-packages/keyboard/_generic.py", line 67, in add_handler
    self.start_if_necessary()
  File "/home/andre/.conda/envs/coding-crew/lib/python3.11/site-packages/keyboard/_generic.py", line 35, in start_if_necessary
    self.init()
  File "/home/andre/.conda/envs/coding-crew/lib/python3.11/site-packages/keyboard/__init__.py", line 196, in init
    _os_keyboard.init()
  File "/home/andre/.conda/envs/coding-crew/lib/python3.11/site-packages/keyboard/_nixkeyboard.py", line 113, in init
    build_device()
  File "/home/andre/.conda/envs/coding-crew/lib/python3.11/site-packages/keyboard/_nixkeyboard.py", line 109, in build_device
    ensure_root()
  File "/home/andre/.conda/envs/coding-crew/lib/python3.11/site-packages/keyboard/_nixcommon.py", line 174, in ensure_root
    raise ImportError('You must be root to use this library on linux.')
ImportError: You must be root to use this library on linux.

This error:
*ImportError: You must be root to use this library on linux.
is from the keyboard.

I've tried that before but I forgot.

from codingcrew.

twelsh37 avatar twelsh37 commented on August 27, 2024

from codingcrew.

AndreVianna avatar AndreVianna commented on August 27, 2024

Added a code that works with CTRL+ENTER with both Windows and Linux.
It is committed in dev and will be in main in the next release.

from codingcrew.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.