ostruct-cli 0.4.0__py3-none-any.whl → 0.6.0__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.
- ostruct/cli/base_errors.py +183 -0
- ostruct/cli/cli.py +879 -592
- ostruct/cli/click_options.py +320 -202
- ostruct/cli/errors.py +273 -134
- ostruct/cli/exit_codes.py +18 -0
- ostruct/cli/file_info.py +30 -14
- ostruct/cli/file_list.py +4 -10
- ostruct/cli/file_utils.py +43 -35
- ostruct/cli/path_utils.py +32 -4
- ostruct/cli/schema_validation.py +213 -0
- ostruct/cli/security/allowed_checker.py +8 -0
- ostruct/cli/security/base.py +46 -0
- ostruct/cli/security/errors.py +83 -103
- ostruct/cli/security/security_manager.py +22 -9
- ostruct/cli/serialization.py +25 -0
- ostruct/cli/template_filters.py +5 -3
- ostruct/cli/template_rendering.py +46 -22
- ostruct/cli/template_utils.py +12 -4
- ostruct/cli/template_validation.py +26 -8
- ostruct/cli/token_utils.py +43 -0
- ostruct/cli/validators.py +109 -0
- ostruct_cli-0.6.0.dist-info/METADATA +404 -0
- ostruct_cli-0.6.0.dist-info/RECORD +43 -0
- {ostruct_cli-0.4.0.dist-info → ostruct_cli-0.6.0.dist-info}/WHEEL +1 -1
- ostruct_cli-0.4.0.dist-info/METADATA +0 -186
- ostruct_cli-0.4.0.dist-info/RECORD +0 -36
- {ostruct_cli-0.4.0.dist-info → ostruct_cli-0.6.0.dist-info}/LICENSE +0 -0
- {ostruct_cli-0.4.0.dist-info → ostruct_cli-0.6.0.dist-info}/entry_points.txt +0 -0
@@ -1,186 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.3
|
2
|
-
Name: ostruct-cli
|
3
|
-
Version: 0.4.0
|
4
|
-
Summary: CLI for OpenAI Structured Output
|
5
|
-
Author: Yaniv Golan
|
6
|
-
Author-email: yaniv@golan.name
|
7
|
-
Requires-Python: >=3.9,<4.0
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
9
|
-
Classifier: Programming Language :: Python :: 3.9
|
10
|
-
Classifier: Programming Language :: Python :: 3.10
|
11
|
-
Classifier: Programming Language :: Python :: 3.11
|
12
|
-
Classifier: Programming Language :: Python :: 3.12
|
13
|
-
Classifier: Programming Language :: Python :: 3.13
|
14
|
-
Requires-Dist: cachetools (>=5.3.2,<6.0.0)
|
15
|
-
Requires-Dist: chardet (>=5.0.0,<6.0.0)
|
16
|
-
Requires-Dist: click (>=8.1.7,<9.0.0)
|
17
|
-
Requires-Dist: ijson (>=3.2.3,<4.0.0)
|
18
|
-
Requires-Dist: jsonschema (>=4.23.0,<5.0.0)
|
19
|
-
Requires-Dist: openai (>=1.0.0,<2.0.0)
|
20
|
-
Requires-Dist: openai-structured (>=1.3.0,<2.0.0)
|
21
|
-
Requires-Dist: pydantic (>=2.6.3,<3.0.0)
|
22
|
-
Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
|
23
|
-
Requires-Dist: tiktoken (>=0.8.0,<0.9.0)
|
24
|
-
Requires-Dist: tomli (>=2.0.1,<3.0.0) ; python_version < "3.11"
|
25
|
-
Requires-Dist: typing-extensions (>=4.9.0,<5.0.0)
|
26
|
-
Requires-Dist: werkzeug (>=3.1.3,<4.0.0)
|
27
|
-
Description-Content-Type: text/markdown
|
28
|
-
|
29
|
-
# ostruct-cli
|
30
|
-
|
31
|
-
[](https://badge.fury.io/py/ostruct-cli)
|
32
|
-
[](https://pypi.org/project/ostruct-cli)
|
33
|
-
[](https://ostruct.readthedocs.io/en/latest/?badge=latest)
|
34
|
-
[](https://github.com/yaniv-golan/ostruct/actions/workflows/ci.yml)
|
35
|
-
[](https://opensource.org/licenses/MIT)
|
36
|
-
|
37
|
-
Command-line interface for working with OpenAI models and structured output, powered by the [openai-structured](https://github.com/yaniv-golan/openai-structured) library.
|
38
|
-
|
39
|
-
## Features
|
40
|
-
|
41
|
-
- Generate structured output from natural language using OpenAI models
|
42
|
-
- Rich template system for defining output schemas
|
43
|
-
- Automatic token counting and context window management
|
44
|
-
- Streaming support for real-time output
|
45
|
-
- Caching system for cost optimization
|
46
|
-
- Secure handling of sensitive data
|
47
|
-
|
48
|
-
## Installation
|
49
|
-
|
50
|
-
```bash
|
51
|
-
pip install ostruct-cli
|
52
|
-
```
|
53
|
-
|
54
|
-
## Quick Start
|
55
|
-
|
56
|
-
1. Set your OpenAI API key:
|
57
|
-
|
58
|
-
```bash
|
59
|
-
export OPENAI_API_KEY=your-api-key
|
60
|
-
```
|
61
|
-
|
62
|
-
2. Create a task template file `task.j2`:
|
63
|
-
|
64
|
-
```
|
65
|
-
Extract information about the person: {{ stdin }}
|
66
|
-
```
|
67
|
-
|
68
|
-
3. Create a schema file `schema.json`:
|
69
|
-
|
70
|
-
```json
|
71
|
-
{
|
72
|
-
"type": "object",
|
73
|
-
"properties": {
|
74
|
-
"name": {
|
75
|
-
"type": "string",
|
76
|
-
"description": "The person's full name"
|
77
|
-
},
|
78
|
-
"age": {
|
79
|
-
"type": "integer",
|
80
|
-
"description": "The person's age"
|
81
|
-
},
|
82
|
-
"occupation": {
|
83
|
-
"type": "string",
|
84
|
-
"description": "The person's job or profession"
|
85
|
-
}
|
86
|
-
},
|
87
|
-
"required": ["name", "age", "occupation"]
|
88
|
-
}
|
89
|
-
```
|
90
|
-
|
91
|
-
4. Run the CLI:
|
92
|
-
|
93
|
-
```bash
|
94
|
-
echo "John Smith is a 35 year old software engineer" | ostruct --task @task.j2 --schema schema.json
|
95
|
-
```
|
96
|
-
|
97
|
-
Output:
|
98
|
-
|
99
|
-
```json
|
100
|
-
{
|
101
|
-
"name": "John Smith",
|
102
|
-
"age": 35,
|
103
|
-
"occupation": "software engineer"
|
104
|
-
}
|
105
|
-
```
|
106
|
-
|
107
|
-
### About Template Files
|
108
|
-
|
109
|
-
Template files use the `.j2` extension to indicate they contain Jinja2 template syntax. This convention:
|
110
|
-
|
111
|
-
- Enables proper syntax highlighting in most editors
|
112
|
-
- Makes it clear the file contains template logic
|
113
|
-
- Follows industry standards for Jinja2 templates
|
114
|
-
|
115
|
-
While the CLI accepts templates with any extension (when prefixed with `@`), we recommend using `.j2` for better tooling support and clarity.
|
116
|
-
|
117
|
-
## Debug Options
|
118
|
-
|
119
|
-
- `--show-model-schema`: Display the generated Pydantic model schema
|
120
|
-
- `--debug-validation`: Show detailed schema validation debugging
|
121
|
-
- `--verbose-schema`: Enable verbose schema debugging output
|
122
|
-
- `--debug-openai-stream`: Enable low-level debug output for OpenAI streaming (very verbose)
|
123
|
-
- `--progress-level {none,basic,detailed}`: Set progress reporting level (default: basic)
|
124
|
-
|
125
|
-
All debug and error logs are written to:
|
126
|
-
|
127
|
-
- `~/.ostruct/logs/ostruct.log`: General application logs
|
128
|
-
- `~/.ostruct/logs/openai_stream.log`: OpenAI streaming operations logs
|
129
|
-
|
130
|
-
For more detailed documentation and examples, visit our [documentation](https://ostruct.readthedocs.io/).
|
131
|
-
|
132
|
-
## Development
|
133
|
-
|
134
|
-
To contribute or report issues, please visit our [GitHub repository](https://github.com/yaniv-golan/ostruct).
|
135
|
-
|
136
|
-
## Development Setup
|
137
|
-
|
138
|
-
1. Clone the repository:
|
139
|
-
|
140
|
-
```bash
|
141
|
-
git clone https://github.com/yanivgolan/ostruct.git
|
142
|
-
cd ostruct
|
143
|
-
```
|
144
|
-
|
145
|
-
2. Install Poetry if you haven't already:
|
146
|
-
|
147
|
-
```bash
|
148
|
-
curl -sSL https://install.python-poetry.org | python3 -
|
149
|
-
```
|
150
|
-
|
151
|
-
3. Install dependencies:
|
152
|
-
|
153
|
-
```bash
|
154
|
-
poetry install
|
155
|
-
```
|
156
|
-
|
157
|
-
4. Install openai-structured in editable mode:
|
158
|
-
|
159
|
-
```bash
|
160
|
-
poetry add --editable ../openai-structured # Adjust path as needed
|
161
|
-
```
|
162
|
-
|
163
|
-
5. Run tests:
|
164
|
-
|
165
|
-
```bash
|
166
|
-
poetry run pytest
|
167
|
-
```
|
168
|
-
|
169
|
-
## Contributing
|
170
|
-
|
171
|
-
Contributions are welcome! Please feel free to submit a Pull Request.
|
172
|
-
|
173
|
-
## License
|
174
|
-
|
175
|
-
This project is licensed under the MIT License - see the LICENSE file for details.
|
176
|
-
|
177
|
-
## Migration from openai-structured
|
178
|
-
|
179
|
-
If you were previously using the CLI bundled with openai-structured (pre-1.0.0), this is its new home. The migration is straightforward:
|
180
|
-
|
181
|
-
1. Update openai-structured to version 1.0.0 or later
|
182
|
-
2. Install ostruct-cli
|
183
|
-
3. Replace any `openai-structured` CLI commands with `ostruct`
|
184
|
-
|
185
|
-
The functionality remains the same, just moved to a dedicated package for better maintenance and focus.
|
186
|
-
|
@@ -1,36 +0,0 @@
|
|
1
|
-
ostruct/__init__.py,sha256=X6zo6V7ZNMv731Wi388aTVQngD1410ExGwGx4J6lpyo,187
|
2
|
-
ostruct/cli/__init__.py,sha256=sYHKT6o1kFy1acbXejzAvVm8Cy8U91Yf1l4DlzquHKg,409
|
3
|
-
ostruct/cli/cache_manager.py,sha256=ej3KrRfkKKZ_lEp2JswjbJ5bW2ncsvna9NeJu81cqqs,5192
|
4
|
-
ostruct/cli/cli.py,sha256=kh2_P8O7BAbu7qWB64d1qH0rgWSJZuyxn4MdXd13h4I,65574
|
5
|
-
ostruct/cli/click_options.py,sha256=rrx04tiZmOu2103k0WJMNtc4ZYGpDftD9DjtGCVaNW0,7551
|
6
|
-
ostruct/cli/errors.py,sha256=lr8c4nkRCZZ5QoWHMZxX4B22CNoaoL1JJx8Y8WTt53Y,10448
|
7
|
-
ostruct/cli/file_info.py,sha256=xafeONqhUC7D9OPVuDIlc-44KcrPjdEBVmHN69CEtzs,13838
|
8
|
-
ostruct/cli/file_list.py,sha256=OiOl0NfkrWipZEdtRAf4eDJGDo2kyWdurxmU2k4KaZ0,11438
|
9
|
-
ostruct/cli/file_utils.py,sha256=On5zjqTx0qKlcZBbt1SNaq7HXtEON5_vyeTFE4UsCFg,22075
|
10
|
-
ostruct/cli/path_utils.py,sha256=RzGO-QOrp__NtDcIfAjfKl71NSXz3m_pb07UybgF8ro,3681
|
11
|
-
ostruct/cli/progress.py,sha256=rj9nVEco5UeZORMbzd7mFJpFGJjbH9KbBFh5oTE5Anw,3415
|
12
|
-
ostruct/cli/security/__init__.py,sha256=CQpkCgTFYlA1p6atpQeNgIKtE4LZGUKt4EbytbGKpCs,846
|
13
|
-
ostruct/cli/security/allowed_checker.py,sha256=y_R1UIJeGr1Ah1jlsg8t6aO28DnOfLqSH0wqmlVhx5A,1369
|
14
|
-
ostruct/cli/security/case_manager.py,sha256=I_ZJSyntLuGx5qVzze559CI-OxsaNPSibkAN8zZ7PvE,2345
|
15
|
-
ostruct/cli/security/errors.py,sha256=hDYKxo7V600ibXtXbrDoCbLNL7MEkarZEQbO2QYfTnI,5859
|
16
|
-
ostruct/cli/security/normalization.py,sha256=qevvxW3hHDtD1cVvDym8LJEQD1AKenVB-0ZvjCYjn5E,5242
|
17
|
-
ostruct/cli/security/safe_joiner.py,sha256=PHowCeBAkfHfPqRwuO5Com0OemGuq3cHkdu2p9IYNT0,7107
|
18
|
-
ostruct/cli/security/security_manager.py,sha256=KkI-fApKoDfRD7HSlz_H5LrIMbM5Rz9aP727t4Q_b5g,12770
|
19
|
-
ostruct/cli/security/symlink_resolver.py,sha256=wtZdJ_T_0FOy6B1P5ty1odEXQk9vr8BzlWeAFD4huJE,16744
|
20
|
-
ostruct/cli/security/types.py,sha256=15yuG_T4CXyAFFFdSWLjVS7ACmDGIPXhQpZ8awcDwCQ,2991
|
21
|
-
ostruct/cli/security/windows_paths.py,sha256=qxC2H2kLwtmQ7YePYde3UrmOJcGnsLEebDLh242sUaI,13453
|
22
|
-
ostruct/cli/template_env.py,sha256=S2ZvxuMQMicodSVqUhrw0kOzbNmlpQjSHtWlOwjXCms,1538
|
23
|
-
ostruct/cli/template_extensions.py,sha256=tJN3HGAS2yzGI8Up6STPday8NVL0VV6UCClBrtDKYr0,1623
|
24
|
-
ostruct/cli/template_filters.py,sha256=wZiR08e2_2SW28B7_tTU3wiij_KTCx3CCvlg-P2q7mk,19126
|
25
|
-
ostruct/cli/template_io.py,sha256=yUWO-8rZnSdX97DTMSEX8fG9CP1ISsOhm2NZN3Fab9A,8821
|
26
|
-
ostruct/cli/template_rendering.py,sha256=GrQAcKpGe6QEjSVQkOjpegMcor9LzVUikGmmEVgiWCE,12391
|
27
|
-
ostruct/cli/template_schema.py,sha256=ckH4rUZnEgfm_BHS9LnMGr8LtDxRmZ0C6UBVrSp8KTc,19604
|
28
|
-
ostruct/cli/template_utils.py,sha256=QGgewxU_Tgn81J5U-Y4xfi67CkN2dEqXI7PsaNiI9es,7812
|
29
|
-
ostruct/cli/template_validation.py,sha256=q3ACw4TscdekJb3Z3CTYw0YPEYttqjKjm74ap4lWtU4,11737
|
30
|
-
ostruct/cli/utils.py,sha256=1UCl4rHjBWKR5EKugvlVGHiHjO3XXmqvkgeAUSyIPDU,831
|
31
|
-
ostruct/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
32
|
-
ostruct_cli-0.4.0.dist-info/LICENSE,sha256=QUOY6QCYVxAiH8vdrUTDqe3i9hQ5bcNczppDSVpLTjk,1068
|
33
|
-
ostruct_cli-0.4.0.dist-info/METADATA,sha256=Khg3pmpYFixNMW_RrpF9bfD_ZRJDjAqP4VDWDdMcBhY,5405
|
34
|
-
ostruct_cli-0.4.0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
35
|
-
ostruct_cli-0.4.0.dist-info/entry_points.txt,sha256=NFq9IuqHVTem0j9zKjV8C1si_zGcP1RL6Wbvt9fUDXw,48
|
36
|
-
ostruct_cli-0.4.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|