Spaces:
Running
Running
File size: 2,323 Bytes
991dd3b 7f5eec6 991dd3b 7f5eec6 991dd3b 7f5eec6 991dd3b 7f5eec6 991dd3b 7f5eec6 991dd3b 7f5eec6 991dd3b 7f5eec6 991dd3b 7f5eec6 991dd3b 7f5eec6 991dd3b 7f5eec6 991dd3b 7f5eec6 991dd3b 7f5eec6 991dd3b 7f5eec6 991dd3b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
#### 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."
```
|