Download the PHP package joshembling/laragenie without Composer

On this page you can find all versions of the php package joshembling/laragenie. 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 laragenie

Laragenie - AI built to understand your codebases

Latest Version on Packagist Total Downloads

Laragenie is an AI chatbot that runs on the command line from your Laravel app. It will be able to read and understand any of your codebases following a few simple steps:

  1. Set up your env variables OpenAI and Pinecone
  2. Publish and update the Laragenie config
  3. Index your files and/or full directories
  4. Ask your questions

It's as simple as that! Accelerate your workflow instantly and collaborate seamlessly with the quickest and most knowledgeable 'colleague' you've ever had.

This is a particularly useful CLI bot that can be used to:

You are not limited to indexing files based in your Laravel project. You can use this for monorepo's, or indeed any repo in any language. You can of course use this tool to index files that are not code-related also.

All you need to do is run this CLI tool from the Laravel directory. Simple, right?! 🎉

[!NOTE]
If you are upgrading from a Laragenie version ^1.0.63 > 1.1, there is a change to Pinecone environment variables. Please see OpenAI and Pinecone.

Contents

Minimum Requirements

For specific versions that match your PHP, Laravel and Laragenie versions please see the table below:

PHP Laravel version Laragenie version
^8.1 ^10.0 >=1.0 <1.2
^8.2 ^10.0, ^11.0 ^1.2.0

This package uses Laravel Prompts which supports macOS, Linux, and Windows with WSL. Due to limitations in the Windows version of PHP, it is not currently possible to use Laravel Prompts on Windows outside of WSL.

For this reason, Laravel Prompts supports falling back to an alternative implementation such as the Symfony Console Question Helper.

Installation

You can install the package via composer:

You can publish and run the migrations with:

If you don't want to publish migrations, you must toggle the database credentials in your Laragenie config to false. (See config file details below).

You can publish the config file with:

This is the contents of the published config file:

Usage

OpenAI and Pinecone

OpenAI

This package uses OpenAI to process and generate responses and Pinecone to index your data.

You will need to create an OpenAI account with credits, generate an API key and add it to your .env file:


Pinecone

[!IMPORTANT]
If you are using a Laragenie version prior to 1.1 and do not want to upgrade, go straight to Legacy Pinecone.

You will need to create a Pinecone account. There are two diferent types of account you can set up:

  1. Serverless
  2. Pod-based index

As of early 2024, Pinecone recommend you start with a serverless account. You can optionally set up an account with a payment method attached to get $100 in free credits, however, a free account allows up to 100,000 indexes - likely more than enough for any small-medium sized application.

Create an index with 1536 dimensions and the metric as 'cosine'. Then generate an api key and add these details to your .env file:

Your host can be seen in the information box on your index page, alongside the metric, dimensions, pod type, cloud, region and environment.


[!TIP]
If you are upgrading to Laragenie ^1.1, you can safely remove the legacy environment variables: PINECONE_ENVIRONMENT and PINECONE_INDEX.

Legacy Pinecone

Important: If you are using Laragenie 1.0.63 or prior, you must use a regular Pinecone account and NOT a serverless account. When you are hinted to select an option on account creation, ensure you select 'Continue with pod-based index'.

Create an environment with 1536 dimensions and name it, generate an api key and add these details to your .env file:

Running Laragenie on the command line

Once these are setup you will be able to run the following command from your root directory:

You will get 4 options:

  1. Ask a question
  2. Index files
  3. Remove indexed files
  4. Something else

Use the arrow keys to toggle through the options and enter to select the command.

Ask a question

Note: you can only run this action once you have files indexed in your Pinecone vector database (skip to the ‘Index Files’ section if you wish to find out how to start indexing).

When your vector database has indexes you’ll be able to ask any questions relating to your codebase.

Answers can be generated in markdown format with code examples, or any format of your choosing. Use the bot.instructions config to write AI instructions as detailed as you need to.

Beneath each response you will see the generated cost (in US dollars), which will help keep close track of the expense. Cost of the response is added to your database, if migrations are enabled.

Costs can vary, but small responses will be less than $0.01. Much larger responses can be between $0.02–0.05.

Force AI

As previously mentioned, when you have migrations enabled your questions will save to your database.

However, you may want to force AI usage (prevent fetching from the database) if you are unsatisfied with the initial answer. This will overwrite the answer already saved to the database.

To force an AI response, you will need to end all questions with an --ai flag e.g.

Tell me how users are saved to the database --ai.

This will ensure the AI model will re-assess your request, and outputs another answer (this could be the same answer depending on the GPT model you are using).

Index files

The quickest way to index files is to pass in singular values to the directories or files array in the Laragenie config. When you run the 'Index Files' command you will always have the option to reindex these files. This will help in keeping your Laragenie bot up to date.

Select 'yes', when prompted with Do you want to index your directories and files saved in your config?

If you select 'no', you can also index files in the following ways:

Indexing files outside of your Laravel project

You may use Laragenie in any way that you wish; you are not limited to just indexing Laravel based files.

For example, your Laravel project may live in a monorepo with two root entries such as frontend and backend. In this instance, you could move up one level to index more directories and files e.g. ../frontend/src/ or ../frontend/components/Component.js.

You can add these to your directories and files in the Laragenie config:

Using this same method, you could technically index any files or directories you have access to on your server or local machine.

Ensure your extensions in your Laragenie config match all the file types that you want to index.

Note: if your directories, paths or file names change, Laragenie will not be able to find the index if you decide to update/remove it later on (unless you truncate your entire vector database, or go into Pinecone and delete them manually).

Removing indexed files

You can remove indexed files using the same methods listed above, except from using your directories or files array in the Laragenie config - this is currently for indexing purposes only.

If you want to remove all files you may do so by selecting Remove all chunked data. Be warned that this will truncate your entire vector database and cannot be reversed.

To remove a comma separated list of files/directories, select the Remove data associated with a directory or specific file prompt as an option.

Strict removal, i.e. warning messages before files are removed, can be turned on/off by changing the 'strict' attribute to false in your config.

Stopping Laragenie

You can stop Laragenie using the following methods:

Have fun using Laragenie! 🤖

Debugging

API Keys

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 laragenie with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/contracts Version ^10.0|^11.0
laravel/prompts Version ^0.1.13
openai-php/client Version ^0.8.0
openai-php/laravel Version ^0.8.0
probots-io/pinecone-php Version ^1.0.1
spatie/laravel-package-tools Version ^1.14.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 joshembling/laragenie contains the following files

Loading the files please wait ...