ostruct-cli 0.7.1__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.
- ostruct/cli/__init__.py +21 -3
- ostruct/cli/base_errors.py +1 -1
- ostruct/cli/cli.py +66 -1983
- ostruct/cli/click_options.py +460 -28
- ostruct/cli/code_interpreter.py +238 -0
- ostruct/cli/commands/__init__.py +32 -0
- ostruct/cli/commands/list_models.py +128 -0
- ostruct/cli/commands/quick_ref.py +50 -0
- ostruct/cli/commands/run.py +137 -0
- ostruct/cli/commands/update_registry.py +71 -0
- ostruct/cli/config.py +277 -0
- ostruct/cli/cost_estimation.py +134 -0
- ostruct/cli/errors.py +310 -6
- ostruct/cli/exit_codes.py +1 -0
- ostruct/cli/explicit_file_processor.py +548 -0
- ostruct/cli/field_utils.py +69 -0
- ostruct/cli/file_info.py +42 -9
- ostruct/cli/file_list.py +301 -102
- ostruct/cli/file_search.py +455 -0
- ostruct/cli/file_utils.py +47 -13
- ostruct/cli/mcp_integration.py +541 -0
- ostruct/cli/model_creation.py +150 -1
- ostruct/cli/model_validation.py +204 -0
- ostruct/cli/progress_reporting.py +398 -0
- ostruct/cli/registry_updates.py +14 -9
- ostruct/cli/runner.py +1418 -0
- ostruct/cli/schema_utils.py +113 -0
- ostruct/cli/services.py +626 -0
- ostruct/cli/template_debug.py +748 -0
- ostruct/cli/template_debug_help.py +162 -0
- ostruct/cli/template_env.py +15 -6
- ostruct/cli/template_filters.py +55 -3
- ostruct/cli/template_optimizer.py +474 -0
- ostruct/cli/template_processor.py +1080 -0
- ostruct/cli/template_rendering.py +69 -34
- ostruct/cli/token_validation.py +286 -0
- ostruct/cli/types.py +78 -0
- ostruct/cli/unattended_operation.py +269 -0
- ostruct/cli/validators.py +386 -3
- {ostruct_cli-0.7.1.dist-info → ostruct_cli-0.8.0.dist-info}/LICENSE +2 -0
- ostruct_cli-0.8.0.dist-info/METADATA +633 -0
- ostruct_cli-0.8.0.dist-info/RECORD +69 -0
- {ostruct_cli-0.7.1.dist-info → ostruct_cli-0.8.0.dist-info}/WHEEL +1 -1
- ostruct_cli-0.7.1.dist-info/METADATA +0 -369
- ostruct_cli-0.7.1.dist-info/RECORD +0 -45
- {ostruct_cli-0.7.1.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,369 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.3
|
2
|
-
Name: ostruct-cli
|
3
|
-
Version: 0.7.1
|
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: jsonschema (>=4.23.0,<5.0.0)
|
18
|
-
Requires-Dist: openai (>=1.0.0,<2.0.0)
|
19
|
-
Requires-Dist: openai-structured (>=3.0.0,<4.0.0)
|
20
|
-
Requires-Dist: pydantic (>=2.6.3,<3.0.0)
|
21
|
-
Requires-Dist: pygments (>=2.15.0,<3.0.0)
|
22
|
-
Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
|
23
|
-
Requires-Dist: tiktoken (==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
|
-

|
30
|
-
|
31
|
-
<div align="center">
|
32
|
-
|
33
|
-
[](https://badge.fury.io/py/ostruct-cli)
|
34
|
-
[](https://pypi.org/project/ostruct-cli)
|
35
|
-
[](https://ostruct.readthedocs.io/en/latest/?badge=latest)
|
36
|
-
[](https://github.com/yaniv-golan/ostruct/actions/workflows/ci.yml)
|
37
|
-
[](https://opensource.org/licenses/MIT)
|
38
|
-
|
39
|
-
**ostruct** tranforms **unstructured** inputs into **structured**, usable **JSON** output using **OpenAI APIs** using dynamic **templates**
|
40
|
-
|
41
|
-
</div>
|
42
|
-
|
43
|
-
# ostruct-cli
|
44
|
-
|
45
|
-
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.
|
46
|
-
|
47
|
-
<div align="center">
|
48
|
-
|
49
|
-

|
50
|
-
|
51
|
-
</div>
|
52
|
-
|
53
|
-
## Why ostruct?
|
54
|
-
|
55
|
-
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:
|
56
|
-
|
57
|
-
- **Bridge the gap** between freeform LLM capabilities and structured data needs in production systems
|
58
|
-
- **Simplify integration** of AI into existing workflows and applications that expect consistent data formats
|
59
|
-
- **Ensure reliability** and validate output against a defined schema to avoid unexpected formats or missing data
|
60
|
-
- **Reduce development time** by providing a standardized way to interact with OpenAI models for structured outputs
|
61
|
-
- **Enable non-developers** to leverage AI capabilities through a simple CLI interface with templates
|
62
|
-
|
63
|
-
## Real-World Use Cases
|
64
|
-
|
65
|
-
ostruct can be used for various scenarios, including:
|
66
|
-
|
67
|
-
### Etymology Analysis
|
68
|
-
|
69
|
-
```bash
|
70
|
-
ostruct run prompts/task.j2 schemas/etymology.json -f input examples/scientific.txt --model gpt-4o
|
71
|
-
```
|
72
|
-
|
73
|
-
Break down words into their components, showing their origins, meanings, and hierarchical relationships. Useful for linguistics, educational tools, and understanding terminology in specialized fields.
|
74
|
-
|
75
|
-
### Automated Code Review
|
76
|
-
|
77
|
-
```bash
|
78
|
-
ostruct run prompts/task.j2 schemas/code_review.json -p source "examples/security/*.py" --model gpt-4o
|
79
|
-
```
|
80
|
-
|
81
|
-
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.
|
82
|
-
|
83
|
-
### Security Vulnerability Scanning
|
84
|
-
|
85
|
-
```bash
|
86
|
-
ostruct run prompts/task.j2 schemas/scan_result.json -d examples/intermediate --model gpt-4o
|
87
|
-
```
|
88
|
-
|
89
|
-
Scan codebases for security vulnerabilities, combining static analysis with AI-powered reasoning to identify potential issues, suggest fixes, and provide detailed explanations.
|
90
|
-
|
91
|
-
### Configuration Validation & Analysis
|
92
|
-
|
93
|
-
```bash
|
94
|
-
ostruct run prompts/task.j2 schemas/validation_result.json -f dev examples/basic/dev.yaml -f prod examples/basic/prod.yaml
|
95
|
-
```
|
96
|
-
|
97
|
-
Validate configuration files across environments, check for inconsistencies, and provide intelligent feedback on potential issues or improvements in infrastructure setups.
|
98
|
-
|
99
|
-
## Features
|
100
|
-
|
101
|
-
- Generate structured JSON output from natural language using OpenAI models and a JSON schema
|
102
|
-
- Rich template system for defining prompts (Jinja2-based)
|
103
|
-
- Automatic token counting and context window management
|
104
|
-
- Streaming support for real-time output
|
105
|
-
- Secure handling of sensitive data
|
106
|
-
- Model registry management with support for updating to the latest OpenAI models
|
107
|
-
- Non-intrusive registry update checks with user notifications
|
108
|
-
|
109
|
-
## Requirements
|
110
|
-
|
111
|
-
- Python 3.10 or higher
|
112
|
-
|
113
|
-
## Installation
|
114
|
-
|
115
|
-
### For Users
|
116
|
-
|
117
|
-
To install the latest stable version from PyPI:
|
118
|
-
|
119
|
-
```bash
|
120
|
-
pip install ostruct-cli
|
121
|
-
```
|
122
|
-
|
123
|
-
### For Developers
|
124
|
-
|
125
|
-
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.
|
126
|
-
|
127
|
-
## Environment Variables
|
128
|
-
|
129
|
-
ostruct-cli respects the following environment variables:
|
130
|
-
|
131
|
-
- `OPENAI_API_KEY`: Your OpenAI API key (required unless provided via command line)
|
132
|
-
- `OPENAI_API_BASE`: Custom API base URL (optional)
|
133
|
-
- `OPENAI_API_VERSION`: API version to use (optional)
|
134
|
-
- `OPENAI_API_TYPE`: API type (e.g., "azure") (optional)
|
135
|
-
- `OSTRUCT_DISABLE_UPDATE_CHECKS`: Set to "1", "true", or "yes" to disable automatic registry update checks
|
136
|
-
|
137
|
-
## Shell Completion
|
138
|
-
|
139
|
-
ostruct-cli supports shell completion for Bash, Zsh, and Fish shells. To enable it:
|
140
|
-
|
141
|
-
### Bash
|
142
|
-
|
143
|
-
Add this to your `~/.bashrc`:
|
144
|
-
|
145
|
-
```bash
|
146
|
-
eval "$(_OSTRUCT_COMPLETE=bash_source ostruct)"
|
147
|
-
```
|
148
|
-
|
149
|
-
### Zsh
|
150
|
-
|
151
|
-
Add this to your `~/.zshrc`:
|
152
|
-
|
153
|
-
```bash
|
154
|
-
eval "$(_OSTRUCT_COMPLETE=zsh_source ostruct)"
|
155
|
-
```
|
156
|
-
|
157
|
-
### Fish
|
158
|
-
|
159
|
-
Add this to your `~/.config/fish/completions/ostruct.fish`:
|
160
|
-
|
161
|
-
```fish
|
162
|
-
eval (env _OSTRUCT_COMPLETE=fish_source ostruct)
|
163
|
-
```
|
164
|
-
|
165
|
-
After adding the appropriate line, restart your shell or source the configuration file.
|
166
|
-
Shell completion will help you with:
|
167
|
-
|
168
|
-
- Command options and their arguments
|
169
|
-
- File paths for template and schema files
|
170
|
-
- Directory paths for `-d` and `--base-dir` options
|
171
|
-
- And more!
|
172
|
-
|
173
|
-
## Quick Start
|
174
|
-
|
175
|
-
1. Set your OpenAI API key:
|
176
|
-
|
177
|
-
```bash
|
178
|
-
export OPENAI_API_KEY=your-api-key
|
179
|
-
```
|
180
|
-
|
181
|
-
### Example 1: Using stdin (Simplest)
|
182
|
-
|
183
|
-
1. Create a template file `extract_person.j2`:
|
184
|
-
|
185
|
-
```jinja
|
186
|
-
Extract information about the person from this text: {{ stdin }}
|
187
|
-
```
|
188
|
-
|
189
|
-
2. Create a schema file `schema.json`:
|
190
|
-
|
191
|
-
```json
|
192
|
-
{
|
193
|
-
"type": "object",
|
194
|
-
"properties": {
|
195
|
-
"person": {
|
196
|
-
"type": "object",
|
197
|
-
"properties": {
|
198
|
-
"name": {
|
199
|
-
"type": "string",
|
200
|
-
"description": "The person's full name"
|
201
|
-
},
|
202
|
-
"age": {
|
203
|
-
"type": "integer",
|
204
|
-
"description": "The person's age"
|
205
|
-
},
|
206
|
-
"occupation": {
|
207
|
-
"type": "string",
|
208
|
-
"description": "The person's job or profession"
|
209
|
-
}
|
210
|
-
},
|
211
|
-
"required": ["name", "age", "occupation"],
|
212
|
-
"additionalProperties": false
|
213
|
-
}
|
214
|
-
},
|
215
|
-
"required": ["person"],
|
216
|
-
"additionalProperties": false
|
217
|
-
}
|
218
|
-
```
|
219
|
-
|
220
|
-
3. Run the CLI:
|
221
|
-
|
222
|
-
```bash
|
223
|
-
# Basic usage
|
224
|
-
echo "John Smith is a 35-year-old software engineer" | ostruct run extract_person.j2 schema.json
|
225
|
-
|
226
|
-
# For longer text using heredoc
|
227
|
-
cat << EOF | ostruct run extract_person.j2 schema.json
|
228
|
-
John Smith is a 35-year-old software engineer
|
229
|
-
working at Tech Corp. He has been programming
|
230
|
-
for over 10 years.
|
231
|
-
EOF
|
232
|
-
|
233
|
-
# With advanced options
|
234
|
-
echo "John Smith is a 35-year-old software engineer" | \
|
235
|
-
ostruct run extract_person.j2 schema.json \
|
236
|
-
--model gpt-4o \
|
237
|
-
--sys-prompt "Extract precise information about the person" \
|
238
|
-
--temperature 0.7
|
239
|
-
```
|
240
|
-
|
241
|
-
The command will output:
|
242
|
-
|
243
|
-
```json
|
244
|
-
{
|
245
|
-
"person": {
|
246
|
-
"name": "John Smith",
|
247
|
-
"age": 35,
|
248
|
-
"occupation": "software engineer"
|
249
|
-
}
|
250
|
-
}
|
251
|
-
```
|
252
|
-
|
253
|
-
### Example 2: Processing a Single File
|
254
|
-
|
255
|
-
1. Create a template file `extract_from_file.j2`:
|
256
|
-
|
257
|
-
```jinja
|
258
|
-
Extract information about the person from this text: {{ text.content }}
|
259
|
-
```
|
260
|
-
|
261
|
-
2. Use the same schema file `schema.json` as above.
|
262
|
-
|
263
|
-
3. Run the CLI:
|
264
|
-
|
265
|
-
```bash
|
266
|
-
# Basic usage
|
267
|
-
ostruct run extract_from_file.j2 schema.json -f text input.txt
|
268
|
-
|
269
|
-
# With advanced options
|
270
|
-
ostruct run extract_from_file.j2 schema.json \
|
271
|
-
-f text input.txt \
|
272
|
-
--model gpt-4o \
|
273
|
-
--max-output-tokens 1000 \
|
274
|
-
--temperature 0.7
|
275
|
-
```
|
276
|
-
|
277
|
-
The command will output:
|
278
|
-
|
279
|
-
```json
|
280
|
-
{
|
281
|
-
"person": {
|
282
|
-
"name": "John Smith",
|
283
|
-
"age": 35,
|
284
|
-
"occupation": "software engineer"
|
285
|
-
}
|
286
|
-
}
|
287
|
-
```
|
288
|
-
|
289
|
-
## System Prompt Handling
|
290
|
-
|
291
|
-
ostruct-cli provides three ways to specify a system prompt, with a clear precedence order:
|
292
|
-
|
293
|
-
1. Command-line option (`--sys-prompt` or `--sys-file`):
|
294
|
-
|
295
|
-
```bash
|
296
|
-
# Direct string
|
297
|
-
ostruct run template.j2 schema.json --sys-prompt "You are an expert analyst"
|
298
|
-
|
299
|
-
# From file
|
300
|
-
ostruct run template.j2 schema.json --sys-file system_prompt.txt
|
301
|
-
```
|
302
|
-
|
303
|
-
2. Template frontmatter:
|
304
|
-
|
305
|
-
```jinja
|
306
|
-
---
|
307
|
-
system_prompt: You are an expert analyst
|
308
|
-
---
|
309
|
-
Extract information from: {{ text }}
|
310
|
-
```
|
311
|
-
|
312
|
-
3. Default system prompt (built into the CLI)
|
313
|
-
|
314
|
-
### Precedence Rules
|
315
|
-
|
316
|
-
When multiple system prompts are provided, they are resolved in this order:
|
317
|
-
|
318
|
-
1. Command-line options take highest precedence:
|
319
|
-
- If both `--sys-prompt` and `--sys-file` are provided, `--sys-prompt` wins
|
320
|
-
- Use `--ignore-task-sysprompt` to ignore template frontmatter
|
321
|
-
|
322
|
-
2. Template frontmatter is used if:
|
323
|
-
- No command-line options are provided
|
324
|
-
- `--ignore-task-sysprompt` is not set
|
325
|
-
|
326
|
-
3. Default system prompt is used only if no other prompts are provided
|
327
|
-
|
328
|
-
Example combining multiple sources:
|
329
|
-
|
330
|
-
```bash
|
331
|
-
# Command-line prompt will override template frontmatter
|
332
|
-
ostruct run template.j2 schema.json --sys-prompt "Override prompt"
|
333
|
-
|
334
|
-
# Ignore template frontmatter and use default
|
335
|
-
ostruct run template.j2 schema.json --ignore-task-sysprompt
|
336
|
-
```
|
337
|
-
|
338
|
-
## Model Registry Management
|
339
|
-
|
340
|
-
ostruct-cli maintains a registry of OpenAI models and their capabilities, which includes:
|
341
|
-
|
342
|
-
- Context window sizes for each model
|
343
|
-
- Maximum output token limits
|
344
|
-
- Supported parameters and their constraints
|
345
|
-
- Model version information
|
346
|
-
|
347
|
-
To ensure you're using the latest models and features, you can update the registry:
|
348
|
-
|
349
|
-
```bash
|
350
|
-
# Update from the official repository
|
351
|
-
ostruct update-registry
|
352
|
-
|
353
|
-
# Update from a custom URL
|
354
|
-
ostruct update-registry --url https://example.com/models.yml
|
355
|
-
|
356
|
-
# Force an update even if the registry is current
|
357
|
-
ostruct update-registry --force
|
358
|
-
```
|
359
|
-
|
360
|
-
This is especially useful when:
|
361
|
-
|
362
|
-
- New OpenAI models are released
|
363
|
-
- Model capabilities or parameters change
|
364
|
-
- You need to work with custom model configurations
|
365
|
-
|
366
|
-
The registry file is stored at `~/.openai_structured/config/models.yml` and is automatically referenced when validating model parameters and token limits.
|
367
|
-
|
368
|
-
The update command uses HTTP conditional requests (If-Modified-Since headers) to check if the remote registry has changed before downloading, ensuring efficient updates.
|
369
|
-
|
@@ -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.1.dist-info/LICENSE,sha256=QUOY6QCYVxAiH8vdrUTDqe3i9hQ5bcNczppDSVpLTjk,1068
|
42
|
-
ostruct_cli-0.7.1.dist-info/METADATA,sha256=tTtA8Z19KckJdG94LXH3eWyli_XgfW-7f3JuaFGfhas,11115
|
43
|
-
ostruct_cli-0.7.1.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
44
|
-
ostruct_cli-0.7.1.dist-info/entry_points.txt,sha256=NFq9IuqHVTem0j9zKjV8C1si_zGcP1RL6Wbvt9fUDXw,48
|
45
|
-
ostruct_cli-0.7.1.dist-info/RECORD,,
|
File without changes
|