gorilla-llm / gorilla-cli Goto Github PK
View Code? Open in Web Editor NEWLLMs for your CLI
Home Page: https://gorilla.cs.berkeley.edu/
License: Apache License 2.0
LLMs for your CLI
Home Page: https://gorilla.cs.berkeley.edu/
License: Apache License 2.0
Traceback (most recent call last):
File "D:\Conda\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "D:\Conda\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "D:\Conda\Scripts\gorilla.exe_main.py", line 7, in
File "D:\Conda\lib\site-packages\go_cli.py", line 158, in main
exit_condition = execute_command(selected_command)
File "D:\Conda\lib\site-packages\go_cli.py", line 123, in execute_command
error_msg = process.stderr.decode("utf-8")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0
xb2 in position 6: invalid start byte
Unable to generate userid: Command '['git', 'config', '--global', 'user.email']' returned non-zero exit status 1.
I did the pip install gorilla-cli
and the command is not found. Installer is maybe not working?
~ $ python3 --version
Python 3.11.3
~ $ pip --version
pip 23.1.2
$ sw_vers
ProductName: macOS
ProductVersion: 13.4.1
$ arch
arm64
When trying to execute the Gorilla command to generate random characters into a file, I encountered an issue with the command not being recognized.
make sure to change the path
]
(myVenv) C:\path\to\your\project\Gorilla>gorilla generate 100 random characters into a file called test.txt
🦍 Welcome to Gorilla. Use arrows to select
» echo "100" | sudo tee -a test.txt
cat /dev/urandom | tr -dc 'a-z0-9' | head -c 100 > test.txt
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 100 | head -n 1 > test.txt
: #Do nothing
xxx
can be different for different prompts:
🦍 echo "100" | sudo tee -a test.txt
'sudo' is not recognized as an internal or external command,
operable program or batch file.
Below is an example when selecting another option:
🦍 cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 100 | head -n 1 > test.txt
'cat' is not recognized as an internal or external command,
operable program or batch file.
The command should successfully generate 100 random characters into a file called test.txt
.
The command prompts are not recognized, resulting in an error message.
This issue seems to be specific to Windows, as the commands mentioned are typical Unix/Linux commands that are not recognized in the Windows environment.
Please let me know if there's anything else I can assist you with!
It looks like selected commands are being sent back over http. Given the somewhat sensitive nature of the information that could be contained, it would be good to see it using HTTPS.
~ $ gorilla how do i shutdown this server?
Unable to generate userid: Command '['git', 'config', '--global', 'user.email']' returned non-zero exit status 1.
~ $ git config --global user.email e-mail-address # fixes it
Some of the suggestions returned by gorilla overflow the space available on the screen.
Sometimes it breaks lines and adds \ for continuation. Sometimes it does not do this and makes long lines.
Could the line size be made more consistent?
When gorilla is suggesting a shell command, it could end a line after about 70 chars and add a \ for continuation.
Other contexts have their own line-continuation requirements.
Since this is a matter of preference and there is no single correct way, it suggests a config file or command line switches.
I have a NextJS project with several .tsx
files needing translation, so:
gorilla 'parse every .tsx file under ./src, extract all strings , substitute them by {t("translationKey.targetKey")} and put the strings in locales/en/translation.json'
Would this work?
Otherwise, how to extend gorilla
in order to understand and potentially accomplish this task?
thx.
Thank you for this very interesting project. Is backend code also going open source?
Currently whatever command is selected is not added to the command history of the shell.
This makes rerunning commands a pain and I have to instead rerun the gorilla command instead.
It would be very nice to have the command executed directly on the shell in a way that adds it to the command history.
Thank you for the project and the paper; seems good work !
In the paper it is clear how you created the api database(ApiBench). I wondered that how did you do it for bash ?
Thanks again, in advance!
The CLI setup / ~/.gorilla-cli-userid
creation logic tries to call git config --global user.email
:
Line 81 in ec4153a
This can fail if the user hasn't configured this git-config value (or if the user doesn't have git installed).
This results in an exception, but we continue to write the cli-userid file anyway (it's empty at this point):
Line 81 in ec4153a
Then on subsequent invocations, the (empty) cli-userid file is read, and this assertion block prevents progress without meaningful recourse:
Line 76 in ec4153a
Suggested fixes / ideas:
git config
invocation to fail Line 81 in ec4153a
Line 76 in ec4153a
Thanks for making this project and making it available open-source. I hope this bug report is helpful.
> python --version
Python 3.11.3
> gorilla help
Traceback (most recent call last):
File "/opt/homebrew/bin/gorilla", line 5, in <module>
from go_cli import main
File "/opt/homebrew/lib/python3.11/site-packages/go_cli.py", line 24, in <module>
import go_questionary
File "/opt/homebrew/lib/python3.11/site-packages/go_questionary/__init__.py", line 2, in <module>
from prompt_toolkit.validation import Validator, ValidationError
File "/opt/homebrew/lib/python3.11/site-packages/prompt_toolkit/__init__.py", line 16, in <module>
from .interface import CommandLineInterface
File "/opt/homebrew/lib/python3.11/site-packages/prompt_toolkit/interface.py", line 19, in <module>
from .application import Application, AbortAction
File "/opt/homebrew/lib/python3.11/site-packages/prompt_toolkit/application.py", line 8, in <module>
from .key_binding.bindings.basic import load_basic_bindings
File "/opt/homebrew/lib/python3.11/site-packages/prompt_toolkit/key_binding/bindings/basic.py", line 9, in <module>
from prompt_toolkit.renderer import HeightIsUnknownError
File "/opt/homebrew/lib/python3.11/site-packages/prompt_toolkit/renderer.py", line 11, in <module>
from prompt_toolkit.styles import Style
File "/opt/homebrew/lib/python3.11/site-packages/prompt_toolkit/styles/__init__.py", line 8, in <module>
from .from_dict import *
File "/opt/homebrew/lib/python3.11/site-packages/prompt_toolkit/styles/from_dict.py", line 9, in <module>
from collections import Mapping
ImportError: cannot import name 'Mapping' from 'collections' (/opt/homebrew/Cellar/[email protected]/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/collections/__init__.py)
Hi!
Trying the Gorilla CLI on my Git Bash instance on Windows 10 I get the error:
Traceback (most recent call last):
File "G:\Programs\conda\lib\site-packages\halo\halo.py", line 410, in _render_frame
self._write(output)
File "G:\Programs\conda\lib\site-packages\halo\halo.py", line 305, in _write
self._stream.write(s)
File "G:\Programs\conda\lib\site-packages\colorama\ansitowin32.py", line 47, in write
self.__convertor.write(text)
File "G:\Programs\conda\lib\site-packages\colorama\ansitowin32.py", line 177, in write
self.write_and_convert(text)
File "G:\Programs\conda\lib\site-packages\colorama\ansitowin32.py", line 205, in write_and_convert
self.write_plain_text(text, cursor, len(text))
File "G:\Programs\conda\lib\site-packages\colorama\ansitowin32.py", line 210, in write_plain_text
self.wrapped.write(text[start:end])
File "G:\Programs\conda\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f98d' in position 3: character maps to <undefined>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "G:\Programs\conda\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "G:\Programs\conda\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "G:\Programs\conda\Scripts\gorilla.exe\__main__.py", line 7, in <module>
File "G:\Programs\conda\lib\site-packages\go_cli.py", line 136, in main
with Halo(text="\U0001f98d Loading", spinner="dots"):
File "G:\Programs\conda\lib\site-packages\halo\halo.py", line 120, in __enter__
return self.start()
File "G:\Programs\conda\lib\site-packages\halo\halo.py", line 498, in start
self._render_frame()
File "G:\Programs\conda\lib\site-packages\halo\halo.py", line 412, in _render_frame
self._write(encode_utf_8_text(output))
File "G:\Programs\conda\lib\site-packages\halo\halo.py", line 305, in _write
self._stream.write(s)
File "G:\Programs\conda\lib\site-packages\colorama\ansitowin32.py", line 47, in write
self.__convertor.write(text)
File "G:\Programs\conda\lib\site-packages\colorama\ansitowin32.py", line 177, in write
self.write_and_convert(text)
File "G:\Programs\conda\lib\site-packages\colorama\ansitowin32.py", line 199, in write_and_convert
text = self.convert_osc(text)
File "G:\Programs\conda\lib\site-packages\colorama\ansitowin32.py", line 261, in convert_osc
for match in self.ANSI_OSC_RE.finditer(text):
TypeError: cannot use a string pattern on a bytes-like object
I can see that character '\U0001f98d' is the 🦍emoji if I'm not mistaken, and it seems that this can't be handled properly in the command line
As a user, I'd like to prompt Gorilla with a tech stack idea on say AWS. Gorilla would reply with the code scaffolding, a GitHub repo, the code pipeline, cloud formation templates, etc.
Is this inside or outside the scope of Gorilla?
gorilla I want to list all files in the current directory
Traceback (most recent call last):
File "/opt/homebrew/bin/gorilla", line 8, in <module>
sys.exit(main())
^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/go_cli.py", line 128, in main
user_id = get_user_id()
^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/go_cli.py", line 76, in get_user_id
assert user_id != ""
^^^^^^^^^^^^^
AssertionError
Which user id should I write before using Gorilla CLI ?
Would it be expensive to train with mpt 8k? Can you provide an mpt 8k model?
Raw command works while running through gorilla doesn't seem to understand the variable value:
$ gorilla print first 20 chars of a SCREENSHOT_B64 variable
🦍 echo $SCREENSHOT_B64 | cut -c 1-20
$ echo $SCREENSHOT_B64 | cut -c 1-20
iVBORw0KGgoAAAANSUhE
Unable to generate userid: [WinError 2] The system cannot find the file specified
I tried to run gorilla in offline server wiithout internet and got
⠦ LoadingServer is unreachable. Try updating Gorilla-CLI with 'pip install --upgrade gorilla-cli'
Can you please confirm does internet required for tool? Thanks
Hello, how can I disable the spinner. I want to make a query without the loading spinner. Or where can I delete the line that adds that spinner?
https://github.com/weaviate/Verba might be a good area
Begin a gorilla
command and instead of selecting one of the options, hit Ctrl-C
.
=> an stack trace is displayed on screen:
❯ gorilla list subdirectories recursively
🦍 Welcome to Gorilla. Use arrows to select
Cancelled by user
Traceback (most recent call last):
File "/Users/philip/Projects/gorilla-cli/.venv/bin/gorilla", line 8, in <module>
sys.exit(main())
^^^^^^
File "/Users/philip/Projects/gorilla-cli/.venv/lib/python3.11/site-packages/go_cli.py", line 159, in main
exit_condition = execute_command(selected_command)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/philip/Projects/gorilla-cli/.venv/lib/python3.11/site-packages/go_cli.py", line 123, in execute_command
process = subprocess.run(cmd, shell=True, stderr=subprocess.PIPE)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/philip/.pyenv/versions/3.11.4/lib/python3.11/subprocess.py", line 548, in run
with Popen(*popenargs, **kwargs) as process:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/philip/.pyenv/versions/3.11.4/lib/python3.11/subprocess.py", line 1026, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Users/philip/.pyenv/versions/3.11.4/lib/python3.11/subprocess.py", line 1808, in _execute_child
args = list(args)
^^^^^^^^^^
TypeError: 'NoneType' object is not iterable
I realize "Do nothing" would be the preferred exit method. Ctrl-C
would be faster.
The fix is as simple as adding, before exit_condition = execute_command(selected_command)
in go_cli.py
a if not selected_command: return
/ 🦍 LoadingServer is unreachable.
Try updating Gorilla-CLI with 'pip install --upgrade gorilla-cli'
It appears server is not reachable.
Is it possible to deploy this locally on my on box and use my own keys for Models ? @ShishirPatil
My input command was
gorilla 'i want to run this sentence through an LLM'
And the output is
Unable to generate userid: Command '['git', 'config', '--global', 'user.email']' returned non-zero exit status 1.
Please run 'go <command>' again. If the problem persists, please raise an issue: https://github.com/gorilla-llm/gorilla-cli/issues/new?title=Problem%20with%20generating%20userid%3A%20Command%20%27%5B%27git%27%2C%20%27config%27%2C%20%27--global%27%2C%20%27user.email%27%5D%27%20returned%20non-zero%20exit%20status%201.&body=Unable%20to%20generate%20userid%3A%20Command%20%27%5B%27git%27%2C%20%27config%27%2C%20%27--global%27%2C%20%27user.email%27%5D%27%20returned%20non-zero%20exit%20status%201.
Unable to write userid file: local variable 'user_id' referenced before assignment
Try deleting USERID_FILE and run 'go <command>' again. If the problem persists, please raise an issue: https://github.com/gorilla-llm/gorilla-cli/issues/new?title=Problem%20with%20userid%20file&body=Unable%20to%20write%20userid%20file%3A%20local%20variable%20%27user_id%27%20referenced%20before%20assignment
I tried logging in using git config user.email
and git config user.name
to no avail.
Hello, great cli app!
Would it be possible to release the inference API source code if not already done, to be able to self host the inference API?
Regards.
Traceback (most recent call last):
File "C:\Users\Admin\anaconda3\Scripts\gorilla-script.py", line 33, in <module>
sys.exit(load_entry_point('gorilla-cli', 'console_scripts', 'gorilla')())
File "C:\Users\Admin\anaconda3\Scripts\gorilla-script.py", line 22, in importlib_load_entry_point
for entry_point in distribution(dist_name).entry_points
File "C:\Users\Admin\anaconda3\lib\importlib\metadata\__init__.py", line 969, in distribution
return Distribution.from_name(distribution_name)
File "C:\Users\Admin\anaconda3\lib\importlib\metadata\__init__.py", line 548, in from_name
raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: No package metadata was found for gorilla-cli
def main():
dockerfile_dir = os.path.expanduser('~/anaconda3/lib/python3.10/site-packages')
image_name = 'go_cli_sandbox'
def build_docker_image():
try:
completed_process = subprocess.run(['docker', 'images', '-q', image_name],/
stdout=subprocess.PIPE, check=True, text=True)
# Check if image ID is present in the output
if completed_process.stdout.strip():
print(f"{image_name} already exists. Skipping build.")
return
except subprocess.CalledProcessError as e:
print(f"Error checking Docker images: {e}", file=sys.stderr)
sys.exit(1)
try:
subprocess.run(['docker', 'build', '-t', image_name, dockerfile_dir], check=True)
print(f"Successfully built {image_name}")
except subprocess.CalledProcessError as e:
print(f"Error building Docker image: {e}", file=sys.stderr)
sys.exit(1)
def execute_command(cmd):
build_docker_image()
try:
process = subprocess.run(['docker', 'run', '--rm', image_name, 'bash', '-c', cmd],stderr=subprocess.PIPE, check=False)
except subprocess.CalledProcessError as e:
print(f"Error running command in Docker container: {e}", file=sys.stder
sys.exit(1)
return str(process.returncode)
# ... [other parts of the code] ...
Dockerfile
FROM python:3.9-slim # Install required packages
RUN apt-get update && \
apt-get install -y sudo && \
apt-get install -y sudo git && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* # Create a user with no password and no shell
RUN useradd -m -s /usr/sbin/nologin sandboxuser # Copy the go_cli.py and any other required files to the container
# Set the working directory
WORKDIR /app
COPY go_cli.py /app/go_cli.py
COPY go_questionary /app/go_questionary
# Install Python dependencies RUN
pip install requests halo prompt_toolkit typing
# Run the go_cli.py script as the entrypoint
ENTRYPOINT ["python", "go_cli.py"]
USER sandboxuser
def main():
venv_path = os.path.expanduser('~/gorilla_venv')
restricted_user = 'sandboxuser' # The restricted user
def create_virtual_environment():
if os.path.exists(venv_path):
shutil.rmtree(venv_path) # Remove the existing virtual environment
venv.create(venv_path, with_pip=True)
def install_dependencies():
pip = os.path.join(venv_path, 'bin', 'pip')
subprocess.run([pip, 'install', 'requests', 'halo', 'prompt_toolkit', 'typing'],
stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL,
check=True)
def execute_command(cmd):
create_virtual_environment() # Create a new virtual environment
install_dependencies() # Install the necessary dependencies
python = os.path.join(venv_path, 'bin', 'python')
try:
process = subprocess.run(['sudo', '-u', restricted_user, python, '-c', cmd], check=True)
except subprocess.CalledProcessError as e:
print(f"Error running command as {restricted_user}: {e}", file=sys.stderr)
sys.exit(1)
However, I am aware that this only provides isolation with an environment, but not python interpreter and the rest of the system.
RestrictedPython
packagefrom RestrictedPython import compile_restricted, safe_globals
source_code =
"""
"""
byte_code = compile_restricted(source_code, filename='<inline code>', mode='exec')
exec(byte_code, safe_globals)
I get this error message when trying to install with pip
Collecting gorilla-cli
Downloading gorilla-cli-0.0.8.tar.gz (27 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [8 lines of output]
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "C:\Temp\pip-install-snfk72nj\gorilla-cli_57007838e78a490fb36390faa9c4a90c\setup.py", line 24, in <module>
long_description=open("README.md").read(),
File "C:\Users\adrian\scoop\apps\python\current\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 1245: character maps to <undefined>
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
Great project! Two UX suggestions when I ctrl-c after suggestions are shown:
(base) ➜ ~ gorilla gcloud change project
🦍 Welcome to Gorilla. Use arrows to select
Cancelled by user
Traceback (most recent call last):
File "/Users/romilb/tools/anaconda3/bin/gorilla", line 8, in <module>
sys.exit(main())
File "/Users/romilb/tools/anaconda3/lib/python3.9/site-packages/go_cli.py", line 155, in main
exit_condition = execute_command(selected_command)
File "/Users/romilb/tools/anaconda3/lib/python3.9/site-packages/go_cli.py", line 119, in execute_command
process = subprocess.run(cmd, shell=True, stderr=subprocess.PIPE)
File "/Users/romilb/tools/anaconda3/lib/python3.9/subprocess.py", line 505, in run
with Popen(*popenargs, **kwargs) as process:
File "/Users/romilb/tools/anaconda3/lib/python3.9/subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Users/romilb/tools/anaconda3/lib/python3.9/subprocess.py", line 1680, in _execute_child
args = list(args)
TypeError: 'NoneType' object is not iterable
Hi,
Gorilla-CLI fuses the capabilities of various Language Learning Models (LLMs) like Gorilla LLM, OpenAI's GPT-4, Claude v1, and others to present a user-friendly command-line interface.
Does it mean user queries are submitted to GPT4(OpenAI) or Claudev1(Anthropic) ?
Can I select or opt for Gorilla only inference ?
Can user be provided option with setting up Gorilla model on local setup ? Is there plan to release Gorilla model checkpoints ?
After installing Gorilla, I attempted to generate a file, but encountered the following error:
Unable to generate userid: Command '['git', 'config', '--global', 'user.email']' returned non-zero exit status 1
Solution:
Upon investigation, it was found that the error was caused by the absence of a configured user email in the global Git settings. To resolve this, I exported the user_id variable, which enabled Gorilla to function correctly.
Hey guys,
Thought this project was neat but realized it wasn't available on the AUR.
I went ahead and created a AUR package for this, check it out if you're interested.
https://aur.archlinux.org/packages/python-gorilla-cli
I'd prefer to not have to maintain this but will if no one else steps up. Hope someone finds this useful!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.