gitbito / CLI

Bito CLI (Command Line Interface) provides a command line interface to the Bito AI chat functionality. Over time, CLI will add more functions and new command options to support complex automation and workflows. This is a very early Alpha version. We would love to get your feedback on the new features or improvements.
https://bito.ai
Other
536 stars 74 forks source link

Bito CLI in interactive mode hangs forever #24

Closed basbs closed 1 year ago

basbs commented 1 year ago

Steps to Reproduce:

  1. Type bito in terminal
  2. give the text awk command to print first and last column (or any text).

Expected: Text Response.

Actual The command just waits for the response forever (i waited till 6 minutes and pressed Ctrl+c)

Logs i found in ~/.bitoai/etc/logs/bitocli.log

2023/06/29 16:53:48 default-conf.go:248: Creating Session ID...(success)
2023/06/29 16:53:48 default-conf.go:255: Reading UID...(success)
2023/06/29 16:53:48 default-conf.go:47: Setting Viper...(success)
2023/06/29 16:53:48 models.go:54: ******************************** Pointing at: PROD ********************************************3.0
2023/06/29 16:53:48 default-conf.go:255: Reading UID...(success)
2023/06/29 16:53:49 http-util.go:79: Url=https://bitoai.bito.co/ai/v1/funnyMsg/,status=500,deatis =""
2023/06/29 16:53:49 user-helper.go:160: Configurations settings done...(success)
2023/06/29 16:53:49 root.go:31: Set configurations...(success)

My machine details:

Distributor ID: Ubuntu
Description:    Ubuntu 22.04.2 LTS
Release:    22.04
Codename:   jammy
Linux 5.14.0-1052-oem #59-Ubuntu SMP Fri Sep 9 09:37:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

However, Piping the same text to bito as standard input seems to work. Example:

echo -n "awk command to print first and last colum" | bito

To print the first and last columns using the `awk` command, you can use the following syntax:

shell
awk '{print $1, $NF}' <file>

Here, `$1` represents the first column, and `$NF` represents the last column. Replace `<file>` with the name of the file you want to process.

Logs generated for the above command :

2023/06/29 17:12:14 default-conf.go:248: Creating Session ID...(success)
2023/06/29 17:12:14 default-conf.go:255: Reading UID...(success)
2023/06/29 17:12:14 default-conf.go:47: Setting Viper...(success)
2023/06/29 17:12:14 models.go:54: ******************************** Pointing at: PROD ********************************************3.0
2023/06/29 17:12:14 default-conf.go:255: Reading UID...(success)
2023/06/29 17:12:15 http-util.go:79: Url=https://bitoai.bito.co/ai/v1/funnyMsg/,status=500,deatis =""
2023/06/29 17:12:15 user-helper.go:160: Configurations settings done...(success)

Can someone tell me why the interactive mode doesn't work?

NOTE: I tried to downgrade the bito from 3.3 to 3.0 and also as sudo. But the issue still persists.

macky3099 commented 1 year ago

Hello @basbs

For the interactive mode, after you are done typing what key do you fire to get the response? Is it Enter or Ctrl+D?

Because Bito CLI supports Ctrl+D as the key combination to submit your query and get the response. Pressing Enter will take you to new line to support multi line input.

bitoandy commented 1 year ago

@basbs ,

As @macky3099 pointed out, Bito CLI supports multiline input, To signal to Bito CLI that you are done with your input/query you need to press CTRL+D after which CLI will start processing your input and provide you an answer.

basbs commented 1 year ago

Gotcha!!! should've read the README carefully :). Thanks for pointing it out @bitoandy and @macky3099. Now it works. My another question is, was there a reason to choose the same functionality for quit as well? My personal opinion is,for the quit, it would be better to have it typed \quit or something else and hit ENTER rather than pressing Ctrl+D. I feel Ctrl+D is little dangerous for this scenario. Because sometimes if someone use it twice thinking that the program is not responding, they may end up closing their terminal itself. (or just enforce users to use Ctrl+c all the time)

bitoandy commented 1 year ago

Hi @basbs ,

As CTRL+D is used to terminate the input and start processing, we just check if user wants to quit by seeing if user only mentioned quit after user terminated the input to decide to quit. Thus the behavior.

Thanks for the suggestion provided regarding quit, we will look into this and will update the implementation in future releases.

bitoandy commented 1 year ago

@basbs , I am closing the issue, in case you want to keep it open you can re-open it.