Skip to main content

Modelsmith

Modelsmith is a Python library that allows you to get structured responses in the form of Pydantic models and Python types from Anthropic, Google Gemini, and OpenAI models.

Currently it allows you to use the following classes of model:

  • AnthropicModel (used with Anthropic's full set of models)
  • OpenAIModel (used with OpenAI's full set of models)
  • GeminiModel (used with Google's full set of Gemini models)

Modelsmith provides a unified interface over all of these. It has been designed to be extensible and can adapt to other models in the future.

Notable Features

  • Structured Responses: Specify both Pydantic models and Python types as the outputs of your LLM responses.
  • Templating: Use Jinja2 templating in your prompts to allow complex prompt logic.
  • Default and Custom Prompts: A default prompt template is provided but you can also specify your own.
  • Retry Logic: Number of retries is user configurable.
  • Validation: Outputs from the LLM are validated against your requested response model. Errors are fed back to the LLM to try and correct any validation failures.

Installation

Install Modelsmith using pip or your favourite python package manager.

pip example:

pip install modelsmith

Documentation

For detailed documentation please have a look at https://christo-olivier.github.io/modelsmith

Get in touch

If you have any questions or suggestions, feel free to open an issue or start a discussion.

License

This project is licensed under the terms of the MIT License.

Metadata

Release files for modelsmith 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for modelsmith 0.7.0
File Size Uploaded Provenance Actions
modelsmith-0.7.0.tar.gz 7.8 kB Without provenance Details for modelsmith-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for modelsmith 0.7.0
File Interpreter ABI Platform Actions
modelsmith-0.7.0-py3-none-any.whl Python 3 none any Details for modelsmith-0.7.0-py3-none-any.whl

Total release size: 18.0 kB

Release files / modelsmith-0.7.0.tar.gz

Download URL modelsmith-0.7.0.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
12fa2f514bfbcd62a5322a6f86aa3960853ce3a2a52ae7af73b40cc2184df66b
BLAKE2b-256 checksum
How to use checksums
6575a3c61f85e2011d0cc40f967e2129bb627876b41d9225a9f2494c2ee0f058
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.17

Release files / modelsmith-0.7.0-py3-none-any.whl

Download URL modelsmith-0.7.0-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
196f002591dc87dfe05f1fbfc551fd3e29431a05e0429a797224e07af7b4d16b
BLAKE2b-256 checksum
How to use checksums
7475f1d4be61fb359f810e69f638860847b4b0afed08e66d6256175d082118b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.17

Security for modelsmith 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page