ngpt 1.1.2__py3-none-any.whl → 1.1.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ngpt/cli.py +1 -2
- {ngpt-1.1.2.dist-info → ngpt-1.1.3.dist-info}/METADATA +89 -34
- ngpt-1.1.3.dist-info/RECORD +9 -0
- ngpt-1.1.2.dist-info/RECORD +0 -9
- {ngpt-1.1.2.dist-info → ngpt-1.1.3.dist-info}/WHEEL +0 -0
- {ngpt-1.1.2.dist-info → ngpt-1.1.3.dist-info}/entry_points.txt +0 -0
- {ngpt-1.1.2.dist-info → ngpt-1.1.3.dist-info}/licenses/LICENSE +0 -0
ngpt/cli.py
CHANGED
@@ -35,11 +35,10 @@ def show_config_help():
|
|
35
35
|
print(" 3. Or set environment variables:")
|
36
36
|
print(" - OPENAI_API_KEY")
|
37
37
|
print(" - OPENAI_BASE_URL")
|
38
|
-
print(" - OPENAI_PROVIDER")
|
39
38
|
print(" - OPENAI_MODEL")
|
40
39
|
|
41
40
|
print(" 4. Or provide command line arguments:")
|
42
|
-
print(" ngpt --api-key your-key --base-url https://api.example.com \"Your prompt\"")
|
41
|
+
print(" ngpt --api-key your-key --base-url https://api.example.com --model your-model \"Your prompt\"")
|
43
42
|
|
44
43
|
print(" 5. Use --config-index to specify which configuration to use:")
|
45
44
|
print(" ngpt --config-index 1 \"Your prompt\"")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ngpt
|
3
|
-
Version: 1.1.
|
3
|
+
Version: 1.1.3
|
4
4
|
Summary: A lightweight Python CLI and library for interacting with OpenAI-compatible APIs, supporting both official and self-hosted LLM endpoints.
|
5
5
|
Project-URL: Homepage, https://github.com/nazdridoy/ngpt
|
6
6
|
Project-URL: Repository, https://github.com/nazdridoy/ngpt
|
@@ -33,19 +33,51 @@ Description-Content-Type: text/markdown
|
|
33
33
|
|
34
34
|
# nGPT
|
35
35
|
|
36
|
+
[](https://pypi.org/project/ngpt/)
|
37
|
+
[](https://opensource.org/licenses/MIT)
|
38
|
+
[](https://pypi.org/project/ngpt/)
|
39
|
+
|
36
40
|
A lightweight Python CLI and library for interacting with OpenAI-compatible APIs, supporting both official and self-hosted LLM endpoints.
|
37
41
|
|
42
|
+
## Table of Contents
|
43
|
+
- [Quick Start](#quick-start)
|
44
|
+
- [Features](#features)
|
45
|
+
- [Installation](#installation)
|
46
|
+
- [Usage](#usage)
|
47
|
+
- [CLI Tool](#as-a-cli-tool)
|
48
|
+
- [Python Library](#as-a-library)
|
49
|
+
- [Configuration](#configuration)
|
50
|
+
- [Command Line Options](#command-line-options)
|
51
|
+
- [Configuration File](#configuration-file)
|
52
|
+
- [Configuration Priority](#configuration-priority)
|
53
|
+
- [License](#license)
|
54
|
+
|
55
|
+
## Quick Start
|
56
|
+
|
57
|
+
```bash
|
58
|
+
# Install
|
59
|
+
pip install ngpt
|
60
|
+
|
61
|
+
# Chat with default settings
|
62
|
+
ngpt "Tell me about quantum computing"
|
63
|
+
|
64
|
+
# Generate code
|
65
|
+
ngpt --code "function to calculate the Fibonacci sequence"
|
66
|
+
|
67
|
+
# Generate and execute shell commands
|
68
|
+
ngpt --shell "list all files in the current directory"
|
69
|
+
```
|
70
|
+
|
38
71
|
## Features
|
39
72
|
|
40
|
-
- Dual
|
41
|
-
- Minimal dependencies
|
42
|
-
-
|
43
|
-
- Streaming
|
44
|
-
- Web
|
45
|
-
- Cross-platform
|
46
|
-
-
|
47
|
-
|
48
|
-
- Code generation with clean output
|
73
|
+
- ✅ **Dual Mode**: Use as a CLI tool or import as a Python library
|
74
|
+
- 🪶 **Lightweight**: Minimal dependencies (just `requests`)
|
75
|
+
- 🔄 **API Flexibility**: Works with OpenAI, Ollama, Groq, and any compatible endpoint
|
76
|
+
- 📊 **Streaming Responses**: Real-time output for better user experience
|
77
|
+
- 🔍 **Web Search**: Integrated with compatible API endpoints
|
78
|
+
- ⚙️ **Multiple Configurations**: Cross-platform config system supporting different profiles
|
79
|
+
- 💻 **Shell Command Generation**: OS-aware command execution
|
80
|
+
- 🧩 **Clean Code Generation**: Output code without markdown or explanations
|
49
81
|
|
50
82
|
## Installation
|
51
83
|
|
@@ -53,6 +85,8 @@ A lightweight Python CLI and library for interacting with OpenAI-compatible APIs
|
|
53
85
|
pip install ngpt
|
54
86
|
```
|
55
87
|
|
88
|
+
Requires Python 3.8 or newer.
|
89
|
+
|
56
90
|
## Usage
|
57
91
|
|
58
92
|
### As a CLI Tool
|
@@ -71,15 +105,19 @@ ngpt --show-config
|
|
71
105
|
ngpt --show-config --all
|
72
106
|
|
73
107
|
# With custom options
|
74
|
-
ngpt --api-key your-key --base-url http://your-endpoint "Hello"
|
108
|
+
ngpt --api-key your-key --base-url http://your-endpoint --model your-model "Hello"
|
75
109
|
|
76
110
|
# Enable web search (if your API endpoint supports it)
|
77
111
|
ngpt --web-search "What's the latest news about AI?"
|
78
112
|
|
79
113
|
# Generate and execute shell commands (using -s or --shell flag)
|
114
|
+
# OS-aware: generates appropriate commands for Windows, macOS, or Linux
|
80
115
|
ngpt -s "list all files in current directory"
|
116
|
+
# On Windows generates: dir
|
117
|
+
# On Linux/macOS generates: ls -la
|
81
118
|
|
82
|
-
# Generate code (using -c or --code flag)
|
119
|
+
# Generate clean code (using -c or --code flag)
|
120
|
+
# Returns only code without markdown formatting or explanations
|
83
121
|
ngpt -c "create a python function that calculates fibonacci numbers"
|
84
122
|
```
|
85
123
|
|
@@ -115,20 +153,51 @@ command = client.generate_shell_command("list all files")
|
|
115
153
|
code = client.generate_code("create a python function that calculates fibonacci numbers")
|
116
154
|
```
|
117
155
|
|
156
|
+
#### Advanced Library Usage
|
157
|
+
|
158
|
+
```python
|
159
|
+
# Stream responses
|
160
|
+
for chunk in client.chat("Write a poem about Python", stream=True):
|
161
|
+
print(chunk, end="", flush=True)
|
162
|
+
|
163
|
+
# Customize system prompt
|
164
|
+
response = client.chat(
|
165
|
+
"Explain quantum computing",
|
166
|
+
system_prompt="You are a quantum physics professor. Explain complex concepts simply."
|
167
|
+
)
|
168
|
+
|
169
|
+
# OS-aware shell commands
|
170
|
+
# Automatically generates appropriate commands for the current OS
|
171
|
+
command = client.generate_shell_command("find large files")
|
172
|
+
import subprocess
|
173
|
+
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
174
|
+
print(result.stdout)
|
175
|
+
|
176
|
+
# Clean code generation
|
177
|
+
# Returns only code without markdown or explanations
|
178
|
+
code = client.generate_code("function that converts Celsius to Fahrenheit")
|
179
|
+
print(code)
|
180
|
+
```
|
181
|
+
|
118
182
|
## Configuration
|
119
183
|
|
120
184
|
### Command Line Options
|
121
185
|
|
122
186
|
You can configure the client using the following options:
|
123
187
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
188
|
+
| Option | Description |
|
189
|
+
|--------|-------------|
|
190
|
+
| `--api-key` | API key for the service |
|
191
|
+
| `--base-url` | Base URL for the API |
|
192
|
+
| `--model` | Model to use |
|
193
|
+
| `--web-search` | Enable web search capability |
|
194
|
+
| `--config` | Path to a custom configuration file |
|
195
|
+
| `--config-index` | Index of the configuration to use (default: 0) |
|
196
|
+
| `--show-config` | Show configuration details and exit |
|
197
|
+
| `--all` | Used with `--show-config` to display all configurations |
|
198
|
+
| `-s, --shell` | Generate and execute shell commands |
|
199
|
+
| `-c, --code` | Generate clean code output |
|
200
|
+
| `-v, --version` | Show version information |
|
132
201
|
|
133
202
|
### Configuration File
|
134
203
|
|
@@ -173,20 +242,6 @@ nGPT determines configuration values in the following order (highest priority fi
|
|
173
242
|
3. Configuration file (selected by `--config-index`, defaults to index 0)
|
174
243
|
4. Default values
|
175
244
|
|
176
|
-
## Special Features
|
177
|
-
|
178
|
-
### OS-Aware Shell Commands
|
179
|
-
|
180
|
-
Shell command generation is OS-aware, providing appropriate commands for your operating system (Windows, macOS, or Linux) and shell type (bash, powershell, etc.).
|
181
|
-
|
182
|
-
### Clean Code Generation
|
183
|
-
|
184
|
-
Code generation uses an improved prompt that ensures only clean code is returned, without markdown formatting or unnecessary explanations.
|
185
|
-
|
186
|
-
## Implementation Notes
|
187
|
-
|
188
|
-
This library uses direct HTTP requests instead of the OpenAI client library, allowing it to work with custom API endpoints that support additional parameters like `provider` and `web_search`. All parameters are sent directly in the request body, similar to the format shown in the curl example.
|
189
|
-
|
190
245
|
## License
|
191
246
|
|
192
247
|
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
@@ -0,0 +1,9 @@
|
|
1
|
+
ngpt/__init__.py,sha256=ehInP9w0MZlS1vZ1g6Cm4YE1ftmgF72CnEddQ3Le9n4,368
|
2
|
+
ngpt/cli.py,sha256=_nu7eY76_y4KQ59cKC91VijVvzSASAaSJI1FFfJ9l04,10655
|
3
|
+
ngpt/client.py,sha256=j7UCX_nkFRQJ_15ynxdu0Tj3HxxsI7Ll4__HdTbD7zE,10400
|
4
|
+
ngpt/config.py,sha256=JWCEp1aMq96i8owi4z_poKigaA_s2UTfzY0fjBM5MoQ,5295
|
5
|
+
ngpt-1.1.3.dist-info/METADATA,sha256=QTx1AssxeYEUlGOUpDdvssIVlvh2Xl8tqp9-a4wXwWs,8002
|
6
|
+
ngpt-1.1.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
7
|
+
ngpt-1.1.3.dist-info/entry_points.txt,sha256=1cnAMujyy34DlOahrJg19lePSnb08bLbkUs_kVerqdk,39
|
8
|
+
ngpt-1.1.3.dist-info/licenses/LICENSE,sha256=mQkpWoADxbHqE0HRefYLJdm7OpdrXBr3vNv5bZ8w72M,1065
|
9
|
+
ngpt-1.1.3.dist-info/RECORD,,
|
ngpt-1.1.2.dist-info/RECORD
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
ngpt/__init__.py,sha256=ehInP9w0MZlS1vZ1g6Cm4YE1ftmgF72CnEddQ3Le9n4,368
|
2
|
-
ngpt/cli.py,sha256=LIXr3NWgdsrddbcYmOxRsWYbNeKNILJZWnIkO7iCSzc,10672
|
3
|
-
ngpt/client.py,sha256=j7UCX_nkFRQJ_15ynxdu0Tj3HxxsI7Ll4__HdTbD7zE,10400
|
4
|
-
ngpt/config.py,sha256=JWCEp1aMq96i8owi4z_poKigaA_s2UTfzY0fjBM5MoQ,5295
|
5
|
-
ngpt-1.1.2.dist-info/METADATA,sha256=GBuRNy3W9JGtdH4NMHriYVOQ2KClYlczYIjmyGcK0xM,6299
|
6
|
-
ngpt-1.1.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
7
|
-
ngpt-1.1.2.dist-info/entry_points.txt,sha256=1cnAMujyy34DlOahrJg19lePSnb08bLbkUs_kVerqdk,39
|
8
|
-
ngpt-1.1.2.dist-info/licenses/LICENSE,sha256=mQkpWoADxbHqE0HRefYLJdm7OpdrXBr3vNv5bZ8w72M,1065
|
9
|
-
ngpt-1.1.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|