Skip to main content

Get Pydantic models and Python types as LLM responses from Anthropic, Google Vertex AI, and OpenAI models.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

modelsmith-0.7.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

modelsmith-0.7.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file modelsmith-0.7.0.tar.gz.

File metadata

  • Download URL: modelsmith-0.7.0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for modelsmith-0.7.0.tar.gz
Algorithm Hash digest
SHA256 12fa2f514bfbcd62a5322a6f86aa3960853ce3a2a52ae7af73b40cc2184df66b
MD5 a84c6894c5f1912eb96425a3994e3dcb
BLAKE2b-256 6575a3c61f85e2011d0cc40f967e2129bb627876b41d9225a9f2494c2ee0f058

See more details on using hashes here.

File details

Details for the file modelsmith-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: modelsmith-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for modelsmith-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 196f002591dc87dfe05f1fbfc551fd3e29431a05e0429a797224e07af7b4d16b
MD5 6063586af6b67d44a8afd73221471aa3
BLAKE2b-256 7475f1d4be61fb359f810e69f638860847b4b0afed08e66d6256175d082118b9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page