The library dynamically generates Pydantic models from natural language queries and handles all the complexity of LLM interactions, type validation, and structured output.
Example:
```python from structx import Extractor
extractor = Extractor.from_litellm( model="gpt-4o-mini", api_key="your-api-key" )
result = extractor.extract( data="System check on 2024-01-15 detected high CPU usage (92%) on server-01.", query="extract incident date and system metrics" )
print(result.data[0].model_dump_json(indent=2)) ```
Key features: - Dynamic model generation from natural language queries - Type safety with Pydantic - Support for any LLM provider via litellm - Document processing (PDF, DOCX, etc.) - Async support and automatic retries
I built this because I was tired of manually creating data models to use with instructor for data extraction every time there is new data. Would love feedback from the HN community.
Docs: https://structx.blacksuan19.dev GitHub: https://github.com/blacksuan19/structx PyPI: https://pypi.org/project/structx-llm/