Download the PHP package fiveam-code/ada-laravel without Composer

On this page you can find all versions of the php package fiveam-code/ada-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 ada-laravel

ada-laravel

The package ada-laravel allows you to enhance your Laravel applications by seamlessly integrating text embeddings and querying capabilities for your models. Utilizing OpenAI by default, it enables your models to generate and query embeddings using nearest neighbors techniques. This package requires a PostgreSQL database with the vector extension to store and manage these embeddings efficiently as well as at least Laravel 11.

Originally created as a demo for the talk »Have you met ada? - Word Embeddings with Laravel and OpenAI« by Diana Scharf, this package is functional yet designed to encourage further development and contributions.

Please note that this package is still in development and may not be suitable for production use.

Installation

At the moment, the installation process depends on the "minimum-stability" setting in your composer.json. If you have "minimum-stability": "dev", you can install the package directly:

Otherwise, you need to add the package with a temporary dev dependency to your composer.json:

Then you can run composer update to install the package.

Ensure that your database is configured to use PostgreSQL with the vector extension. The package will enable the extension via a migration if it is not already enabled.

Publish the migrations and run them:

This will enable the vector extension in your database and create a table embeddings to store the embeddings.

Configuration

Set the OpenAI API key in your .env file:

Please note that you need an OpenAI key for API access, not just ChatGPT access.

Optionally, you can publish the configuration file if you want to make changes to the default settings:

The default configuration is as follows:

If you want to implement your own engine to handle embeddings, you can create a new class that implements the Index interface with the appropriate engine and set it in the configuration.

Usage

Basic Usage

First, add the HasEmbeddings trait to your Eloquent model:

Embed content

Embed content related to your model by calling the embed method with a reference key and text:

This will generate an embedding for the text and store it in the database with a relation to the $paper model and the reference key "abstract".

Lookup embeddings

The lookup method allows for direct querying of your model's stored knowledge, facilitating an intelligent search that retrieves the most contextually relevant information using vector similarity.

This will create an embedding for the query and find the most similar embeddings in the database related to the $paper model by using the nearest neighbors technique of the vectors. The result will be the most similar text to the query and will be used as context for a request to the OpenAI API to generate an answer.

This is the default prompt text:

{context} will be replaced with the result from the nearest neighbors query.

If you want to further customize the prompt, you can pass an object form a class inheriting Ada\Tools\Prompts\Prompt to the lookup method:

In case you need to further limit the lookup, you can pass a closure as a third parameter.

Advanced Usage

Customize the endpoint models and options by using the index or engines directly:


All versions of ada-laravel with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/contracts Version ^10.0|^11.0
openai-php/client Version ^0.8.4
pgvector/pgvector Version ^0.1.4
rajentrivedi/tokenizer-x Version dev-upgrade-laravel-11
symfony/http-client Version ^7.0
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 fiveam-code/ada-laravel contains the following files

Loading the files please wait ....