Download the PHP package basillangevin/instructor-laravel without Composer

On this page you can find all versions of the php package basillangevin/instructor-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package instructor-laravel

Structured outputs for LLMs using Spatie Data objects.

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Instructor Laravel turns LLM (Large Language Model) responses into spatie/laravel-data objects, helping you easily integrate LLMs into your applications.

Installation

You can install the package via composer:

You can publish the config file with:

These are the contents of the published config file:

Introduction

Instructor Laravel is built on top of echolabsdev/prism: a fantastic package that provides a unified interface to work with various LLM providers.

Instructor Laravel extends the Structured Outputs feature of Prism, allowing you to use spatie/laravel-data objects as your data schema.

The package modifies two methods from Prism: withSchema and generate. All other Prism methods are available and work as expected.

Basic Usage

Because this package transforms LLM responses into spatie/laravel-data objects, we'll start by defining a Data object.

Then, we'll build our LLM request by:

The generate method will return a BirdData object from the LLM response.

Collections of Data objects

Instructor Laravel also supports transforming responses that contain collections of Data objects.

The generate method will return a Collection`` ofBirdData` objects.

You may pass a custom Collection class name as the second argument of withCollectionSchema to use a custom collection class:

Validation and retries

Instructor Laravel will automatically validate the LLM response against the Data object's rules.

If the LLM response doesn't match the expected structure, Instructor Laravel will call the LLM again with any errors it encountered, helping the LLM generate a response that matches the expected structure.

By default, the request will be retried up to 3 times. You can change this by calling withRetries(...) or withoutRetries():

The withRetries method accepts the same arguments as Laravel's retry helper (excluding the $callback argument). The number of retries will be added to the initial request, so if you pass 3 to withRetries, the request will be made up to 4 times in total (1 initial attempt + 3 retries).

Improving LLM response reliability

To improve the LLM's understanding of the expected response, Laravel Instructor transforms the Data class into a JSON Schema and passes it to the LLM.

Under the hood, schemas are generated using basillangevin/laravel-json-data-schema. This package adds additional information to the generated schema by transforming:

All of this information is available to the LLM from the very first request, so it can be helpful to annotate your Data classes more information as needed.

Testing

Each PHP file in this package has a co-located Pest test file named {FileName}Test.php.

This package achieves 100% test coverage, 100% mutation coverage, and 100% PHPStan coverage coverage at level 10.

The following commands can be used to test the package:

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of instructor-laravel with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
basillangevin/laravel-data-json-schemas Version ^1.1
echolabsdev/prism Version ^0.34.0
illuminate/contracts Version ^10.0||^11.0
opis/json-schema Version ^2.4
spatie/laravel-package-tools Version ^1.16
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package basillangevin/instructor-laravel contains the following files

Loading the files please wait ....