ostruct-cli 0.7.2__py3-none-any.whl → 0.8.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.
Files changed (46) hide show
  1. ostruct/cli/__init__.py +21 -3
  2. ostruct/cli/base_errors.py +1 -1
  3. ostruct/cli/cli.py +66 -1983
  4. ostruct/cli/click_options.py +460 -28
  5. ostruct/cli/code_interpreter.py +238 -0
  6. ostruct/cli/commands/__init__.py +32 -0
  7. ostruct/cli/commands/list_models.py +128 -0
  8. ostruct/cli/commands/quick_ref.py +50 -0
  9. ostruct/cli/commands/run.py +137 -0
  10. ostruct/cli/commands/update_registry.py +71 -0
  11. ostruct/cli/config.py +277 -0
  12. ostruct/cli/cost_estimation.py +134 -0
  13. ostruct/cli/errors.py +310 -6
  14. ostruct/cli/exit_codes.py +1 -0
  15. ostruct/cli/explicit_file_processor.py +548 -0
  16. ostruct/cli/field_utils.py +69 -0
  17. ostruct/cli/file_info.py +42 -9
  18. ostruct/cli/file_list.py +301 -102
  19. ostruct/cli/file_search.py +455 -0
  20. ostruct/cli/file_utils.py +47 -13
  21. ostruct/cli/mcp_integration.py +541 -0
  22. ostruct/cli/model_creation.py +150 -1
  23. ostruct/cli/model_validation.py +204 -0
  24. ostruct/cli/progress_reporting.py +398 -0
  25. ostruct/cli/registry_updates.py +14 -9
  26. ostruct/cli/runner.py +1418 -0
  27. ostruct/cli/schema_utils.py +113 -0
  28. ostruct/cli/services.py +626 -0
  29. ostruct/cli/template_debug.py +748 -0
  30. ostruct/cli/template_debug_help.py +162 -0
  31. ostruct/cli/template_env.py +15 -6
  32. ostruct/cli/template_filters.py +55 -3
  33. ostruct/cli/template_optimizer.py +474 -0
  34. ostruct/cli/template_processor.py +1080 -0
  35. ostruct/cli/template_rendering.py +69 -34
  36. ostruct/cli/token_validation.py +286 -0
  37. ostruct/cli/types.py +78 -0
  38. ostruct/cli/unattended_operation.py +269 -0
  39. ostruct/cli/validators.py +386 -3
  40. {ostruct_cli-0.7.2.dist-info → ostruct_cli-0.8.0.dist-info}/LICENSE +2 -0
  41. ostruct_cli-0.8.0.dist-info/METADATA +633 -0
  42. ostruct_cli-0.8.0.dist-info/RECORD +69 -0
  43. {ostruct_cli-0.7.2.dist-info → ostruct_cli-0.8.0.dist-info}/WHEEL +1 -1
  44. ostruct_cli-0.7.2.dist-info/METADATA +0 -370
  45. ostruct_cli-0.7.2.dist-info/RECORD +0 -45
  46. {ostruct_cli-0.7.2.dist-info → ostruct_cli-0.8.0.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,69 @@
1
+ ostruct/__init__.py,sha256=X6zo6V7ZNMv731Wi388aTVQngD1410ExGwGx4J6lpyo,187
2
+ ostruct/cli/__init__.py,sha256=e-DtWRviCr3fIAJH4cB4UAvles3-rqnhJaTOlBn9TKs,871
3
+ ostruct/cli/base_errors.py,sha256=o-877bJJA8yJWISRPy0KyL6wDu1-_avddmQIfVePuFM,5989
4
+ ostruct/cli/cache_manager.py,sha256=ej3KrRfkKKZ_lEp2JswjbJ5bW2ncsvna9NeJu81cqqs,5192
5
+ ostruct/cli/cli.py,sha256=yv-0O3vLrEgWFyu8T3lzAEzpH6GDIEeU0LT4S9CqtOQ,4086
6
+ ostruct/cli/click_options.py,sha256=f2a6XTidy-RJgL64WAgTqRYpMPokY0O8Bb6aQgwMOtk,28298
7
+ ostruct/cli/code_interpreter.py,sha256=sEq-zi0CfotRqEseA9pWTm-UU1fZTH_06WGvWPNwct8,7786
8
+ ostruct/cli/commands/__init__.py,sha256=3NHz-WZ9XqrnWWMksoV2MpYpHnjA-EO9lsrBOYeHcjY,723
9
+ ostruct/cli/commands/list_models.py,sha256=yeuQpUGAmRr4uOHS7teuVHkC9dkqN0yKDOEw_n-ehi0,4662
10
+ ostruct/cli/commands/quick_ref.py,sha256=DLKDHjhG1AOLRL68fOiRcnSLMlu-HdRBpLc91T_vuTk,1798
11
+ ostruct/cli/commands/run.py,sha256=1M5KYhXPLJLFVbfGJHRp88kO25CSN6TP1A0cVex1-7A,4370
12
+ ostruct/cli/commands/update_registry.py,sha256=7DQrPlCJScPVgE2HbFAM7UMap-EdYu58AQWfpI-H7Gw,2483
13
+ ostruct/cli/config.py,sha256=keX5mUiyZ9_CrVHZFpxr7loBAetORRW-ZjNUoQFa_k8,9030
14
+ ostruct/cli/cost_estimation.py,sha256=08hyE-kM5QYzj7y-KB3lMD_RxCMoM_Ve3-IQlSpJAo4,4483
15
+ ostruct/cli/errors.py,sha256=WUa_LwwBMynrP9WVgS199ovir1XJFLZIRw5QoPRLVwY,25145
16
+ ostruct/cli/exit_codes.py,sha256=gdvB1dpu0LalEUZrofpk5K6aTQ24n5AfkAK5umludHU,365
17
+ ostruct/cli/explicit_file_processor.py,sha256=B6yUPbyn6MVd81GcyMVpORFwyaHFFESLwFixp2B6M5w,19767
18
+ ostruct/cli/field_utils.py,sha256=bcRi1qQ0Ac2UCfrKSQ677_yu-VzaShm_zN7QLf98qc0,1939
19
+ ostruct/cli/file_info.py,sha256=Vgx-unid2ODSYbJxzgC2ndEeh-DS6eADsrqG34_C820,16182
20
+ ostruct/cli/file_list.py,sha256=alRAguq4tj1zH0_qlWaRoyHo1G1Xmxqu9Xd4QP-zYP0,20268
21
+ ostruct/cli/file_search.py,sha256=N12mkji2ttvItLVPyAWE3KEfhTv8hV5IXPrQME2UFdE,15313
22
+ ostruct/cli/file_utils.py,sha256=kLZKiZadkIiYvs3B_gngqf_PwMRMYIWw49i8GTGVbkk,23607
23
+ ostruct/cli/mcp_integration.py,sha256=EXIz_KbYC4srWZxuKVkINeaHgHvEYB9l1uhptpLNn5I,18774
24
+ ostruct/cli/model_creation.py,sha256=l-FHxCaAmZ2akKszoRg8gf1KgJxeT10Pt8YX39bXeT4,23261
25
+ ostruct/cli/model_validation.py,sha256=j2az3q88-Ljm2cMMgZ8p_-gcp1vKQnWCknnw0y0YlAw,6675
26
+ ostruct/cli/path_utils.py,sha256=j44q1OoLkqMErgK-qEuhuIZ1VyzqRIvNgxR1et9PoXA,4813
27
+ ostruct/cli/progress.py,sha256=rj9nVEco5UeZORMbzd7mFJpFGJjbH9KbBFh5oTE5Anw,3415
28
+ ostruct/cli/progress_reporting.py,sha256=MBjALM4pmPd_d9YuXqH162-tkC6DDKYmz-pJPSGLTfk,13669
29
+ ostruct/cli/registry_updates.py,sha256=ohiHdlfrocvThpR_ZjMyqulDKFjRM1hIFKOlNzpaqHg,5138
30
+ ostruct/cli/runner.py,sha256=pNw0TzdpDElzaUYxb8R-rzSPqa1MOzUM-hPaOvpETI4,54045
31
+ ostruct/cli/schema_utils.py,sha256=9LnsjxEKg6RIfXQB3nS3pyDggm5n-4-thXf92897gJU,3590
32
+ ostruct/cli/schema_validation.py,sha256=ohEuxJ0KF93qphj0JSZDnrxDn0C2ZU37g-U2JY03onM,8154
33
+ ostruct/cli/security/__init__.py,sha256=CQpkCgTFYlA1p6atpQeNgIKtE4LZGUKt4EbytbGKpCs,846
34
+ ostruct/cli/security/allowed_checker.py,sha256=N5UXlpjdj5zAbKk-lRDlHiHV3KtQHtJNhtZI_qGB4zw,1638
35
+ ostruct/cli/security/base.py,sha256=q9YUdHEj2eg5w8GEw5403E9OQKIjZbEiaWsvYFnCGLw,1359
36
+ ostruct/cli/security/case_manager.py,sha256=I_ZJSyntLuGx5qVzze559CI-OxsaNPSibkAN8zZ7PvE,2345
37
+ ostruct/cli/security/errors.py,sha256=8jYJFRQyEXIH3Wd2ATWORVoqbDg7qwu0TsuROpsqNfU,5254
38
+ ostruct/cli/security/normalization.py,sha256=ULvFopRLiUMC86yGxge5Jzjbvc64C_j2QlD5smKPjEI,5286
39
+ ostruct/cli/security/safe_joiner.py,sha256=PHowCeBAkfHfPqRwuO5Com0OemGuq3cHkdu2p9IYNT0,7107
40
+ ostruct/cli/security/security_manager.py,sha256=HFCqJ5kAhaZlFnPTEs6MKNM8JeE2q79db9jW-cHIvxw,15242
41
+ ostruct/cli/security/symlink_resolver.py,sha256=wtZdJ_T_0FOy6B1P5ty1odEXQk9vr8BzlWeAFD4huJE,16744
42
+ ostruct/cli/security/types.py,sha256=15yuG_T4CXyAFFFdSWLjVS7ACmDGIPXhQpZ8awcDwCQ,2991
43
+ ostruct/cli/security/windows_paths.py,sha256=qxC2H2kLwtmQ7YePYde3UrmOJcGnsLEebDLh242sUaI,13453
44
+ ostruct/cli/serialization.py,sha256=ec0UswDE2onwtZVUoZaMCsGv6zW_tSKdBng2qVo6Ucs,704
45
+ ostruct/cli/services.py,sha256=nLYUbF3DDNuilh7j9q_atUOjTAWta7bxTS3G-zkveaA,21621
46
+ ostruct/cli/template_debug.py,sha256=1tP3pTdvQwHcMneYnpWnS2Jr5EQijjyCSQDh5DPXvDE,24698
47
+ ostruct/cli/template_debug_help.py,sha256=7TKiUV07Y2RS9nMgMURDN6LRip1ZHezzsI7XQngB7J0,6099
48
+ ostruct/cli/template_env.py,sha256=7ZcGKyqlkV-ZS2sSUvzyaLsnlvPmfCKUG0epIV8TD6o,1893
49
+ ostruct/cli/template_extensions.py,sha256=_lomtDGMGxMfpw05v_-daJ0JbhRm_r_-uEJlPAjbpkI,2699
50
+ ostruct/cli/template_filters.py,sha256=S9ad8she0lXRr0PDQVkNrPWbZg7GnybptEXUMkQKOyo,20657
51
+ ostruct/cli/template_io.py,sha256=yUWO-8rZnSdX97DTMSEX8fG9CP1ISsOhm2NZN3Fab9A,8821
52
+ ostruct/cli/template_optimizer.py,sha256=_eQbHQP6fH5tbWLwXtLSLDYlGQ8hLpZKVgXsbcWF2xY,16394
53
+ ostruct/cli/template_processor.py,sha256=AWtWEpJvCCFB1PzoDp6EovV4RaIMbY316cb-Iq5o48c,41726
54
+ ostruct/cli/template_rendering.py,sha256=5i7gtFjW2QKVW3e_xK0Llrurn0I4e_gG0gzn2p9IFTc,15030
55
+ ostruct/cli/template_schema.py,sha256=ckH4rUZnEgfm_BHS9LnMGr8LtDxRmZ0C6UBVrSp8KTc,19604
56
+ ostruct/cli/template_utils.py,sha256=MZdXXjL-x-IXX-5Y8GWopGNBkDE2ItLdCuCl0QWFR_U,14968
57
+ ostruct/cli/template_validation.py,sha256=AXa2zmsws1j-0CTFlp7fMiZR43iNLnj4h467up2JdgU,12693
58
+ ostruct/cli/token_utils.py,sha256=r4KPEO3Sec18Q6mU0aClK6XGShvusgUggXEQgEPPlaA,1369
59
+ ostruct/cli/token_validation.py,sha256=gmyPJ7B2gC_jSx_1wKZq87DEoFulj23X1XnVpO_aRNA,9930
60
+ ostruct/cli/types.py,sha256=vCZFBUkeL1QUBM5tTSjEWf_5BUttlyC40kFfpNfTrrY,2474
61
+ ostruct/cli/unattended_operation.py,sha256=kI95SSVJC_taxORXQYrce_qLEnuKc6edwn9tMOye-qs,9383
62
+ ostruct/cli/utils.py,sha256=uY7c0NaINHWfnl77FcPE3TmYUXv3RqEeUTjrCMDij9A,922
63
+ ostruct/cli/validators.py,sha256=lbxAUUVS5TPJ7HdYZ5yB7gUjJqfcClZCuh0oktoq0E0,15291
64
+ ostruct/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
65
+ ostruct_cli-0.8.0.dist-info/LICENSE,sha256=DmGAkaYzhrdzTB9Y2Rvfzd3mJiF9ZrTOhxN8t6wrfHA,1098
66
+ ostruct_cli-0.8.0.dist-info/METADATA,sha256=cMBZoX3RLP8GYAa7rFYkPuub43jMFeQpFPBtaga4iDI,21657
67
+ ostruct_cli-0.8.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
68
+ ostruct_cli-0.8.0.dist-info/entry_points.txt,sha256=NFq9IuqHVTem0j9zKjV8C1si_zGcP1RL6Wbvt9fUDXw,48
69
+ ostruct_cli-0.8.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.1.1
2
+ Generator: poetry-core 2.1.3
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,370 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: ostruct-cli
3
- Version: 0.7.2
4
- Summary: CLI for OpenAI Structured Output
5
- Author: Yaniv Golan
6
- Author-email: yaniv@golan.name
7
- Requires-Python: >=3.10,<4.0
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: Programming Language :: Python :: 3.10
10
- Classifier: Programming Language :: Python :: 3.11
11
- Classifier: Programming Language :: Python :: 3.12
12
- Classifier: Programming Language :: Python :: 3.13
13
- Requires-Dist: cachetools (>=5.3.2,<6.0.0)
14
- Requires-Dist: chardet (>=5.0.0,<6.0.0)
15
- Requires-Dist: click (>=8.1.7,<9.0.0)
16
- Requires-Dist: ijson (>=3.2.3,<4.0.0)
17
- Requires-Dist: jinja2 (>=3.1.2,<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 (>=3.0.0,<4.0.0)
21
- Requires-Dist: pydantic (>=2.6.3,<3.0.0)
22
- Requires-Dist: pygments (>=2.15.0,<3.0.0)
23
- Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
24
- Requires-Dist: tiktoken (==0.9.0)
25
- Requires-Dist: tomli (>=2.0.1,<3.0.0) ; python_version < "3.11"
26
- Requires-Dist: typing-extensions (>=4.9.0,<5.0.0)
27
- Requires-Dist: werkzeug (>=3.1.3,<4.0.0)
28
- Description-Content-Type: text/markdown
29
-
30
- ![ostruct](src/assets/ostruct-header.png)
31
-
32
- <div align="center">
33
-
34
- [![PyPI version](https://badge.fury.io/py/ostruct-cli.svg)](https://badge.fury.io/py/ostruct-cli)
35
- [![Python Versions](https://img.shields.io/pypi/pyversions/ostruct-cli.svg)](https://pypi.org/project/ostruct-cli)
36
- [![Documentation Status](https://readthedocs.org/projects/ostruct/badge/?version=latest)](https://ostruct.readthedocs.io/en/latest/?badge=latest)
37
- [![CI](https://github.com/yaniv-golan/ostruct/actions/workflows/ci.yml/badge.svg)](https://github.com/yaniv-golan/ostruct/actions/workflows/ci.yml)
38
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
39
-
40
- **ostruct** tranforms **unstructured** inputs into **structured**, usable **JSON** output using **OpenAI APIs** using dynamic **templates**
41
-
42
- </div>
43
-
44
- # ostruct-cli
45
-
46
- ostruct will process a set of plain text files (data, source code, CSV, etc), input variables, a dynamic prompt template, and a JSON schema specifying the desired output format, and will produce the result in JSON format.
47
-
48
- <div align="center">
49
-
50
- ![How ostruct works](src/assets/ostrict-hl-diagram.png)
51
-
52
- </div>
53
-
54
- ## Why ostruct?
55
-
56
- LLMs are powerful, but getting consistent, structured output from them can be challenging. ostruct solves this problem by providing a streamlined approach to transform unstructured data into reliable JSON structures. The motivation behind creating ostruct was to:
57
-
58
- - **Bridge the gap** between freeform LLM capabilities and structured data needs in production systems
59
- - **Simplify integration** of AI into existing workflows and applications that expect consistent data formats
60
- - **Ensure reliability** and validate output against a defined schema to avoid unexpected formats or missing data
61
- - **Reduce development time** by providing a standardized way to interact with OpenAI models for structured outputs
62
- - **Enable non-developers** to leverage AI capabilities through a simple CLI interface with templates
63
-
64
- ## Real-World Use Cases
65
-
66
- ostruct can be used for various scenarios, including:
67
-
68
- ### Etymology Analysis
69
-
70
- ```bash
71
- ostruct run prompts/task.j2 schemas/etymology.json -f input examples/scientific.txt --model gpt-4o
72
- ```
73
-
74
- Break down words into their components, showing their origins, meanings, and hierarchical relationships. Useful for linguistics, educational tools, and understanding terminology in specialized fields.
75
-
76
- ### Automated Code Review
77
-
78
- ```bash
79
- ostruct run prompts/task.j2 schemas/code_review.json -p source "examples/security/*.py" --model gpt-4o
80
- ```
81
-
82
- Analyze code for security vulnerabilities, style issues, and performance problems, producing structured reports that can be easily integrated into CI/CD pipelines or developer workflows.
83
-
84
- ### Security Vulnerability Scanning
85
-
86
- ```bash
87
- ostruct run prompts/task.j2 schemas/scan_result.json -d examples/intermediate --model gpt-4o
88
- ```
89
-
90
- Scan codebases for security vulnerabilities, combining static analysis with AI-powered reasoning to identify potential issues, suggest fixes, and provide detailed explanations.
91
-
92
- ### Configuration Validation & Analysis
93
-
94
- ```bash
95
- ostruct run prompts/task.j2 schemas/validation_result.json -f dev examples/basic/dev.yaml -f prod examples/basic/prod.yaml
96
- ```
97
-
98
- Validate configuration files across environments, check for inconsistencies, and provide intelligent feedback on potential issues or improvements in infrastructure setups.
99
-
100
- ## Features
101
-
102
- - Generate structured JSON output from natural language using OpenAI models and a JSON schema
103
- - Rich template system for defining prompts (Jinja2-based)
104
- - Automatic token counting and context window management
105
- - Streaming support for real-time output
106
- - Secure handling of sensitive data
107
- - Model registry management with support for updating to the latest OpenAI models
108
- - Non-intrusive registry update checks with user notifications
109
-
110
- ## Requirements
111
-
112
- - Python 3.10 or higher
113
-
114
- ## Installation
115
-
116
- ### For Users
117
-
118
- To install the latest stable version from PyPI:
119
-
120
- ```bash
121
- pip install ostruct-cli
122
- ```
123
-
124
- ### For Developers
125
-
126
- If you plan to contribute to the project, see the [Development Setup](#development-setup) section below for instructions on setting up the development environment with Poetry.
127
-
128
- ## Environment Variables
129
-
130
- ostruct-cli respects the following environment variables:
131
-
132
- - `OPENAI_API_KEY`: Your OpenAI API key (required unless provided via command line)
133
- - `OPENAI_API_BASE`: Custom API base URL (optional)
134
- - `OPENAI_API_VERSION`: API version to use (optional)
135
- - `OPENAI_API_TYPE`: API type (e.g., "azure") (optional)
136
- - `OSTRUCT_DISABLE_UPDATE_CHECKS`: Set to "1", "true", or "yes" to disable automatic registry update checks
137
-
138
- ## Shell Completion
139
-
140
- ostruct-cli supports shell completion for Bash, Zsh, and Fish shells. To enable it:
141
-
142
- ### Bash
143
-
144
- Add this to your `~/.bashrc`:
145
-
146
- ```bash
147
- eval "$(_OSTRUCT_COMPLETE=bash_source ostruct)"
148
- ```
149
-
150
- ### Zsh
151
-
152
- Add this to your `~/.zshrc`:
153
-
154
- ```bash
155
- eval "$(_OSTRUCT_COMPLETE=zsh_source ostruct)"
156
- ```
157
-
158
- ### Fish
159
-
160
- Add this to your `~/.config/fish/completions/ostruct.fish`:
161
-
162
- ```fish
163
- eval (env _OSTRUCT_COMPLETE=fish_source ostruct)
164
- ```
165
-
166
- After adding the appropriate line, restart your shell or source the configuration file.
167
- Shell completion will help you with:
168
-
169
- - Command options and their arguments
170
- - File paths for template and schema files
171
- - Directory paths for `-d` and `--base-dir` options
172
- - And more!
173
-
174
- ## Quick Start
175
-
176
- 1. Set your OpenAI API key:
177
-
178
- ```bash
179
- export OPENAI_API_KEY=your-api-key
180
- ```
181
-
182
- ### Example 1: Using stdin (Simplest)
183
-
184
- 1. Create a template file `extract_person.j2`:
185
-
186
- ```jinja
187
- Extract information about the person from this text: {{ stdin }}
188
- ```
189
-
190
- 2. Create a schema file `schema.json`:
191
-
192
- ```json
193
- {
194
- "type": "object",
195
- "properties": {
196
- "person": {
197
- "type": "object",
198
- "properties": {
199
- "name": {
200
- "type": "string",
201
- "description": "The person's full name"
202
- },
203
- "age": {
204
- "type": "integer",
205
- "description": "The person's age"
206
- },
207
- "occupation": {
208
- "type": "string",
209
- "description": "The person's job or profession"
210
- }
211
- },
212
- "required": ["name", "age", "occupation"],
213
- "additionalProperties": false
214
- }
215
- },
216
- "required": ["person"],
217
- "additionalProperties": false
218
- }
219
- ```
220
-
221
- 3. Run the CLI:
222
-
223
- ```bash
224
- # Basic usage
225
- echo "John Smith is a 35-year-old software engineer" | ostruct run extract_person.j2 schema.json
226
-
227
- # For longer text using heredoc
228
- cat << EOF | ostruct run extract_person.j2 schema.json
229
- John Smith is a 35-year-old software engineer
230
- working at Tech Corp. He has been programming
231
- for over 10 years.
232
- EOF
233
-
234
- # With advanced options
235
- echo "John Smith is a 35-year-old software engineer" | \
236
- ostruct run extract_person.j2 schema.json \
237
- --model gpt-4o \
238
- --sys-prompt "Extract precise information about the person" \
239
- --temperature 0.7
240
- ```
241
-
242
- The command will output:
243
-
244
- ```json
245
- {
246
- "person": {
247
- "name": "John Smith",
248
- "age": 35,
249
- "occupation": "software engineer"
250
- }
251
- }
252
- ```
253
-
254
- ### Example 2: Processing a Single File
255
-
256
- 1. Create a template file `extract_from_file.j2`:
257
-
258
- ```jinja
259
- Extract information about the person from this text: {{ text.content }}
260
- ```
261
-
262
- 2. Use the same schema file `schema.json` as above.
263
-
264
- 3. Run the CLI:
265
-
266
- ```bash
267
- # Basic usage
268
- ostruct run extract_from_file.j2 schema.json -f text input.txt
269
-
270
- # With advanced options
271
- ostruct run extract_from_file.j2 schema.json \
272
- -f text input.txt \
273
- --model gpt-4o \
274
- --max-output-tokens 1000 \
275
- --temperature 0.7
276
- ```
277
-
278
- The command will output:
279
-
280
- ```json
281
- {
282
- "person": {
283
- "name": "John Smith",
284
- "age": 35,
285
- "occupation": "software engineer"
286
- }
287
- }
288
- ```
289
-
290
- ## System Prompt Handling
291
-
292
- ostruct-cli provides three ways to specify a system prompt, with a clear precedence order:
293
-
294
- 1. Command-line option (`--sys-prompt` or `--sys-file`):
295
-
296
- ```bash
297
- # Direct string
298
- ostruct run template.j2 schema.json --sys-prompt "You are an expert analyst"
299
-
300
- # From file
301
- ostruct run template.j2 schema.json --sys-file system_prompt.txt
302
- ```
303
-
304
- 2. Template frontmatter:
305
-
306
- ```jinja
307
- ---
308
- system_prompt: You are an expert analyst
309
- ---
310
- Extract information from: {{ text }}
311
- ```
312
-
313
- 3. Default system prompt (built into the CLI)
314
-
315
- ### Precedence Rules
316
-
317
- When multiple system prompts are provided, they are resolved in this order:
318
-
319
- 1. Command-line options take highest precedence:
320
- - If both `--sys-prompt` and `--sys-file` are provided, `--sys-prompt` wins
321
- - Use `--ignore-task-sysprompt` to ignore template frontmatter
322
-
323
- 2. Template frontmatter is used if:
324
- - No command-line options are provided
325
- - `--ignore-task-sysprompt` is not set
326
-
327
- 3. Default system prompt is used only if no other prompts are provided
328
-
329
- Example combining multiple sources:
330
-
331
- ```bash
332
- # Command-line prompt will override template frontmatter
333
- ostruct run template.j2 schema.json --sys-prompt "Override prompt"
334
-
335
- # Ignore template frontmatter and use default
336
- ostruct run template.j2 schema.json --ignore-task-sysprompt
337
- ```
338
-
339
- ## Model Registry Management
340
-
341
- ostruct-cli maintains a registry of OpenAI models and their capabilities, which includes:
342
-
343
- - Context window sizes for each model
344
- - Maximum output token limits
345
- - Supported parameters and their constraints
346
- - Model version information
347
-
348
- To ensure you're using the latest models and features, you can update the registry:
349
-
350
- ```bash
351
- # Update from the official repository
352
- ostruct update-registry
353
-
354
- # Update from a custom URL
355
- ostruct update-registry --url https://example.com/models.yml
356
-
357
- # Force an update even if the registry is current
358
- ostruct update-registry --force
359
- ```
360
-
361
- This is especially useful when:
362
-
363
- - New OpenAI models are released
364
- - Model capabilities or parameters change
365
- - You need to work with custom model configurations
366
-
367
- The registry file is stored at `~/.openai_structured/config/models.yml` and is automatically referenced when validating model parameters and token limits.
368
-
369
- The update command uses HTTP conditional requests (If-Modified-Since headers) to check if the remote registry has changed before downloading, ensuring efficient updates.
370
-
@@ -1,45 +0,0 @@
1
- ostruct/__init__.py,sha256=X6zo6V7ZNMv731Wi388aTVQngD1410ExGwGx4J6lpyo,187
2
- ostruct/cli/__init__.py,sha256=IfQ68CRqPEeCP4zxV1DxowSEWFKhZiB8swMAOZJOXa8,494
3
- ostruct/cli/base_errors.py,sha256=S1cQxoiALbXKPxzgLo6XdSWpzPRb7RKz0QARmu9Zt4g,5987
4
- ostruct/cli/cache_manager.py,sha256=ej3KrRfkKKZ_lEp2JswjbJ5bW2ncsvna9NeJu81cqqs,5192
5
- ostruct/cli/cli.py,sha256=WqVToFC4mt4qXeaW0pGRmakGal8vxxH0ny_BHNMKh5M,69645
6
- ostruct/cli/click_options.py,sha256=WbRJdB9sO63ChN3fnCP7XWs73DHKl0C1ervfwL11am0,11371
7
- ostruct/cli/errors.py,sha256=UytzS6RKOFMpB3GCJl73M93k74cutKOTFo5RDM4PTE0,15292
8
- ostruct/cli/exit_codes.py,sha256=uNjvQeUGwU1mlUJYIDrExAn7YlwOXZo603yLAwpqIwk,338
9
- ostruct/cli/file_info.py,sha256=ilpT8IuckfhadLF1QQAPLXJp7p8kVpffDEEJ2erHPZU,14485
10
- ostruct/cli/file_list.py,sha256=jLuCd1ardoAXX8FNwPgIqEM-ixzr1xP5ZSqXo2lmrj0,11270
11
- ostruct/cli/file_utils.py,sha256=J3-6fbEGQ7KD_bU81pAxueHLv9XV0X7f8FSMt_0AJGQ,22537
12
- ostruct/cli/model_creation.py,sha256=UdXT3657rC5t-aZAZkQDuIdaQWSY9P6vgHKNAoFUWVw,16768
13
- ostruct/cli/path_utils.py,sha256=j44q1OoLkqMErgK-qEuhuIZ1VyzqRIvNgxR1et9PoXA,4813
14
- ostruct/cli/progress.py,sha256=rj9nVEco5UeZORMbzd7mFJpFGJjbH9KbBFh5oTE5Anw,3415
15
- ostruct/cli/registry_updates.py,sha256=H0-Ftz4TvzryS2Qyoei7k2GKiY_s0Qr17i6pqrRmgF0,4921
16
- ostruct/cli/schema_validation.py,sha256=ohEuxJ0KF93qphj0JSZDnrxDn0C2ZU37g-U2JY03onM,8154
17
- ostruct/cli/security/__init__.py,sha256=CQpkCgTFYlA1p6atpQeNgIKtE4LZGUKt4EbytbGKpCs,846
18
- ostruct/cli/security/allowed_checker.py,sha256=N5UXlpjdj5zAbKk-lRDlHiHV3KtQHtJNhtZI_qGB4zw,1638
19
- ostruct/cli/security/base.py,sha256=q9YUdHEj2eg5w8GEw5403E9OQKIjZbEiaWsvYFnCGLw,1359
20
- ostruct/cli/security/case_manager.py,sha256=I_ZJSyntLuGx5qVzze559CI-OxsaNPSibkAN8zZ7PvE,2345
21
- ostruct/cli/security/errors.py,sha256=8jYJFRQyEXIH3Wd2ATWORVoqbDg7qwu0TsuROpsqNfU,5254
22
- ostruct/cli/security/normalization.py,sha256=ULvFopRLiUMC86yGxge5Jzjbvc64C_j2QlD5smKPjEI,5286
23
- ostruct/cli/security/safe_joiner.py,sha256=PHowCeBAkfHfPqRwuO5Com0OemGuq3cHkdu2p9IYNT0,7107
24
- ostruct/cli/security/security_manager.py,sha256=HFCqJ5kAhaZlFnPTEs6MKNM8JeE2q79db9jW-cHIvxw,15242
25
- ostruct/cli/security/symlink_resolver.py,sha256=wtZdJ_T_0FOy6B1P5ty1odEXQk9vr8BzlWeAFD4huJE,16744
26
- ostruct/cli/security/types.py,sha256=15yuG_T4CXyAFFFdSWLjVS7ACmDGIPXhQpZ8awcDwCQ,2991
27
- ostruct/cli/security/windows_paths.py,sha256=qxC2H2kLwtmQ7YePYde3UrmOJcGnsLEebDLh242sUaI,13453
28
- ostruct/cli/serialization.py,sha256=ec0UswDE2onwtZVUoZaMCsGv6zW_tSKdBng2qVo6Ucs,704
29
- ostruct/cli/template_env.py,sha256=S2ZvxuMQMicodSVqUhrw0kOzbNmlpQjSHtWlOwjXCms,1538
30
- ostruct/cli/template_extensions.py,sha256=_lomtDGMGxMfpw05v_-daJ0JbhRm_r_-uEJlPAjbpkI,2699
31
- ostruct/cli/template_filters.py,sha256=SjuQxlM5S283TS2El_AbrzETGnYoQeTpmA9sv5et3QI,19222
32
- ostruct/cli/template_io.py,sha256=yUWO-8rZnSdX97DTMSEX8fG9CP1ISsOhm2NZN3Fab9A,8821
33
- ostruct/cli/template_rendering.py,sha256=vp_4gvrYLd_kbQi3TYrYNniXLTeLmTaitGVBQManXvo,13342
34
- ostruct/cli/template_schema.py,sha256=ckH4rUZnEgfm_BHS9LnMGr8LtDxRmZ0C6UBVrSp8KTc,19604
35
- ostruct/cli/template_utils.py,sha256=MZdXXjL-x-IXX-5Y8GWopGNBkDE2ItLdCuCl0QWFR_U,14968
36
- ostruct/cli/template_validation.py,sha256=AXa2zmsws1j-0CTFlp7fMiZR43iNLnj4h467up2JdgU,12693
37
- ostruct/cli/token_utils.py,sha256=r4KPEO3Sec18Q6mU0aClK6XGShvusgUggXEQgEPPlaA,1369
38
- ostruct/cli/utils.py,sha256=uY7c0NaINHWfnl77FcPE3TmYUXv3RqEeUTjrCMDij9A,922
39
- ostruct/cli/validators.py,sha256=k-vmBjkPmC-VwSTM5Yq1zQjGSIOzzTHS4kc0B7Aqpck,3186
40
- ostruct/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
- ostruct_cli-0.7.2.dist-info/LICENSE,sha256=QUOY6QCYVxAiH8vdrUTDqe3i9hQ5bcNczppDSVpLTjk,1068
42
- ostruct_cli-0.7.2.dist-info/METADATA,sha256=iJHa7gp6eLDvHQMKtuReyMRPmgJESKiNzx-PHMxw9d0,11154
43
- ostruct_cli-0.7.2.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
44
- ostruct_cli-0.7.2.dist-info/entry_points.txt,sha256=NFq9IuqHVTem0j9zKjV8C1si_zGcP1RL6Wbvt9fUDXw,48
45
- ostruct_cli-0.7.2.dist-info/RECORD,,