{"id":44417302,"url":"https://github.com/christopherarter/dream","last_synced_at":"2026-02-12T08:37:56.170Z","repository":{"id":62344840,"uuid":"559774233","full_name":"christopherarter/dream","owner":"christopherarter","description":"An AI/ML toolbox for Laravel","archived":false,"fork":false,"pushed_at":"2023-02-19T21:47:32.000Z","size":37076,"stargazers_count":182,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-01-31T14:44:04.464Z","etag":null,"topics":["ai","laravel","machine-learning"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/christopherarter.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-31T04:01:40.000Z","updated_at":"2025-10-08T09:58:23.000Z","dependencies_parsed_at":"2023-01-29T18:31:09.316Z","dependency_job_id":null,"html_url":"https://github.com/christopherarter/dream","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/christopherarter/dream","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christopherarter%2Fdream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christopherarter%2Fdream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christopherarter%2Fdream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christopherarter%2Fdream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/christopherarter","download_url":"https://codeload.github.com/christopherarter/dream/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christopherarter%2Fdream/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29361819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T01:03:07.613Z","status":"online","status_checked_at":"2026-02-12T02:00:06.911Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","laravel","machine-learning"],"created_at":"2026-02-12T08:37:53.046Z","updated_at":"2026-02-12T08:37:56.154Z","avatar_url":"https://github.com/christopherarter.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"![title](.github/images/dream-logo.png)\n\n# The AI/ML Toolbox for Laravel\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/christopherarter/dream.svg?style=flat-square)](https://packagist.org/packages/christopherarter/dream)\n[![Total Downloads](https://img.shields.io/packagist/dt/christopherarter/dream.svg?style=flat-square)](https://packagist.org/packages/christopherarter/dream)\n![GitHub Actions](https://github.com/christopherarter/dream/actions/workflows/main.yml/badge.svg)\n\nDream is a package for Laravel that brings common AI/ML tools into your Laravel application without all the boilerplate.\n\nIt currently supports:\n- **OpenAI**\n- **AWS Comprehend**\n\n## Requirements\n\n- PHP 8.1\n- Laravel 9\n\n## Getting Started\n\n### Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require christopherarter/dream\n```\n\nNext, publish the vendor config file:\n```bash\nphp artisan vendor:publish --provider=\"Dream\\DreamServiceProvider\"\n```\n\n### Authentication\n\n#### OpenAI\n```dotenv\nDREAM_OPENAI_API_KEY=your-api-key\n```\n#### AWS\nTo use AWS Comprehend, you can add your AWS credentials in your `.env` file. **Note: the user must have access to the AWS Comprehend service.**\n\n```dotenv\nAWS_ACCESS_KEY_ID=your-access-key\nAWS_SECRET_ACCESS_KEY=your-secret-key\n```\n\n\n\n---\n## Usage\n\nTo use this package, you can rely on the `Dream` facade. This facade will automatically use the default driver you have set in your `config/dream.php` file.\n\n```php\nuse Dream\\Facades\\Dream;\n```\n\n### Sentiment Analysis\nSentiment analysis is the process of determining whether a piece of writing is positive, negative, or neutral. It's also known as opinion mining, deriving the opinion or attitude of a speaker.\nDream includes several helper methods to make it easy to use sentiment analysis.\n\nExample:\n```php\nuse Dream\\Facades\\Dream;\n\n$sentiment = Dream::text('I love Laravel!')-\u003esentiment();\n$sentiment-\u003edisposition(); // 'positive';\n$sentiment-\u003epositive(); // true;\n```\n\nAvailable Methods:\n```php\nuse Dream\\Facades\\Dream;\n\n$sentiment-\u003edisposition(); // 'positive' | 'negative' | 'neutral';\n$sentiment-\u003epositive(); // true | false;\n$sentiment-\u003enegative(); // true | false;\n$sentiment-\u003eneutral(); // true | false;\n```\n\n### Entity Extraction\nEntity extraction is the process of detecting and classifying key information from text and other unstructured data sources. \nIt's also known as named entity recognition (NER).\n\n```php\nuse Dream\\Facades\\Dream;\n\n$entities = Dream::text('I need a reservation for Mr. Foo and Mr. Bar at \nthe Foo Bar Restaurant on October 31st.')\n-\u003eentities();\n\n$entities-\u003epeople()-\u003etoArray(); // ['Mr. Foo', 'Mr. Bar'];\n$entities-\u003eplaces()-\u003etoArray(); // ['Foo Bar Restaurant'];\n$entities-\u003edates()-\u003etoArray(); // ['October 31st'];\n```\n\nAvailable Methods:\n```php\n$entities-\u003epeople(); // Collection of people\n$entities-\u003eplaces(); // Collection of places\n$entities-\u003edates(); // Collection of dates\n$entities-\u003eorganizations(); // Collection of organizations\n$entities-\u003eevents(); // Collection of events\n$entities-\u003eproducts(); // Collection of products\n$entities-\u003equantities(); // Collection of quantities\n$enteties-\u003eother(); // Collection of other entities\n```\n\n### Key Phrase Extraction\nKey phrase extraction is the process of identifying the most important phrases in a block of text.\nDream includes the ability to extract key phrases from a string.\n\n```php\nuse Dream\\Facades\\Dream;\n\nDream::text('Laravel is a web application framework with expressive, \nelegant syntax. We’ve already laid the foundation — freeing you to create \nwithout sweating the small things.')\n  -\u003ephrases()\n  -\u003epluck('text')\n  -\u003etoArray();\n  \n// [\n//   \"Laravel\",\n//   \"a web application framework\",\n//   \"expressive, elegant syntax\",\n//   \"the foundation —\",\n//   \"the small things\",\n// ]\n```\n\n### Language Detection\nLanguage detection is the process of identifying the language of a given text.\nDream includes the ability to detect the language of a string.\n\n```php\nuse Dream\\Facades\\Dream;\n\nDream::text('¿Cuál es tu película favorita?')-\u003elanguage(); // 'es'\n```\n\nThe language code will be the [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) code for the language. The\nreturn type is a value backed enum `Dream\\Enums\\Language` to ensure consistency\nacross clients.\n\n### Image Text Detection\nDream can detect the text inside of an image. To do this, we'll use the `imageText()` method.\n```php\nuse Dream\\Facades\\Dream;\n\n$file = Storage::get('image.jpg');\nDream::image($file)\n    -\u003etext()\n    -\u003epluck('text')\n    -\u003etoArray();\n    \n// [\"This was text in an image\"]\n```\n*Note: Currently only available using AWS*\n\n### Image Label Detection\nDream can determine labels for an image using the `imageLabels()` method.\n\n```php\nuse Dream\\Facades\\Dream;\n\n$file = Storage::get('image.jpg');\nDream::image($file)\n    -\u003elabels()\n    -\u003epluck('name')\n    -\u003etoArray();\n    \n// [\"man\", \"fish\", \"boat\", \"water\", \"ocean\", \"sea\"];\n```\n\n*Note: Currently only available using AWS*\n\n---\n## Clients\n\n### AWS Comprehend\n\n#### IAM Configuration\n\nThe AWS user you provide will need to have access to the Comprehend service.\n\nHere's a policy example:\n```json\n{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Action\": [\n                \"comprehend:*\",\n            ],\n            \"Effect\": \"Allow\",\n            \"Resource\": \"*\"\n        }\n    ]\n}\n```\n\nIf you'd like to strictly adhere to [least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege), you can limit the Actions in the role\nto just the ones you need. For example, if you only need to use the `entities` method, you can limit the Actions to just `comprehend:DetectEntities`.\n\n#### AWS Rekognition\nTo use the image detection methods, you'll need to enable the [AWS Rekognition](https://aws.amazon.com/rekognition/) service for your user as well.\nYou can add this to the example policy above:\n\n```json\n{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Action\": [\n                \"comprehend:*\",\n            ],\n            \"Effect\": \"Allow\",\n            \"Resource\": \"*\"\n        },\n        {\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"rekognition:*\"\n            ],\n            \"Resource\": \"*\"\n        }\n    ]\n}\n```\n\n#### Environment Variables\n\nBy default, Dream will use the `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables to authenticate with AWS Comprehend.\nIf you would like to specify a different AWS key \u0026 secret to use with Dream,\nyou can do so by setting the keys with the `DREAM_` prefix.\n\nFor example, \n\n```dotenv\nDREAM_AWS_ACCESS_KEY_ID=your-key\nDREAM_AWS_SECRET_ACCESS_KEY=your-secret\n```\n\n### Azure Cognitive Services\nComing soon :)\n\n---\n\n### Building Custom Clients\n\nIf you would like to build your own client, or contribute to this project by\nadding another client from a different provider, you can do so by extending\nthe base classes:\n\n- `Dream\\Clients\\Client` - The base client class\n- `Dream\\Clients\\TextClient` - The base text client class\n- `Dream\\Clients\\ImageClient` - The base image client class\n\nA client should have both image and text capabilities. These capabilities are handled \nin their own respective client classes.\n\n```php\n\u003c?php\n\nuse Dream\\Clients\\Client;\nuse Dream\\Collections\\TextEntityCollection;\nuse Illuminate\\Support\\Collection\n\nclass MyCustomClient extends Client\n{\n    public function text(string $text): MyCustomTextClient\n    {\n        return new MyCustomTextClient($text);\n    }\n    \n    public function image(string $image): MyCustomImageClient\n    {\n        return new MyCustomImageClient($image);\n    }\n}\n```\nNext, you'll add your client to the `config/dream.php` file.\n\n```php\n\u003c?php\n\nreturn [\n    'connections' =\u003e [\n        // ...\n        'my-custom-client' =\u003e [\n            'driver' =\u003e MyCustomClient::class,\n        ],   \n    ],\n];\n```\n\nFinally, you'll set your client as the default driver in your environment. Here's an example in your `.env`:\n\n```dotenv\nDREAM_DRIVER=my-custom-client\n```\n\n### Testing\n\n```bash\ncomposer test\n```\n\n## Roadmap\n- [x] Add OCR \u0026 Image Recognition\n- [x] Add support for OpenAI\n- [ ] Add support for Google Natural Language\n- [ ] Add support for custom local models using [Rubix ML](https://github.com/RubixML/ML)\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n### Security\n\nIf you discover any security related issues, please email chris@arter.dev instead of using the issue tracker.\n\n## Credits\n\n- Maintained by [Chris Arter](https://github.com/christopherarter)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristopherarter%2Fdream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchristopherarter%2Fdream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristopherarter%2Fdream/lists"}