get-systems 0.2.21__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.
- get_systems-0.2.21/PKG-INFO +202 -0
- get_systems-0.2.21/README.md +172 -0
- get_systems-0.2.21/get_systems/__init__.py +93 -0
- get_systems-0.2.21/get_systems/http/__init__.py +15 -0
- get_systems-0.2.21/get_systems/http/http_block.py +69 -0
- get_systems-0.2.21/get_systems/llm/__init__.py +22 -0
- get_systems-0.2.21/get_systems/llm/gpt_blocks.py +424 -0
- get_systems-0.2.21/get_systems/llm/utils.py +49 -0
- get_systems-0.2.21/get_systems/models/__init__.py +32 -0
- get_systems-0.2.21/get_systems/models/address.py +234 -0
- get_systems-0.2.21/get_systems/models/bank_account.py +51 -0
- get_systems-0.2.21/get_systems/models/base.py +182 -0
- get_systems-0.2.21/get_systems/models/ccase.py +27 -0
- get_systems-0.2.21/get_systems/models/communication.py +56 -0
- get_systems-0.2.21/get_systems/models/contact.py +265 -0
- get_systems-0.2.21/get_systems/models/contact_parser.py +234 -0
- get_systems-0.2.21/get_systems/models/event.py +175 -0
- get_systems-0.2.21/get_systems/models/file_aica.py +20 -0
- get_systems-0.2.21/get_systems/models/import_data.py +16 -0
- get_systems-0.2.21/get_systems/models/payment.py +11 -0
- get_systems-0.2.21/get_systems/models/subcase.py +8 -0
- get_systems-0.2.21/get_systems.egg-info/PKG-INFO +202 -0
- get_systems-0.2.21/get_systems.egg-info/SOURCES.txt +35 -0
- get_systems-0.2.21/get_systems.egg-info/dependency_links.txt +1 -0
- get_systems-0.2.21/get_systems.egg-info/requires.txt +28 -0
- get_systems-0.2.21/get_systems.egg-info/top_level.txt +1 -0
- get_systems-0.2.21/pyproject.toml +35 -0
- get_systems-0.2.21/setup.cfg +4 -0
- get_systems-0.2.21/tests/test_address.py +175 -0
- get_systems-0.2.21/tests/test_bank_account.py +57 -0
- get_systems-0.2.21/tests/test_base.py +90 -0
- get_systems-0.2.21/tests/test_client.py +88 -0
- get_systems-0.2.21/tests/test_comparison.py +67 -0
- get_systems-0.2.21/tests/test_contact.py +264 -0
- get_systems-0.2.21/tests/test_contact_parser.py +189 -0
- get_systems-0.2.21/tests/test_event.py +104 -0
- get_systems-0.2.21/tests/test_gs.py +86 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: get-systems
|
|
3
|
+
Version: 0.2.21
|
|
4
|
+
Summary: Get Systems Prefect Blocks - Enterprise LLM and HTTP operations
|
|
5
|
+
Author: Get Systems
|
|
6
|
+
Requires-Python: >=3.11
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: prefect>=3.6.5
|
|
9
|
+
Requires-Dist: pydantic>=2.0.0
|
|
10
|
+
Provides-Extra: llm
|
|
11
|
+
Requires-Dist: openai>=2.21.0; extra == "llm"
|
|
12
|
+
Provides-Extra: http
|
|
13
|
+
Requires-Dist: httpx>=0.27.0; extra == "http"
|
|
14
|
+
Provides-Extra: models
|
|
15
|
+
Requires-Dist: nameparser>=1.1.3; extra == "models"
|
|
16
|
+
Requires-Dist: gender-guesser>=0.4.0; extra == "models"
|
|
17
|
+
Requires-Dist: python-stdnum>=1.19; extra == "models"
|
|
18
|
+
Provides-Extra: azure-cu
|
|
19
|
+
Requires-Dist: azure-ai-contentunderstanding; extra == "azure-cu"
|
|
20
|
+
Requires-Dist: azure-identity; extra == "azure-cu"
|
|
21
|
+
Provides-Extra: all
|
|
22
|
+
Requires-Dist: openai>=2.21.0; extra == "all"
|
|
23
|
+
Requires-Dist: httpx>=0.27.0; extra == "all"
|
|
24
|
+
Requires-Dist: nameparser>=1.1.3; extra == "all"
|
|
25
|
+
Requires-Dist: gender-guesser>=0.4.0; extra == "all"
|
|
26
|
+
Requires-Dist: python-stdnum>=1.19; extra == "all"
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest>=9.0.2; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
|
|
30
|
+
|
|
31
|
+
# get_systems - Get Systems Prefect Blocks
|
|
32
|
+
|
|
33
|
+
Enterprise-grade Prefect blocks for LLM operations and HTTP requests.
|
|
34
|
+
|
|
35
|
+
## Features
|
|
36
|
+
|
|
37
|
+
### LLM Module (`get_systems.llm`)
|
|
38
|
+
- ✅ **OpenAI & Azure OpenAI Support** - Seamlessly switch between providers
|
|
39
|
+
- ✅ **Environment Variables** - Automatic fallback to env vars
|
|
40
|
+
- ✅ **Retry Logic** - Exponential backoff with jitter
|
|
41
|
+
- ✅ **Caching** - Optional in-memory response caching
|
|
42
|
+
- ✅ **Safe Logging** - No API key leaks
|
|
43
|
+
- ✅ **Flexible Parameters** - Pass any OpenAI API parameter via **kwarget_systems
|
|
44
|
+
- ✅ **Function Calling** - Full support for tools
|
|
45
|
+
|
|
46
|
+
### HTTP Module (`get_systems.http`)
|
|
47
|
+
- ✅ **Multiple Auth Types** - None, Basic, Token, Bearer
|
|
48
|
+
- ✅ **Async HTTP Client** - Built on httpx
|
|
49
|
+
- ✅ **Prefect Integration** - First-class block support
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
### Install Everything (Recommended)
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install "get_systems[all]"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Install Specific Modules
|
|
60
|
+
|
|
61
|
+
Install only what you need:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# For LLM operations only
|
|
65
|
+
pip install "get_systems[llm]"
|
|
66
|
+
|
|
67
|
+
# For HTTP operations only
|
|
68
|
+
pip install "get_systems[http]"
|
|
69
|
+
|
|
70
|
+
# Install both
|
|
71
|
+
pip install "get_systems[llm,http]"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### From Azure Artifacts
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# All modules
|
|
78
|
+
pip install "get_systems[all]" --extra-index-url https://pkget_systems.dev.azure.com/get-systems/_packaging/get-systems/pypi/simple/
|
|
79
|
+
|
|
80
|
+
# Specific modules
|
|
81
|
+
pip install "get_systems[llm]" --extra-index-url https://pkget_systems.dev.azure.com/get-systems/_packaging/get-systems/pypi/simple/
|
|
82
|
+
pip install "get_systems[http]" --extra-index-url https://pkget_systems.dev.azure.com/get-systems/_packaging/get-systems/pypi/simple/
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### What Gets Installed
|
|
86
|
+
|
|
87
|
+
| Installation | Dependencies |
|
|
88
|
+
|-------------|--------------|
|
|
89
|
+
| `pip install get_systems` | `prefect`, `pydantic` (base only) |
|
|
90
|
+
| `pip install "get_systems[llm]"` | Base + `openai` |
|
|
91
|
+
| `pip install "get_systems[http]"` | Base + `httpx` |
|
|
92
|
+
| `pip install "get_systems[all]"` | Base + `openai` + `httpx` |
|
|
93
|
+
|
|
94
|
+
## Quick Start
|
|
95
|
+
|
|
96
|
+
### LLM Operations
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
from get_systems.llm import GptCompletionBlock, GptAuth, LlmRuntime
|
|
100
|
+
from prefect import flow
|
|
101
|
+
|
|
102
|
+
# Configure auth
|
|
103
|
+
auth = GptAuth(
|
|
104
|
+
api_key="sk-...",
|
|
105
|
+
model="gpt-4o-mini",
|
|
106
|
+
is_azure=False
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
# Create completion block
|
|
110
|
+
block = GptCompletionBlock(
|
|
111
|
+
auth=auth,
|
|
112
|
+
prompt="What is Prefect?",
|
|
113
|
+
temperature=0.7
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
@flow
|
|
117
|
+
async def my_llm_flow():
|
|
118
|
+
result = await block.run()
|
|
119
|
+
print(result.content)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### HTTP Operations
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
from get_systems.http import HttpAuth, HttpBlock
|
|
126
|
+
from prefect import flow
|
|
127
|
+
|
|
128
|
+
# Configure HTTP auth
|
|
129
|
+
auth = HttpAuth(
|
|
130
|
+
auth_type="bearer",
|
|
131
|
+
token="your-token",
|
|
132
|
+
base_url="https://api.example.com"
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
# Create HTTP block
|
|
136
|
+
http_block = HttpBlock(auth=auth)
|
|
137
|
+
|
|
138
|
+
@flow
|
|
139
|
+
async def my_http_flow():
|
|
140
|
+
response = await http_block.request("GET", "/users")
|
|
141
|
+
print(response.json())
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Register Blocks in Prefect
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
# Register all blocks
|
|
148
|
+
prefect block register -m get_systems.llm.gpt_blocks
|
|
149
|
+
prefect block register -m get_systems.http.http_block
|
|
150
|
+
|
|
151
|
+
# View registered blocks
|
|
152
|
+
prefect block ls
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Import Styles
|
|
156
|
+
|
|
157
|
+
All import styles are supported:
|
|
158
|
+
|
|
159
|
+
```python
|
|
160
|
+
# Submodule imports
|
|
161
|
+
from get_systems.llm import GptCompletionBlock, GptAuth
|
|
162
|
+
from get_systems.http import HttpAuth, HttpBlock
|
|
163
|
+
|
|
164
|
+
# Direct module imports
|
|
165
|
+
from get_systems.llm.gpt_blocks import GptCompletionBlock
|
|
166
|
+
from get_systems.http.http_block import HttpAuth
|
|
167
|
+
|
|
168
|
+
# Package-level imports
|
|
169
|
+
from get_systems import GptCompletionBlock, HttpAuth
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Environment Variables
|
|
173
|
+
|
|
174
|
+
### OpenAI Configuration:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
OPENAI_API_KEY=sk-...
|
|
178
|
+
OPENAI_MODEL=gpt-4o-mini
|
|
179
|
+
OPENAI_BASE_URL=https://api.openai.com/v1 # optional
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Azure OpenAI Configuration:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
OPENAI_API_KEY=your-azure-key
|
|
186
|
+
OPENAI_BASE_URL=https://your-resource.openai.azure.com
|
|
187
|
+
OPENAI_MODEL=your-deployment-name
|
|
188
|
+
OPENAI_API_VERSION=2024-02-15-preview
|
|
189
|
+
OPENAI_IS_AZURE=true
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Documentation
|
|
193
|
+
|
|
194
|
+
- [docs/QUICKSTART-get_systems.md](docs/QUICKSTART-get_systems.md) - Quick start and usage examples
|
|
195
|
+
- [docs/MIGRATION.md](docs/MIGRATION.md) - Migration guide from old packages
|
|
196
|
+
- **LLM Module**: Full OpenAI/Azure OpenAI integration with enterprise features
|
|
197
|
+
- **HTTP Module**: Flexible HTTP client with multiple authentication types
|
|
198
|
+
- **Prefect Integration**: Native Prefect block support for both modules
|
|
199
|
+
|
|
200
|
+
## License
|
|
201
|
+
|
|
202
|
+
Proprietary - Get Systems
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# get_systems - Get Systems Prefect Blocks
|
|
2
|
+
|
|
3
|
+
Enterprise-grade Prefect blocks for LLM operations and HTTP requests.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
### LLM Module (`get_systems.llm`)
|
|
8
|
+
- ✅ **OpenAI & Azure OpenAI Support** - Seamlessly switch between providers
|
|
9
|
+
- ✅ **Environment Variables** - Automatic fallback to env vars
|
|
10
|
+
- ✅ **Retry Logic** - Exponential backoff with jitter
|
|
11
|
+
- ✅ **Caching** - Optional in-memory response caching
|
|
12
|
+
- ✅ **Safe Logging** - No API key leaks
|
|
13
|
+
- ✅ **Flexible Parameters** - Pass any OpenAI API parameter via **kwarget_systems
|
|
14
|
+
- ✅ **Function Calling** - Full support for tools
|
|
15
|
+
|
|
16
|
+
### HTTP Module (`get_systems.http`)
|
|
17
|
+
- ✅ **Multiple Auth Types** - None, Basic, Token, Bearer
|
|
18
|
+
- ✅ **Async HTTP Client** - Built on httpx
|
|
19
|
+
- ✅ **Prefect Integration** - First-class block support
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
### Install Everything (Recommended)
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install "get_systems[all]"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Install Specific Modules
|
|
30
|
+
|
|
31
|
+
Install only what you need:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# For LLM operations only
|
|
35
|
+
pip install "get_systems[llm]"
|
|
36
|
+
|
|
37
|
+
# For HTTP operations only
|
|
38
|
+
pip install "get_systems[http]"
|
|
39
|
+
|
|
40
|
+
# Install both
|
|
41
|
+
pip install "get_systems[llm,http]"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### From Azure Artifacts
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# All modules
|
|
48
|
+
pip install "get_systems[all]" --extra-index-url https://pkget_systems.dev.azure.com/get-systems/_packaging/get-systems/pypi/simple/
|
|
49
|
+
|
|
50
|
+
# Specific modules
|
|
51
|
+
pip install "get_systems[llm]" --extra-index-url https://pkget_systems.dev.azure.com/get-systems/_packaging/get-systems/pypi/simple/
|
|
52
|
+
pip install "get_systems[http]" --extra-index-url https://pkget_systems.dev.azure.com/get-systems/_packaging/get-systems/pypi/simple/
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### What Gets Installed
|
|
56
|
+
|
|
57
|
+
| Installation | Dependencies |
|
|
58
|
+
|-------------|--------------|
|
|
59
|
+
| `pip install get_systems` | `prefect`, `pydantic` (base only) |
|
|
60
|
+
| `pip install "get_systems[llm]"` | Base + `openai` |
|
|
61
|
+
| `pip install "get_systems[http]"` | Base + `httpx` |
|
|
62
|
+
| `pip install "get_systems[all]"` | Base + `openai` + `httpx` |
|
|
63
|
+
|
|
64
|
+
## Quick Start
|
|
65
|
+
|
|
66
|
+
### LLM Operations
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from get_systems.llm import GptCompletionBlock, GptAuth, LlmRuntime
|
|
70
|
+
from prefect import flow
|
|
71
|
+
|
|
72
|
+
# Configure auth
|
|
73
|
+
auth = GptAuth(
|
|
74
|
+
api_key="sk-...",
|
|
75
|
+
model="gpt-4o-mini",
|
|
76
|
+
is_azure=False
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
# Create completion block
|
|
80
|
+
block = GptCompletionBlock(
|
|
81
|
+
auth=auth,
|
|
82
|
+
prompt="What is Prefect?",
|
|
83
|
+
temperature=0.7
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
@flow
|
|
87
|
+
async def my_llm_flow():
|
|
88
|
+
result = await block.run()
|
|
89
|
+
print(result.content)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### HTTP Operations
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from get_systems.http import HttpAuth, HttpBlock
|
|
96
|
+
from prefect import flow
|
|
97
|
+
|
|
98
|
+
# Configure HTTP auth
|
|
99
|
+
auth = HttpAuth(
|
|
100
|
+
auth_type="bearer",
|
|
101
|
+
token="your-token",
|
|
102
|
+
base_url="https://api.example.com"
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
# Create HTTP block
|
|
106
|
+
http_block = HttpBlock(auth=auth)
|
|
107
|
+
|
|
108
|
+
@flow
|
|
109
|
+
async def my_http_flow():
|
|
110
|
+
response = await http_block.request("GET", "/users")
|
|
111
|
+
print(response.json())
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Register Blocks in Prefect
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# Register all blocks
|
|
118
|
+
prefect block register -m get_systems.llm.gpt_blocks
|
|
119
|
+
prefect block register -m get_systems.http.http_block
|
|
120
|
+
|
|
121
|
+
# View registered blocks
|
|
122
|
+
prefect block ls
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Import Styles
|
|
126
|
+
|
|
127
|
+
All import styles are supported:
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
# Submodule imports
|
|
131
|
+
from get_systems.llm import GptCompletionBlock, GptAuth
|
|
132
|
+
from get_systems.http import HttpAuth, HttpBlock
|
|
133
|
+
|
|
134
|
+
# Direct module imports
|
|
135
|
+
from get_systems.llm.gpt_blocks import GptCompletionBlock
|
|
136
|
+
from get_systems.http.http_block import HttpAuth
|
|
137
|
+
|
|
138
|
+
# Package-level imports
|
|
139
|
+
from get_systems import GptCompletionBlock, HttpAuth
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Environment Variables
|
|
143
|
+
|
|
144
|
+
### OpenAI Configuration:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
OPENAI_API_KEY=sk-...
|
|
148
|
+
OPENAI_MODEL=gpt-4o-mini
|
|
149
|
+
OPENAI_BASE_URL=https://api.openai.com/v1 # optional
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Azure OpenAI Configuration:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
OPENAI_API_KEY=your-azure-key
|
|
156
|
+
OPENAI_BASE_URL=https://your-resource.openai.azure.com
|
|
157
|
+
OPENAI_MODEL=your-deployment-name
|
|
158
|
+
OPENAI_API_VERSION=2024-02-15-preview
|
|
159
|
+
OPENAI_IS_AZURE=true
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Documentation
|
|
163
|
+
|
|
164
|
+
- [docs/QUICKSTART-get_systems.md](docs/QUICKSTART-get_systems.md) - Quick start and usage examples
|
|
165
|
+
- [docs/MIGRATION.md](docs/MIGRATION.md) - Migration guide from old packages
|
|
166
|
+
- **LLM Module**: Full OpenAI/Azure OpenAI integration with enterprise features
|
|
167
|
+
- **HTTP Module**: Flexible HTTP client with multiple authentication types
|
|
168
|
+
- **Prefect Integration**: Native Prefect block support for both modules
|
|
169
|
+
|
|
170
|
+
## License
|
|
171
|
+
|
|
172
|
+
Proprietary - Get Systems
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from importlib import import_module
|
|
4
|
+
from importlib.util import find_spec
|
|
5
|
+
from importlib.metadata import version, PackageNotFoundError
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
try:
|
|
9
|
+
__version__ = version("get-systems") # package name in pyproject
|
|
10
|
+
except PackageNotFoundError:
|
|
11
|
+
# fallback for local/dev run (not installed via pip)
|
|
12
|
+
__version__ = "0.0.0"
|
|
13
|
+
|
|
14
|
+
# Какие "пространства" сканируем.
|
|
15
|
+
# Можешь расширять: plugins, integrations и т.п.
|
|
16
|
+
_NAMESPACES = ("models", "llm", "http")
|
|
17
|
+
|
|
18
|
+
# Здесь будет: name -> (module_path, attr_name)
|
|
19
|
+
_EXPORTS: dict[str, tuple[str, str]] = {}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _discover_exports() -> None:
|
|
23
|
+
"""
|
|
24
|
+
Discover exports from get_systems.<namespace> packages.
|
|
25
|
+
|
|
26
|
+
Strategy:
|
|
27
|
+
- For each namespace package (models/llm/http), import only its __init__
|
|
28
|
+
(not every submodule), read __all__ and register lazy exports.
|
|
29
|
+
- The heavy dependencies should be imported inside that namespace package,
|
|
30
|
+
or inside its submodules, not here.
|
|
31
|
+
"""
|
|
32
|
+
pkg_root = "get_systems"
|
|
33
|
+
|
|
34
|
+
for ns in _NAMESPACES:
|
|
35
|
+
ns_mod_path = f"{pkg_root}.{ns}"
|
|
36
|
+
|
|
37
|
+
# Namespace may not exist if extra isn't installed or package not shipped
|
|
38
|
+
if find_spec(ns_mod_path) is None:
|
|
39
|
+
continue
|
|
40
|
+
|
|
41
|
+
try:
|
|
42
|
+
ns_mod = import_module(ns_mod_path) # imports get_systems.<ns>.__init__
|
|
43
|
+
except ImportError:
|
|
44
|
+
# If optional deps of that namespace are missing, just skip.
|
|
45
|
+
# Real error will appear when user tries to access something.
|
|
46
|
+
continue
|
|
47
|
+
|
|
48
|
+
ns_all = getattr(ns_mod, "__all__", None)
|
|
49
|
+
if not ns_all:
|
|
50
|
+
continue
|
|
51
|
+
|
|
52
|
+
for name in ns_all:
|
|
53
|
+
# Detect collisions early
|
|
54
|
+
if name in _EXPORTS:
|
|
55
|
+
prev = _EXPORTS[name][0]
|
|
56
|
+
raise RuntimeError(
|
|
57
|
+
f"Export name collision: '{name}' provided by both '{prev}' and '{ns_mod_path}'. "
|
|
58
|
+
f"Rename one of them or avoid exporting it at top-level."
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
_EXPORTS[name] = (ns_mod_path, name)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
_discover_exports()
|
|
65
|
+
|
|
66
|
+
# Public API is whatever we discovered
|
|
67
|
+
__all__ = sorted(_EXPORTS.keys())
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def __getattr__(name: str) -> Any:
|
|
71
|
+
"""
|
|
72
|
+
Lazy attribute resolver for dynamically discovered exports.
|
|
73
|
+
"""
|
|
74
|
+
if name not in _EXPORTS:
|
|
75
|
+
raise AttributeError(f"module 'get_systems' has no attribute '{name}'")
|
|
76
|
+
|
|
77
|
+
module_name, attr_name = _EXPORTS[name]
|
|
78
|
+
|
|
79
|
+
# Optional nice hints based on namespace
|
|
80
|
+
if module_name.endswith(".llm"):
|
|
81
|
+
# if llm extra not installed, most likely it fails inside llm import
|
|
82
|
+
pass
|
|
83
|
+
if module_name.endswith(".http"):
|
|
84
|
+
pass
|
|
85
|
+
if module_name.endswith(".models"):
|
|
86
|
+
pass
|
|
87
|
+
|
|
88
|
+
mod = import_module(module_name)
|
|
89
|
+
value = getattr(mod, attr_name)
|
|
90
|
+
|
|
91
|
+
# Cache for next time
|
|
92
|
+
globals()[name] = value
|
|
93
|
+
return value
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""
|
|
2
|
+
HTTP authentication and request module - Prefect blocks for HTTP operations
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
from get_systems.http import HttpAuth, HttpBlock
|
|
6
|
+
# or
|
|
7
|
+
from get_systems.http.http_block import HttpAuth
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from get_systems.http.http_block import HttpAuth, HttpBlock
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"HttpAuth",
|
|
14
|
+
"HttpBlock",
|
|
15
|
+
]
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
from typing import Any, Literal, Optional
|
|
2
|
+
|
|
3
|
+
import httpx
|
|
4
|
+
from pydantic import Field, SecretStr
|
|
5
|
+
from prefect.blocks.core import Block
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class HttpAuth(Block):
|
|
9
|
+
"""HTTP authentication configuration and async client factory."""
|
|
10
|
+
|
|
11
|
+
auth_type: Literal["none", "basic", "token", "bearer"] = Field(
|
|
12
|
+
default="none",
|
|
13
|
+
description="Authentication type for HTTP requests",
|
|
14
|
+
)
|
|
15
|
+
username: Optional[str] = Field(default=None, description="Basic auth username")
|
|
16
|
+
password: Optional[SecretStr] = Field(default=None, description="Basic auth password")
|
|
17
|
+
token: Optional[SecretStr] = Field(default=None, description="Token or bearer value")
|
|
18
|
+
headers: dict[str, str] = Field(default_factory=dict, description="Extra headers")
|
|
19
|
+
|
|
20
|
+
def _auth(self) -> Optional[httpx.Auth]:
|
|
21
|
+
if self.auth_type != "basic":
|
|
22
|
+
return None
|
|
23
|
+
if not self.username or not self.password:
|
|
24
|
+
raise ValueError("Basic auth requires username and password.")
|
|
25
|
+
return httpx.BasicAuth(self.username, self.password.get_secret_value())
|
|
26
|
+
|
|
27
|
+
def _headers(self) -> dict[str, str]:
|
|
28
|
+
headers = dict(self.headers)
|
|
29
|
+
if self.auth_type in ("token", "bearer"):
|
|
30
|
+
if not self.token:
|
|
31
|
+
raise ValueError("Token auth requires token.")
|
|
32
|
+
prefix = "Token" if self.auth_type == "token" else "Bearer"
|
|
33
|
+
headers["Authorization"] = f"{prefix} {self.token.get_secret_value()}"
|
|
34
|
+
return headers
|
|
35
|
+
|
|
36
|
+
def get_async_client(
|
|
37
|
+
self,
|
|
38
|
+
base_url: Optional[str] = None,
|
|
39
|
+
timeout_s: float = 60.0,
|
|
40
|
+
extra_headers: Optional[dict[str, str]] = None,
|
|
41
|
+
) -> httpx.AsyncClient:
|
|
42
|
+
headers = self._headers()
|
|
43
|
+
if extra_headers:
|
|
44
|
+
headers.update(extra_headers)
|
|
45
|
+
|
|
46
|
+
return httpx.AsyncClient(
|
|
47
|
+
base_url=base_url or "",
|
|
48
|
+
timeout=httpx.Timeout(timeout_s),
|
|
49
|
+
headers=headers,
|
|
50
|
+
auth=self._auth(),
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class HttpBlock(Block):
|
|
55
|
+
"""Base class for HTTP-based blocks, providing common functionality for API interactions."""
|
|
56
|
+
|
|
57
|
+
url: str = "https://api.example.com" # Default URL, can be overridden by subclasses
|
|
58
|
+
extract_token: bool = False # Whether to extract token from response for chaining
|
|
59
|
+
auth: Optional[HttpAuth] = None
|
|
60
|
+
timeout_s: float = 60.0
|
|
61
|
+
|
|
62
|
+
def get_async_client(self) -> httpx.AsyncClient:
|
|
63
|
+
if self.auth:
|
|
64
|
+
return self.auth.get_async_client(base_url=self.url, timeout_s=self.timeout_s)
|
|
65
|
+
return httpx.AsyncClient(base_url=self.url, timeout=httpx.Timeout(self.timeout_s))
|
|
66
|
+
|
|
67
|
+
async def request(self, method: str, path: str = "", **kwargs: Any) -> httpx.Response:
|
|
68
|
+
async with self.get_async_client() as client:
|
|
69
|
+
return await client.request(method=method, url=path, **kwargs)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""
|
|
2
|
+
LLM operations module - OpenAI and Azure OpenAI Prefect blocks
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
from get_systems.llm import GptCompletionBlock, GptAuth, LlmRuntime, LlmResult
|
|
6
|
+
# or
|
|
7
|
+
from get_systems.llm.gpt_blocks import GptCompletionBlock
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from get_systems.llm.gpt_blocks import (
|
|
11
|
+
GptAuth,
|
|
12
|
+
GptCompletionBlock,
|
|
13
|
+
LlmResult,
|
|
14
|
+
LlmRuntime,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"GptAuth",
|
|
19
|
+
"GptCompletionBlock",
|
|
20
|
+
"LlmResult",
|
|
21
|
+
"LlmRuntime",
|
|
22
|
+
]
|