Spaces:
Runtime error
Runtime error
| #### Installation | |
| ```bash | |
| #!/bin/bash | |
| # Linux/Android (Termux)/MacOS/Windows | |
| install_python() { | |
| if ! command -v python3 &>/dev/null; then | |
| if [[ "$OSTYPE" == "linux-gnu"* ]]; then | |
| apt update | |
| apt install python3 python3-pip -q -y | |
| elif [[ "$OSTYPE" == "darwin"* ]]; then | |
| if ! command -v brew &>/dev/null; then | |
| /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
| fi | |
| brew install python | |
| elif [[ "$OSTYPE" == "cygwin" ]]; then | |
| echo "Using Cygwin, please install Python manually." | |
| elif [[ "$OSTYPE" == "msys" ]]; then | |
| echo "Windows detected. Please install Python from python.org or using the Windows Store." | |
| exit 1 | |
| fi | |
| else | |
| echo "Python 3 already installed!" | |
| fi | |
| } | |
| install_pip() { | |
| if ! command -v pip3 &>/dev/null; then | |
| if [[ "$OSTYPE" == "linux-gnu"* || "$OSTYPE" == "darwin"* ]]; then | |
| curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py | |
| python3 get-pip.py | |
| rm get-pip.py | |
| elif [[ "$OSTYPE" == "msys"* ]]; then | |
| echo "Please make sure pip is installed on Windows. Install pip manually if needed." | |
| fi | |
| else | |
| echo "pip already installed!" | |
| fi | |
| } | |
| install_libraries() { | |
| pip3 install gradio_client rich --upgrade | |
| } | |
| install_python | |
| install_pip | |
| install_libraries | |
| echo "Installation complete! Python, pip, and required packages are installed." | |
| ``` | |
| #### Create JARVIS script. | |
| ```bash | |
| nano jarvis | |
| # If windows user create file manually. | |
| ``` | |
| ```python | |
| #!/usr/bin/env python3 | |
| import sys | |
| from gradio_client import Client | |
| from rich.console import Console | |
| from rich.markdown import Markdown | |
| console = Console() | |
| jarvis = Client("hadadrjt/ai") | |
| input = " ".join(sys.argv[1:]) if len(sys.argv) > 1 else "Hi!" | |
| result = jarvis.predict(multi_input={"text": input}, api_name="/api") | |
| responses = result[0][0][1] | |
| markdown = Markdown(responses) | |
| console.print(markdown) | |
| ``` | |
| ```bash | |
| chmod a+x jarvis | |
| # Windows users set permissions to 755 according with linux. | |
| ``` | |
| ### Run | |
| ```bash | |
| ./jarvis "Your message here." | |
| ``` | |
| #### Linux User's | |
| ```bash | |
| # Bonus for more flexible. | |
| sudo mv jarvis /bin/ai | |
| ``` | |
| ```bash | |
| ai "Your message here." | |
| ``` | |