gateforge-sdk 0.1.0__tar.gz
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.
- gateforge_sdk-0.1.0/.env.example +6 -0
- gateforge_sdk-0.1.0/.gitignore +48 -0
- gateforge_sdk-0.1.0/.pypirc.example +12 -0
- gateforge_sdk-0.1.0/INSTALL.md +225 -0
- gateforge_sdk-0.1.0/LICENSE +37 -0
- gateforge_sdk-0.1.0/MANIFEST.in +8 -0
- gateforge_sdk-0.1.0/PKG-INFO +365 -0
- gateforge_sdk-0.1.0/PUBLISHING.md +175 -0
- gateforge_sdk-0.1.0/PUBLISH_NOW.md +199 -0
- gateforge_sdk-0.1.0/README.md +323 -0
- gateforge_sdk-0.1.0/gateforge/__init__.py +58 -0
- gateforge_sdk-0.1.0/gateforge/client.py +119 -0
- gateforge_sdk-0.1.0/gateforge/config.py +38 -0
- gateforge_sdk-0.1.0/gateforge/metrics.py +25 -0
- gateforge_sdk-0.1.0/gateforge/pii.py +46 -0
- gateforge_sdk-0.1.0/gateforge/providers/__init__.py +0 -0
- gateforge_sdk-0.1.0/gateforge/providers/anthropic.py +59 -0
- gateforge_sdk-0.1.0/gateforge/providers/gemini.py +70 -0
- gateforge_sdk-0.1.0/gateforge/providers/openai.py +50 -0
- gateforge_sdk-0.1.0/gateforge/response.py +14 -0
- gateforge_sdk-0.1.0/pyproject.toml +47 -0
- gateforge_sdk-0.1.0/tests/__init__.py +0 -0
- gateforge_sdk-0.1.0/tests/test_metrics.py +69 -0
- gateforge_sdk-0.1.0/tests/test_pii.py +59 -0
- gateforge_sdk-0.1.0/tests/test_providers.py +96 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
develop-eggs/
|
|
9
|
+
dist/
|
|
10
|
+
downloads/
|
|
11
|
+
eggs/
|
|
12
|
+
.eggs/
|
|
13
|
+
lib/
|
|
14
|
+
lib64/
|
|
15
|
+
parts/
|
|
16
|
+
sdist/
|
|
17
|
+
var/
|
|
18
|
+
wheels/
|
|
19
|
+
*.egg-info/
|
|
20
|
+
.installed.cfg
|
|
21
|
+
*.egg
|
|
22
|
+
|
|
23
|
+
# Virtual environments
|
|
24
|
+
venv/
|
|
25
|
+
env/
|
|
26
|
+
ENV/
|
|
27
|
+
.venv
|
|
28
|
+
|
|
29
|
+
# IDE
|
|
30
|
+
.vscode/
|
|
31
|
+
.idea/
|
|
32
|
+
*.swp
|
|
33
|
+
*.swo
|
|
34
|
+
*~
|
|
35
|
+
|
|
36
|
+
# Tests
|
|
37
|
+
.pytest_cache/
|
|
38
|
+
.coverage
|
|
39
|
+
htmlcov/
|
|
40
|
+
*.cover
|
|
41
|
+
|
|
42
|
+
# Environment
|
|
43
|
+
.env
|
|
44
|
+
.env.local
|
|
45
|
+
|
|
46
|
+
# Build artifacts
|
|
47
|
+
*.whl
|
|
48
|
+
*.tar.gz
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
[pypi]
|
|
2
|
+
username = __token__
|
|
3
|
+
password = pypi-YOUR_API_TOKEN_HERE
|
|
4
|
+
|
|
5
|
+
# To use this file:
|
|
6
|
+
# 1. Rename to .pypirc (without .example)
|
|
7
|
+
# 2. Move to your home directory: %USERPROFILE%\.pypirc
|
|
8
|
+
# 3. Get your token from: https://pypi.org/manage/account/token/
|
|
9
|
+
# 4. Replace YOUR_API_TOKEN_HERE with your actual token
|
|
10
|
+
|
|
11
|
+
# Or you can upload directly with:
|
|
12
|
+
# python -m twine upload dist/* --username __token__ --password pypi-YOUR_TOKEN
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# Instalación del SDK Gateforge
|
|
2
|
+
|
|
3
|
+
## 📦 El SDK ya está construido y listo para usar
|
|
4
|
+
|
|
5
|
+
✅ **Archivos generados:**
|
|
6
|
+
- `gateforge-0.1.0-py3-none-any.whl` (wheel - recomendado)
|
|
7
|
+
- `gateforge-0.1.0.tar.gz` (source distribution)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 🚀 Opciones de Instalación
|
|
12
|
+
|
|
13
|
+
### 1. **Instalación Local (Para Testing)**
|
|
14
|
+
|
|
15
|
+
Desde el directorio `observability`:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install gateforge-sdk/dist/gateforge-0.1.0-py3-none-any.whl
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
O con soporte para providers:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install "gateforge-sdk/dist/gateforge-0.1.0-py3-none-any.whl[openai]"
|
|
25
|
+
pip install "gateforge-sdk/dist/gateforge-0.1.0-py3-none-any.whl[all]"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 2. **Instalación Editable (Para Desarrollo)**
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
cd gateforge-sdk
|
|
32
|
+
pip install -e .
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Cualquier cambio en el código se refleja inmediatamente.
|
|
36
|
+
|
|
37
|
+
### 3. **Publicar en PyPI (Producción)** ⭐
|
|
38
|
+
|
|
39
|
+
#### Opción A: PyPI Público (Gratis, Recomendado)
|
|
40
|
+
|
|
41
|
+
1. **Crear cuenta en PyPI:**
|
|
42
|
+
- https://pypi.org/account/register/
|
|
43
|
+
|
|
44
|
+
2. **Crear API token:**
|
|
45
|
+
- https://pypi.org/manage/account/token/
|
|
46
|
+
- Nombre: "Gateforge SDK"
|
|
47
|
+
- Scope: "Entire account"
|
|
48
|
+
|
|
49
|
+
3. **Configurar credenciales:**
|
|
50
|
+
|
|
51
|
+
Windows - Crear `%USERPROFILE%\.pypirc`:
|
|
52
|
+
```ini
|
|
53
|
+
[pypi]
|
|
54
|
+
username = __token__
|
|
55
|
+
password = pypi-TU_TOKEN_AQUI
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
4. **Instalar twine:**
|
|
59
|
+
```bash
|
|
60
|
+
pip install twine
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
5. **Publicar:**
|
|
64
|
+
```bash
|
|
65
|
+
cd gateforge-sdk
|
|
66
|
+
python -m twine upload dist/*
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
6. **Instalar desde PyPI:**
|
|
70
|
+
```bash
|
|
71
|
+
pip install gateforge
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### Opción B: GitHub Releases (Privado/Público)
|
|
75
|
+
|
|
76
|
+
1. **Subir archivos a GitHub Release:**
|
|
77
|
+
- Crear release en GitHub
|
|
78
|
+
- Adjuntar `dist/gateforge-0.1.0-py3-none-any.whl`
|
|
79
|
+
|
|
80
|
+
2. **Instalar desde GitHub:**
|
|
81
|
+
```bash
|
|
82
|
+
pip install https://github.com/tu-usuario/repo/releases/download/v0.1.0/gateforge-0.1.0-py3-none-any.whl
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
#### Opción C: Servidor Privado (Para Empresas)
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# Usando servidor pip interno
|
|
89
|
+
pip install --index-url https://tu-servidor-pip.com gateforge
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 4. **Instalar desde Git (Desarrollo)**
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
pip install git+https://github.com/gateforge/gateforge-sdk.git
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## 🎯 Modelo de Negocio SaaS + Open Source
|
|
101
|
+
|
|
102
|
+
### ✅ Licencia MIT (Open Source)
|
|
103
|
+
|
|
104
|
+
El SDK es **completamente gratis y open source** (MIT license):
|
|
105
|
+
- ✅ Cualquiera puede usar el código
|
|
106
|
+
- ✅ Pueden modificarlo
|
|
107
|
+
- ✅ Pueden redistribuirlo
|
|
108
|
+
- ✅ Pueden usarlo comercialmente
|
|
109
|
+
|
|
110
|
+
### 💰 Monetización mediante SaaS
|
|
111
|
+
|
|
112
|
+
**El SDK requiere cuenta en Gateforge** para funcionar:
|
|
113
|
+
|
|
114
|
+
| Plan | Precio | Requests/mes | Soporte |
|
|
115
|
+
|------|--------|--------------|---------|
|
|
116
|
+
| **Free** | $0 | 1,000 | Community |
|
|
117
|
+
| **Pro** | $29/mo | 100,000 | Email |
|
|
118
|
+
| **Enterprise** | Custom | Ilimitados | Dedicado |
|
|
119
|
+
|
|
120
|
+
**Ingresos vienen de:**
|
|
121
|
+
1. Planes pagos (Pro, Enterprise)
|
|
122
|
+
2. Requests adicionales
|
|
123
|
+
3. Features premium (SSO, audit logs, etc.)
|
|
124
|
+
|
|
125
|
+
**No del SDK**, que es gratis.
|
|
126
|
+
|
|
127
|
+
### 🎯 Por qué funciona este modelo:
|
|
128
|
+
|
|
129
|
+
✅ **Más usuarios** → Open source = mayor adopción
|
|
130
|
+
✅ **Network effect** → Más usuarios = más feedback = mejor producto
|
|
131
|
+
✅ **Trust** → Developers confían en código que pueden ver
|
|
132
|
+
✅ **Lock-in natural** → El SDK solo funciona con api.gateforge.dev
|
|
133
|
+
✅ **Freemium** → Usuarios prueban gratis, luego pagan por más
|
|
134
|
+
|
|
135
|
+
**Ejemplos exitosos:**
|
|
136
|
+
- Stripe (SDK open, API comercial)
|
|
137
|
+
- Supabase (SDK open, hosting comercial)
|
|
138
|
+
- Vercel (SDK open, deployment comercial)
|
|
139
|
+
- Sentry (SDK open, error tracking comercial)
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## 📊 Distribución Recomendada
|
|
144
|
+
|
|
145
|
+
### Para MVP y Crecimiento Inicial:
|
|
146
|
+
|
|
147
|
+
**1. PyPI (Público)** ⭐ Recomendado
|
|
148
|
+
- Más descubribilidad
|
|
149
|
+
- `pip install gateforge` es más fácil
|
|
150
|
+
- Aparece en búsquedas de PyPI
|
|
151
|
+
- Stats de downloads
|
|
152
|
+
|
|
153
|
+
**2. GitHub (Público)**
|
|
154
|
+
- Source code visible
|
|
155
|
+
- Issues y PRs
|
|
156
|
+
- Community contributions
|
|
157
|
+
- Marketing gratuito (stars)
|
|
158
|
+
|
|
159
|
+
### Para Empresas con Restricciones:
|
|
160
|
+
|
|
161
|
+
**1. PyPI (Privado)** - Si requieres control
|
|
162
|
+
- Solo con token
|
|
163
|
+
- No aparece en búsquedas públicas
|
|
164
|
+
|
|
165
|
+
**2. Servidor interno**
|
|
166
|
+
- Control total
|
|
167
|
+
- Para clientes enterprise
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## 🔄 Flujo de Actualización
|
|
172
|
+
|
|
173
|
+
Cuando hagas cambios:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
cd gateforge-sdk
|
|
177
|
+
|
|
178
|
+
# 1. Actualizar versión en pyproject.toml
|
|
179
|
+
# [project]
|
|
180
|
+
# version = "0.1.1"
|
|
181
|
+
|
|
182
|
+
# 2. Limpiar builds anteriores
|
|
183
|
+
rm -rf dist/ build/ *.egg-info
|
|
184
|
+
|
|
185
|
+
# 3. Construir nueva versión
|
|
186
|
+
python -m build
|
|
187
|
+
|
|
188
|
+
# 4. Publicar
|
|
189
|
+
python -m twine upload dist/*
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Los usuarios actualizan:
|
|
193
|
+
```bash
|
|
194
|
+
pip install --upgrade gateforge
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## ✅ Next Steps Recomendados
|
|
200
|
+
|
|
201
|
+
1. **Ahora mismo:**
|
|
202
|
+
```bash
|
|
203
|
+
# Probar instalación local
|
|
204
|
+
pip install gateforge-sdk/dist/gateforge-0.1.0-py3-none-any.whl
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
2. **Esta semana:**
|
|
208
|
+
- Crear cuenta en PyPI
|
|
209
|
+
- Publicar primera versión
|
|
210
|
+
- Crear repo público en GitHub
|
|
211
|
+
- Añadir CI/CD para auto-publish
|
|
212
|
+
|
|
213
|
+
3. **Este mes:**
|
|
214
|
+
- Documentación completa
|
|
215
|
+
- Ejemplos y tutoriales
|
|
216
|
+
- Blog post de lanzamiento
|
|
217
|
+
- Product Hunt / Hacker News
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## 📚 Recursos
|
|
222
|
+
|
|
223
|
+
- **PyPI Publishing:** Ver `PUBLISHING.md`
|
|
224
|
+
- **SDK Usage:** Ver `README.md`
|
|
225
|
+
- **License:** Ver `LICENSE` (MIT)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Gateforge
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
IMPORTANT NOTICE:
|
|
26
|
+
|
|
27
|
+
This SDK requires a Gateforge account and API key to function.
|
|
28
|
+
Service usage is subject to Gateforge's Terms of Service and Privacy Policy:
|
|
29
|
+
- Terms of Service: https://gateforge.dev/terms
|
|
30
|
+
- Privacy Policy: https://gateforge.dev/privacy
|
|
31
|
+
- Pricing: https://gateforge.dev/pricing
|
|
32
|
+
|
|
33
|
+
The Gateforge service (api.gateforge.dev) is a commercial SaaS offering
|
|
34
|
+
operated by Gateforge. Different pricing plans and usage limits apply.
|
|
35
|
+
|
|
36
|
+
Free tier: 1,000 requests/month
|
|
37
|
+
See https://gateforge.dev/pricing for details.
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gateforge-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Privacy-first LLMOps SDK — Automatic PII masking, cost tracking, and prompt management for LLM applications
|
|
5
|
+
Project-URL: Homepage, https://gateforge.dev
|
|
6
|
+
Project-URL: Documentation, https://gateforge.dev/docs
|
|
7
|
+
Project-URL: Repository, https://github.com/gateforge/gateforge-sdk
|
|
8
|
+
Project-URL: Dashboard, https://app.gateforge.dev
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/gateforge/gateforge-sdk/issues
|
|
10
|
+
Author-email: Gateforge Team <support@gateforge.dev>
|
|
11
|
+
License: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: anthropic,gemini,llm,llmops,mlops,openai,pii,privacy
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Security
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Requires-Dist: httpx>=0.27.0
|
|
25
|
+
Requires-Dist: pii-firewall[langdetect,presidio]
|
|
26
|
+
Provides-Extra: all
|
|
27
|
+
Requires-Dist: anthropic>=0.40.0; extra == 'all'
|
|
28
|
+
Requires-Dist: google-genai>=1.0.0; extra == 'all'
|
|
29
|
+
Requires-Dist: openai>=1.0.0; extra == 'all'
|
|
30
|
+
Provides-Extra: anthropic
|
|
31
|
+
Requires-Dist: anthropic>=0.40.0; extra == 'anthropic'
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: build>=1.0.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: twine>=5.0.0; extra == 'dev'
|
|
37
|
+
Provides-Extra: gemini
|
|
38
|
+
Requires-Dist: google-genai>=1.0.0; extra == 'gemini'
|
|
39
|
+
Provides-Extra: openai
|
|
40
|
+
Requires-Dist: openai>=1.0.0; extra == 'openai'
|
|
41
|
+
Description-Content-Type: text/markdown
|
|
42
|
+
|
|
43
|
+
# Gateforge SDK
|
|
44
|
+
|
|
45
|
+
**Privacy-first LLMOps SDK** — Automatic PII masking, cost tracking, and prompt management for LLM applications.
|
|
46
|
+
|
|
47
|
+
[](https://www.python.org/downloads/)
|
|
48
|
+
[](LICENSE)
|
|
49
|
+
|
|
50
|
+
## 🔒 What is Gateforge?
|
|
51
|
+
|
|
52
|
+
Gateforge is an LLMOps platform that automatically protects sensitive data (PII) in your LLM applications. The SDK processes everything **locally** — no content ever leaves your infrastructure.
|
|
53
|
+
|
|
54
|
+
> **Note:** This SDK is free and open source (MIT license). It requires a Gateforge account to use. We offer a generous free tier: **1,000 requests/month**. See [pricing](https://gateforge.dev/pricing) for details.
|
|
55
|
+
|
|
56
|
+
**Key Features:**
|
|
57
|
+
- ✅ **Automatic PII Detection & Masking** — Names, emails, SSN, phone numbers, credit cards, and more
|
|
58
|
+
- ✅ **Multi-Provider Support** — OpenAI, Anthropic, Gemini with unified interface
|
|
59
|
+
- ✅ **Cost Tracking** — Real-time metrics and dashboards
|
|
60
|
+
- ✅ **Domain-Specific Detection** — Healthcare, Finance, Legal, Generic
|
|
61
|
+
- ✅ **Custom Regex Patterns** — Add your own entity types
|
|
62
|
+
- ✅ **Zero Network Overhead** — All PII processing happens locally
|
|
63
|
+
|
|
64
|
+
## 🚀 Quick Start
|
|
65
|
+
|
|
66
|
+
### Installation
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pip install gateforge-sdk
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
With provider support:
|
|
73
|
+
```bash
|
|
74
|
+
pip install gateforge-sdk[openai] # OpenAI only
|
|
75
|
+
pip install gateforge-sdk[anthropic] # Anthropic only
|
|
76
|
+
pip install gateforge-sdk[gemini] # Google Gemini only
|
|
77
|
+
pip install gateforge-sdk[all] # All providers
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Get Your API Key
|
|
81
|
+
|
|
82
|
+
1. Sign up at [https://gateforge.dev](https://gateforge.dev)
|
|
83
|
+
2. Get your API key from [https://app.gateforge.dev/dashboard/keys](https://app.gateforge.dev/dashboard/keys)
|
|
84
|
+
|
|
85
|
+
### Basic Usage
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
import gateforge
|
|
89
|
+
|
|
90
|
+
# Initialize once at startup
|
|
91
|
+
gateforge.init(
|
|
92
|
+
api_key="your-gateforge-api-key",
|
|
93
|
+
openai_key="your-openai-key",
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
# Make LLM calls with automatic PII protection
|
|
97
|
+
response = gateforge.chat(
|
|
98
|
+
model="gpt-4.1-nano",
|
|
99
|
+
messages=[
|
|
100
|
+
{"role": "user", "content": "My email is john@example.com, can you help?"}
|
|
101
|
+
]
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
print(response.content) # "Hello! I'd be happy to help..."
|
|
105
|
+
print(response.pii_detected) # ['EMAIL']
|
|
106
|
+
print(response.tokens) # 45
|
|
107
|
+
print(response.cost_usd) # 0.000023
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## 📖 Examples
|
|
111
|
+
|
|
112
|
+
### Healthcare Domain
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
response = gateforge.chat(
|
|
116
|
+
model="gpt-4.1-nano",
|
|
117
|
+
messages=[
|
|
118
|
+
{
|
|
119
|
+
"role": "user",
|
|
120
|
+
"content": "Patient John Doe, SSN 123-45-6789, has hypertension. Recommend treatment."
|
|
121
|
+
}
|
|
122
|
+
],
|
|
123
|
+
pii_domain="healthcare" # Detects medical entities
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
print(response.pii_detected) # ['PERSON', 'SSN', 'SYMPTOM']
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Multiple Providers
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
import gateforge
|
|
133
|
+
|
|
134
|
+
gateforge.init(
|
|
135
|
+
api_key="your-gateforge-key",
|
|
136
|
+
openai_key="sk-...",
|
|
137
|
+
anthropic_key="sk-ant-...",
|
|
138
|
+
gemini_key="...",
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
# OpenAI
|
|
142
|
+
r1 = gateforge.chat(model="gpt-4.1-nano", messages=[...])
|
|
143
|
+
|
|
144
|
+
# Anthropic
|
|
145
|
+
r2 = gateforge.chat(model="claude-haiku-4-5", messages=[...])
|
|
146
|
+
|
|
147
|
+
# Gemini
|
|
148
|
+
r3 = gateforge.chat(model="gemini-2.5-flash", messages=[...])
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Custom PII Patterns
|
|
152
|
+
|
|
153
|
+
Configure custom patterns in your dashboard at [https://app.gateforge.dev/dashboard/pii/settings](https://app.gateforge.dev/dashboard/pii/settings), and the SDK will download them automatically.
|
|
154
|
+
|
|
155
|
+
## 🔧 Configuration
|
|
156
|
+
|
|
157
|
+
### Initialization Options
|
|
158
|
+
|
|
159
|
+
```python
|
|
160
|
+
gateforge.init(
|
|
161
|
+
api_key="your-gateforge-api-key", # Required
|
|
162
|
+
openai_key="sk-...", # Optional
|
|
163
|
+
anthropic_key="sk-ant-...", # Optional
|
|
164
|
+
gemini_key="...", # Optional
|
|
165
|
+
)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Chat Parameters
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
response = gateforge.chat(
|
|
172
|
+
model="gpt-4.1-nano", # Required: model name
|
|
173
|
+
messages=[...], # Required: chat messages
|
|
174
|
+
pii_domain="generic", # Optional: "generic", "healthcare", "finance", "legal"
|
|
175
|
+
provider_key="sk-...", # Optional: override provider key
|
|
176
|
+
prompt_id="user-signup", # Optional: for prompt tracking
|
|
177
|
+
temperature=0.7, # Optional: model parameters
|
|
178
|
+
max_tokens=500, # Optional: model parameters
|
|
179
|
+
)
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Response Object
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
response = gateforge.chat(...)
|
|
186
|
+
|
|
187
|
+
response.content # str: The response content
|
|
188
|
+
response.pii_detected # list[str]: Detected PII types
|
|
189
|
+
response.tokens # int: Total tokens
|
|
190
|
+
response.prompt_tokens # int: Input tokens
|
|
191
|
+
response.completion_tokens # int: Output tokens
|
|
192
|
+
response.cost_usd # float: Cost in USD
|
|
193
|
+
response.latency_ms # float: Latency in milliseconds
|
|
194
|
+
response.model # str: Model used
|
|
195
|
+
response.raw # dict: Raw provider response
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## 🔒 Privacy & Security
|
|
199
|
+
|
|
200
|
+
### How it Works
|
|
201
|
+
|
|
202
|
+
1. **Local Processing**: All PII detection happens locally in your environment
|
|
203
|
+
2. **Content Never Sent**: Only metadata (tokens, cost) is sent to Gateforge API
|
|
204
|
+
3. **Automatic Masking**: PII is replaced with tokens before sending to LLM providers
|
|
205
|
+
4. **Automatic Rehydration**: Responses are reconstructed with original context
|
|
206
|
+
|
|
207
|
+
### What Gets Detected?
|
|
208
|
+
|
|
209
|
+
- **Personal**: Names, emails, phone numbers, addresses
|
|
210
|
+
- **Financial**: Credit cards, bank accounts, SSN, tax IDs
|
|
211
|
+
- **Healthcare**: Medical record numbers, symptoms, diagnoses
|
|
212
|
+
- **Technical**: IP addresses, URLs, API keys
|
|
213
|
+
- **Custom**: Your own regex patterns
|
|
214
|
+
|
|
215
|
+
### Supported Backends
|
|
216
|
+
|
|
217
|
+
- **Presidio** (default): ML-based, highest accuracy
|
|
218
|
+
- **Regex**: Pattern matching, fastest
|
|
219
|
+
- **Hybrid**: Combined ML + regex
|
|
220
|
+
- **GLiNER**: Zero-shot NER
|
|
221
|
+
- **Transformers**: HuggingFace models
|
|
222
|
+
|
|
223
|
+
## 📊 Dashboard & Monitoring
|
|
224
|
+
|
|
225
|
+
View real-time metrics at [https://app.gateforge.dev/dashboard](https://app.gateforge.dev/dashboard):
|
|
226
|
+
|
|
227
|
+
- 📈 Request volume and trends
|
|
228
|
+
- 💰 Cost breakdown by model and provider
|
|
229
|
+
- ⚡ Latency analytics
|
|
230
|
+
- 🔒 PII detection statistics
|
|
231
|
+
- 🔑 API key management
|
|
232
|
+
|
|
233
|
+
## 🛠️ Advanced Usage
|
|
234
|
+
|
|
235
|
+
### Streaming (Coming Soon)
|
|
236
|
+
|
|
237
|
+
```python
|
|
238
|
+
for chunk in gateforge.chat_stream(model="gpt-4.1-nano", messages=[...]):
|
|
239
|
+
print(chunk.content, end="", flush=True)
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Async Support (Coming Soon)
|
|
243
|
+
|
|
244
|
+
```python
|
|
245
|
+
response = await gateforge.achat(model="gpt-4.1-nano", messages=[...])
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Direct Anonymization
|
|
249
|
+
|
|
250
|
+
```python
|
|
251
|
+
from gateforge.pii import anonymize_messages
|
|
252
|
+
|
|
253
|
+
context = {
|
|
254
|
+
"tenant_id": "user-123",
|
|
255
|
+
"case_id": "case-456",
|
|
256
|
+
"thread_id": "thread-789",
|
|
257
|
+
"actor_id": "user"
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
anonymized, entities = anonymize_messages(
|
|
261
|
+
messages=[{"role": "user", "content": "My email is john@example.com"}],
|
|
262
|
+
domain="generic",
|
|
263
|
+
backend="presidio",
|
|
264
|
+
context=context
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
print(anonymized) # [{"role": "user", "content": "My email is [EMAIL_001]"}]
|
|
268
|
+
print(entities) # ['EMAIL']
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
## 🌐 Supported Models
|
|
272
|
+
|
|
273
|
+
### OpenAI
|
|
274
|
+
- GPT-4.1-nano, GPT-4.1-mini, GPT-4.1, GPT-4.1-turbo
|
|
275
|
+
- GPT-4o, GPT-4o-mini
|
|
276
|
+
- GPT-3.5-turbo
|
|
277
|
+
|
|
278
|
+
### Anthropic
|
|
279
|
+
- Claude Haiku 4-5
|
|
280
|
+
- Claude Sonnet 4-5
|
|
281
|
+
- Claude Opus 4
|
|
282
|
+
|
|
283
|
+
### Google Gemini
|
|
284
|
+
- Gemini 2.5 Flash
|
|
285
|
+
- Gemini 2.5 Pro
|
|
286
|
+
|
|
287
|
+
## 📝 Configuration via Dashboard
|
|
288
|
+
|
|
289
|
+
### PII Settings
|
|
290
|
+
|
|
291
|
+
1. Go to [https://app.gateforge.dev/dashboard/pii/settings](https://app.gateforge.dev/dashboard/pii/settings)
|
|
292
|
+
2. Select domain: Generic, Healthcare, Finance, Legal
|
|
293
|
+
3. Choose backend: Presidio, Regex, Hybrid
|
|
294
|
+
4. Set language: Auto-detect or specific language
|
|
295
|
+
5. Add custom regex patterns
|
|
296
|
+
|
|
297
|
+
The SDK downloads your configuration automatically on init.
|
|
298
|
+
|
|
299
|
+
### Custom Patterns
|
|
300
|
+
|
|
301
|
+
Add patterns like:
|
|
302
|
+
```
|
|
303
|
+
Entity Type: EMPLOYEE_ID
|
|
304
|
+
Regex: EMP-\d{6}
|
|
305
|
+
Confidence: 0.95
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
## 🐛 Troubleshooting
|
|
309
|
+
|
|
310
|
+
### ImportError: No module named 'gateforge'
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
pip install gateforge-sdk
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
### RuntimeError: Call gateforge.init() first
|
|
317
|
+
|
|
318
|
+
Make sure to initialize before making calls:
|
|
319
|
+
```python
|
|
320
|
+
gateforge.init(api_key="your-key")
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### API Key Not Working
|
|
324
|
+
|
|
325
|
+
1. Verify your key at [https://app.gateforge.dev/dashboard/keys](https://app.gateforge.dev/dashboard/keys)
|
|
326
|
+
2. Check it's not revoked
|
|
327
|
+
3. Ensure you're using the correct environment
|
|
328
|
+
|
|
329
|
+
### PII Not Detected
|
|
330
|
+
|
|
331
|
+
1. Check your domain setting matches your use case
|
|
332
|
+
2. Try different backends (presidio is most accurate)
|
|
333
|
+
3. Add custom patterns for domain-specific entities
|
|
334
|
+
|
|
335
|
+
## 📚 Documentation
|
|
336
|
+
|
|
337
|
+
- **Website**: [https://gateforge.dev](https://gateforge.dev)
|
|
338
|
+
- **Dashboard**: [https://app.gateforge.dev](https://app.gateforge.dev)
|
|
339
|
+
- **API Docs**: [https://api.gateforge.dev/docs](https://api.gateforge.dev/docs)
|
|
340
|
+
|
|
341
|
+
## 🤝 Contributing
|
|
342
|
+
|
|
343
|
+
Contributions are welcome! Please open an issue or submit a pull request.
|
|
344
|
+
|
|
345
|
+
## 📄 License
|
|
346
|
+
|
|
347
|
+
MIT License - See [LICENSE](LICENSE) for details.
|
|
348
|
+
|
|
349
|
+
**Important:** While the SDK is open source, the Gateforge service is commercial. You need a Gateforge account (free tier available) to use this SDK.
|
|
350
|
+
|
|
351
|
+
## 🔗 Links
|
|
352
|
+
|
|
353
|
+
- [Website](https://gateforge.dev)
|
|
354
|
+
- [Dashboard](https://app.gateforge.dev)
|
|
355
|
+
- [API Health](https://api.gateforge.dev/v1/health)
|
|
356
|
+
- [Documentation](https://gateforge.dev/docs)
|
|
357
|
+
|
|
358
|
+
## 💬 Support
|
|
359
|
+
|
|
360
|
+
- **Email**: support@gateforge.dev
|
|
361
|
+
- **Issues**: [GitHub Issues](https://github.com/gateforge/gateforge-sdk/issues)
|
|
362
|
+
|
|
363
|
+
---
|
|
364
|
+
|
|
365
|
+
**Made with ❤️ by the Gateforge team**
|