Download the PHP package omarsabbagh/php-openai-structured without Composer
On this page you can find all versions of the php package omarsabbagh/php-openai-structured. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download omarsabbagh/php-openai-structured
More information about omarsabbagh/php-openai-structured
Files in omarsabbagh/php-openai-structured
Package php-openai-structured
Short Description A PHP package for easily working with OpenAI's structured output feature
License MIT
Informations about the package php-openai-structured
PHP OpenAI Structured Output
A PHP package for easily working with OpenAI's structured output feature. This package provides a simple and intuitive way to define JSON schemas for OpenAI API calls and process the structured responses.
Features
- Simple client for making OpenAI API calls with structured output
- Fluent interface for building JSON schemas
- Pre-built schema types for common use cases
- Type-safe PHP classes with proper documentation
Installation
Install via Composer:
Basic Usage
Building Custom Schemas
You can build custom schemas for more complex use cases:
Available Schema Types
CategorizationSchema
For categorizing input into predefined categories:
ObjectSchema
For creating custom object schemas:
Creating Your Own Schema Types
You can create your own schema types by extending the BaseSchema class:
Examples
Check the examples directory for more examples of how to use this package:
examples/categorization.php- Basic categorization exampleexamples/custom_schema.php- Custom schema for entity extraction
Development
Running Tests
This package includes a comprehensive test suite. To run the tests:
The test suite includes:
- Unit Tests: Tests for individual components
- Integration Tests: Tests for components working together
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Requirements
- PHP 8.1 or higher
- OpenAI API key
- Composer for dependency management
License
MIT License
Further Reading
All versions of php-openai-structured with dependencies
openai-php/client Version ^0.10.3
guzzlehttp/psr7 Version ^2.7
symfony/http-client Version ^6.4 || ^7.0