Dynamic Pydantic

Dynamic Pydantic

Visit Site

Dynamic Pydantic is a Python library that allows users to create and validate tools and databases in runtime. It leverages the Instructor and Pydantic libraries to generate models dynamically based on provided prompt and context.

Key Features

  1. Dynamic Model Generation: Dynamic Pydantic generates pydantic models dynamically based on the input prompt and context.
  2. AI Agent Integration: The library is designed to integrate with AI agents, making it easy to create and validate tools and databases in runtime.
  3. Support for OpenAI-Compatible Endpoints: Dynamic Pydantic supports OpenAI-compatible endpoints via LiteLLM, allowing users to interact with the model seamlessly.

Installation

To install Dynamic Pydantic, simply run pip install dynamic-pydantic in your terminal.

Usage Example

Here's a basic example showcasing the generation of a pydantic schema using Dynamic Pydantic:

from dynamic_pydantic import dynamic_model

genModel = dynamic_model(prompt='User = Name, Age')

print(f'{genModel.schema_json()}')

Output:

{"properties": {"Name": {"default": null, "description": "The user's name", "title": "Name", "type": "string"}, "Age": {"default": null, "description": "The user's age", "title": "Age", "type": "integer"}}, "title": "User", "type": "object"}

License

Dynamic Pydantic is licensed under the MIT license.

Contributing

To contribute to Dynamic Pydantic, simply clone the repository and start contributing by submitting a pull request.

Stars, Watchers, and Forks

Dynamic Pydantic has 2 stars, 1 watcher, and no forks.