# GPT Pydantic Tools
The `gpt_pydantic_tools` repository offers a Python module designed to integrate Pydantic models with GPT-style tool schemas. It facilitates the transformation of Pydantic models into a format that is suitable for use with GPT-4's tools functionality, ensuring structured data and tool interaction consistency.
## Features
- **Model Conversion:** Convert Pydantic models into GPT-4 tool schemas.
- **Flexible Tool Choice Handling:** Provides several strategies for tool invocation such as auto, required, and none, based on the context or specific requirements.
## Installation
Install directly using pip:
```bash
pip install gpt-pydantic-tools
```
## Usage
1. **Define Pydantic Models:** Create your Pydantic models as per your requirements.
2. **Convert to GPT Tool Schema:** Use the `ToolSchemaManager` to convert your Pydantic models into GPT tool schemas.
3. **Tool Choice Management:** Utilize the `get_tool_choice_dict` to manage how tools are chosen for execution based on the defined strategies.
Example usage:
```python
from pydantic import BaseModel
from gpt_pydantic_tools import ToolSchemaManager, get_tool_choice_dict, ToolChoiceEnum
class MyModel(BaseModel):
name: str
age: int
# Convert Pydantic model to GPT tool schema
schema_manager = ToolSchemaManager(pydantic_obj=MyModel)
tool_schema = schema_manager.tools_schema
# Determine tool invocation strategy
tool_choice = get_tool_choice_dict(ToolChoiceEnum.AUTO, schema_manager)
```
If you want to do the Pydantic Schema conversion yourself, and directly provide the JSON instead, you can do:
```
schema_manager = ToolSchemaManager(pydantic_obj_json_schema=my_model_json_schema)
```
## Contributing
Contributions are welcome! Please feel free to submit pull requests, create issues, and suggest improvements to the repository.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
Raw data
{
"_id": null,
"home_page": null,
"name": "gpt-pydantic-tools",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "gpt, ai, tool, schemas, pydantic, json",
"author": null,
"author_email": "\"Carlos A. Planch\u00f3n\" <carlosandresplanchonprestes@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/1e/b1/bc022cc16e6f3a3b46ae59d52ff996ea63e1527375755f94641a311633a2/gpt_pydantic_tools-0.2.tar.gz",
"platform": null,
"description": "# GPT Pydantic Tools\n\nThe `gpt_pydantic_tools` repository offers a Python module designed to integrate Pydantic models with GPT-style tool schemas. It facilitates the transformation of Pydantic models into a format that is suitable for use with GPT-4's tools functionality, ensuring structured data and tool interaction consistency.\n\n## Features\n\n- **Model Conversion:** Convert Pydantic models into GPT-4 tool schemas.\n- **Flexible Tool Choice Handling:** Provides several strategies for tool invocation such as auto, required, and none, based on the context or specific requirements.\n\n## Installation\n\nInstall directly using pip:\n```bash\npip install gpt-pydantic-tools\n```\n\n## Usage\n\n1. **Define Pydantic Models:** Create your Pydantic models as per your requirements.\n2. **Convert to GPT Tool Schema:** Use the `ToolSchemaManager` to convert your Pydantic models into GPT tool schemas.\n3. **Tool Choice Management:** Utilize the `get_tool_choice_dict` to manage how tools are chosen for execution based on the defined strategies.\n\nExample usage:\n```python\nfrom pydantic import BaseModel\nfrom gpt_pydantic_tools import ToolSchemaManager, get_tool_choice_dict, ToolChoiceEnum\n\nclass MyModel(BaseModel):\n name: str\n age: int\n\n# Convert Pydantic model to GPT tool schema\nschema_manager = ToolSchemaManager(pydantic_obj=MyModel)\ntool_schema = schema_manager.tools_schema\n\n# Determine tool invocation strategy\ntool_choice = get_tool_choice_dict(ToolChoiceEnum.AUTO, schema_manager)\n```\n\nIf you want to do the Pydantic Schema conversion yourself, and directly provide the JSON instead, you can do:\n```\nschema_manager = ToolSchemaManager(pydantic_obj_json_schema=my_model_json_schema)\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit pull requests, create issues, and suggest improvements to the repository.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "Define GPT tool schemas using Pydantic.",
"version": "0.2",
"project_urls": {
"repository": "https://github.com/carlosplanchon/gpt_pydantic_tools.git"
},
"split_keywords": [
"gpt",
" ai",
" tool",
" schemas",
" pydantic",
" json"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5a6283ecf6e158fe41bfcaf683a9de87a1654dc8ec8789578f4ed11f32296d1a",
"md5": "be9e6b59322c4692a3929d892f7a3a00",
"sha256": "24ca9549ee89c1694dc5526c2c7ae03cea82045b572606fee7452318b46b7ed8"
},
"downloads": -1,
"filename": "gpt_pydantic_tools-0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "be9e6b59322c4692a3929d892f7a3a00",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 4716,
"upload_time": "2024-05-19T17:41:49",
"upload_time_iso_8601": "2024-05-19T17:41:49.545202Z",
"url": "https://files.pythonhosted.org/packages/5a/62/83ecf6e158fe41bfcaf683a9de87a1654dc8ec8789578f4ed11f32296d1a/gpt_pydantic_tools-0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1eb1bc022cc16e6f3a3b46ae59d52ff996ea63e1527375755f94641a311633a2",
"md5": "ae39800896abd8847ad9a1371627214b",
"sha256": "79a2258190c03c84624b494d21bab5ab66fdac7a86adb9cdbb66de22e4383918"
},
"downloads": -1,
"filename": "gpt_pydantic_tools-0.2.tar.gz",
"has_sig": false,
"md5_digest": "ae39800896abd8847ad9a1371627214b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4433,
"upload_time": "2024-05-19T17:41:52",
"upload_time_iso_8601": "2024-05-19T17:41:52.631469Z",
"url": "https://files.pythonhosted.org/packages/1e/b1/bc022cc16e6f3a3b46ae59d52ff996ea63e1527375755f94641a311633a2/gpt_pydantic_tools-0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-19 17:41:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "carlosplanchon",
"github_project": "gpt_pydantic_tools",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "gpt-pydantic-tools"
}