hadadrjt commited on
Commit
4a6a19d
·
0 Parent(s):

CLI: Initial.

Browse files
Files changed (6) hide show
  1. .gitattributes +35 -0
  2. README.md +10 -0
  3. assets/bin/ai +97 -0
  4. assets/bin/installer.sh +33 -0
  5. assets/css/style.css +29 -0
  6. index.html +49 -0
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: UltimaX Intelligence CLI
3
+ short_description: Run GPT-4.1 (Nano) on your local terminal for free.
4
+ license: apache-2.0
5
+ emoji: ⚡
6
+ colorFrom: yellow
7
+ colorTo: purple
8
+ sdk: static
9
+ pinned: false
10
+ ---
assets/bin/ai ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ #
3
+ # SPDX-FileCopyrightText: Hadad <[email protected]>
4
+ # SPDX-License-Identifier: Apache-2.0
5
+ #
6
+ # UltimaX Intelligence CLI
7
+ # 0.0.1 version
8
+ #
9
+
10
+ import sys
11
+ import argparse
12
+
13
+ try:
14
+ import pollinations # Provider.
15
+ except ImportError:
16
+ print("Module 'pollinations' not found. Install it with: pip install pollinations pollinations.ai", file=sys.stderr)
17
+ sys.exit(2) # Exit to signal missing dependency.
18
+
19
+ def response(output): # Print non-stream responses.
20
+ try:
21
+ if hasattr(output, "text"): # Handle objects with .text.
22
+ print(output.text) # Print text and return.
23
+ return
24
+ if isinstance(output, dict) and "text" in output: # Handle dicts with 'text'.
25
+ print(output["text"]) # Print dict value and return.
26
+ return
27
+ if isinstance(output, (list, tuple)): # Handle sequences of parts.
28
+ try:
29
+ print("".join(map(str, output))) # Join parts and return.
30
+ return
31
+ except Exception:
32
+ pass # Fall through to fallback.
33
+ except Exception:
34
+ pass # Fall through on any inspection error.
35
+ print(str(output)) # Fallback printing.
36
+
37
+ def main(): # Script entry point.
38
+ parser = argparse.ArgumentParser(description="UltimaX Intelligence")
39
+ parser.add_argument("text", nargs="*", help="Helper for the user input.") # Positional text.
40
+ parser.add_argument("--no-stream", dest="stream", action="store_false", help="Use non-streaming mode.")
41
+ args = parser.parse_args() # Parse flags and positionals.
42
+
43
+ if not args.text: # No positional text given.
44
+ if sys.stdin.isatty(): # Nothing piped in.
45
+ print("Empty input. Request cancelled.", file=sys.stderr) # Immediate cancel on empty invocation.
46
+ sys.exit(1) # Exit to indicate no work done.
47
+ input = sys.stdin.read() # Read piped stdin.
48
+ elif len(args.text) == 1 and args.text[0] == "-": # Explicit stdin sentinel.
49
+ if sys.stdin.isatty(): # No data to read.
50
+ print("Empty input. Request cancelled.", file=sys.stderr) # Cancel when '-' without pipe.
51
+ sys.exit(1) # Exit to indicate no work done.
52
+ input = sys.stdin.read() # Read piped stdin.
53
+ else:
54
+ input = " ".join(args.text) # Join positional pieces.
55
+
56
+ # Reject empty or whitespace-only input.
57
+ if not input or input.strip() == "": # Guard against blanks.
58
+ print("Empty input. Request cancelled.", file=sys.stderr) # Consistent message.
59
+ sys.exit(1) # Exit to indicate no work done.
60
+
61
+ # Build model instance.
62
+ try:
63
+ model = pollinations.Text() # OpenAI: GPT-4.1 (Nano).
64
+ except Exception:
65
+ print("Failed to construct default model.", file=sys.stderr) # High level failure.
66
+ import traceback # Lazy import for error details.
67
+ traceback.print_exc() # Show stack trace for debugging.
68
+ sys.exit(1) # Exit due to setup failure.
69
+
70
+ try:
71
+ if args.stream: # Streaming path.
72
+ for token in model(input, stream=True): # Iterate tokens.
73
+ try:
74
+ if isinstance(token, (str, bytes)): # Strings or bytes.
75
+ print(token.decode() if isinstance(token, bytes) else token, end="", flush=True) # Emit token.
76
+ elif isinstance(token, dict) and "text" in token: # Dict tokens.
77
+ print(token["text"], end="", flush=True) # Emit dict text.
78
+ elif hasattr(token, "text"): # Object tokens with .text.
79
+ print(token.text, end="", flush=True) # Emit attribute.
80
+ else:
81
+ print(str(token), end="", flush=True) # Emit generic.
82
+ except Exception:
83
+ print(str(token), end="", flush=True) # Fallback on token error.
84
+ print() # Newline after stream completes.
85
+ else: # Non-streaming path.
86
+ output = model(input, stream=False) # Get full response.
87
+ response(output) # Print.
88
+ except KeyboardInterrupt:
89
+ print("\nInterrupted by user.", file=sys.stderr) # User aborted.
90
+ sys.exit(130) # Conventional Ctrl+C code.
91
+ except Exception:
92
+ print("Error while calling the model:", file=sys.stderr) # Runtime failure.
93
+ import traceback # Lazy import for details.
94
+ traceback.print_exc() # Show stack trace.
95
+ sys.exit(1) # Exit on runtime error.
96
+
97
+ main() # Run immediately for terminal use.
assets/bin/installer.sh ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ #
3
+ # SPDX-FileCopyrightText: Hadad <[email protected]>
4
+ # SPDX-License-Identifier: Apache-2.0
5
+ #
6
+
7
+ echo "Welcome to UltimaX Intelligence CLI"
8
+ echo ""
9
+ echo ""
10
+ echo "Installing required Python packages..."
11
+ pip install pollinations pollinations.ai --upgrade
12
+ echo "Installation complete."
13
+ echo ""
14
+ echo ""
15
+ echo "Downloading the main script..."
16
+ wget https://huggingface.co/spaces/umint/cli/raw/main/assets/bin/ai
17
+ echo "Download complete."
18
+ echo ""
19
+ echo ""
20
+ echo "Setting executable permission..."
21
+ chmod a+x ai
22
+ echo "Permission set."
23
+ echo ""
24
+ echo ""
25
+ echo "Removing installer script..."
26
+ rm installer.sh
27
+ echo "Done."
28
+ echo ""
29
+ echo ""
30
+ echo "Example usage:"
31
+ echo "./ai Your message here"
32
+ echo ""
33
+ echo ""
assets/css/style.css ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * SPDX-FileCopyrightText: Hadad <[email protected]>
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ body {
7
+ font-family: Arial, sans-serif;
8
+ line-height: 1.6;
9
+ margin: 20px;
10
+ background-color: #f9f9f9;
11
+ }
12
+
13
+ h1, h2, h3 {
14
+ color: #333;
15
+ }
16
+
17
+ code, pre {
18
+ background-color: #eee;
19
+ padding: 6px 10px;
20
+ border-radius: 4px;
21
+ }
22
+
23
+ pre {
24
+ overflow-x: auto;
25
+ }
26
+
27
+ .section {
28
+ margin-bottom: 30px;
29
+ }
index.html ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ SPDX-FileCopyrightText: Hadad <[email protected]>
3
+ SPDX-License-Identifier: Apache-2.0
4
+ -->
5
+
6
+ <!DOCTYPE html>
7
+ <html lang="en">
8
+ <head>
9
+ <meta charset="UTF-8">
10
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
11
+ <link rel="stylesheet" href="assets/css/style.css" />
12
+ </head>
13
+ <body>
14
+ <div class="section">
15
+ <p>
16
+ This script provides a simple command-line interface
17
+ for the UltimaX Intelligence CLI.
18
+ It supports streaming and non-streaming modes.
19
+ Compatible for Linux/MacOS/Windows (WSL)/Termux.
20
+ </p>
21
+ </div>
22
+
23
+ <div class="section">
24
+ <h2>Installation</h2>
25
+ <p>Make sure Python 3 is installed and then install the required dependency:</p>
26
+ <pre><code>
27
+ # Download the installer script
28
+ wget https://huggingface.co/spaces/umint/cli/raw/main/assets/bin/installer.sh
29
+
30
+ # Set proper permission
31
+ chmod a+x installer.sh
32
+
33
+ # Run the installer script
34
+ ./installer.sh
35
+ </code></pre>
36
+ </div>
37
+
38
+ <div class="section">
39
+ <h2>Usage</h2>
40
+ <pre><code>
41
+ # Streaming (default)
42
+ ./ai Tell me about yourself.
43
+
44
+ # Non-streaming mode
45
+ ./ai Tell me about yourself. --no-stream
46
+ </code></pre>
47
+ </div>
48
+ </body>
49
+ </html>