Download the PHP package rhaymison/elephant_chain without Composer

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

Elephant Chain 🐘 - A Powerful Library for PHP Environments with LLMs

Banner

Welcome to Elephant Chain 🐘, a robust library crafted to seamlessly integrate Large Language Models (LLMs) into PHP environments. Whether you're developing sophisticated natural language processing applications or enhancing your PHP projects with AI capabilities, Elephant Chain equips you with the tools and functionalities to achieve this effortlessly and efficiently.

Key Features

Table of Contents

  1. Installation
  2. Basic Usage
  3. Available Models
    • OpenAi
    • Gemini
    • Mistral
    • Ollama
  4. Loaders
    • TXT Files
    • PDF Loaders
    • CSV Loaders
    • Doc Loaders
  5. Chains
    • Chain
    • RetrieverChain
    • SequentialChain
    • TabularChain
    • ChatMemoryChain
  6. Embedding
    • OpenAi Embeddings
    • Gemini Embeddings
    • Mistral Embeddings
    • Ollama Embeddings
  7. Vector Databases
    • ElephantVectors
    • ChromaDB
  8. Tools
    • Wikipedia
    • DuckDuckGo

Installation

To get started with Elephant Chain, follow these simple steps:

  1. Installation: Install the library using Composer:

Basic Usage

Available Models

Elephant Chain currently supports the use of models from OpenAI and Gemini. Integration with Mixtral and LlamaCPP is currently being implemented. Here are examples of how to initialize and use these models:

OpenAi

You must pass your integration key with your api. The model used by default is the gpt3.5 turbo and with a temperature of 0.5

Gemini

You must provide your Gemini API key and pass the temperature if you want, by default it is set to 0.5

Mistral

You must pass your integration key with the mistral and choose one of the available models. By default the model is: mistral-large-latest and with temperature: 0.5

Ollama

Add the ollama endpoint and select the model you want to use and have downloaded in your ollama environment

Loaders

TXT Files

The TxtLoader class allows you to load and process text files for use within Elephant Chain.

The first parameter is the directory, the second is the chunk size and the third is the overlapping window.

If you want to load only one txt file you can use this method and the last two parameters remain chunk and overlaping

PDF Loaders

The PdfLoader class enables you to load and extract text from PDF documents, making it easy to integrate document data into your workflows.

CSV Loaders

Doc Loaders

This class allows you to load only .doc files and not docx files. You can load an entire directory or just a single file.

Chains

Chain

The Chain class is the fundamental building block for creating and managing sequences of operations in Elephant Chain.

RetrieverChain

The RetrieverChain class extends the functionality of Chain by incorporating mechanisms to retrieve relevant data based on provided prompts.

SequentialChain

The SequentialChain class allows you to create a series of dependent operations, where the output of one operation serves as the input for the next.

If you wish, you can include a retriever chain at the beginning, end or middle of the chain. Just ensure that the exit must be passed forward.

TabularChain

The TabularChain class loads data from CSV/XLSX spreadsheets and applies user-defined transformations and filters to the extracted data. This class enables flexible manipulation and analysis of data through dynamically generated functions.

ChatMemoryChain

If you want to add memory to your conversation. You can use the Memory chat with the memory template. A memory cell will be stored and you can manipulate, remove or clear it whenever you want. ChainMemory accepts the template and name of the chat room you want to create.

The memory is added automatically and you don't need to worry about it. If you want to start the conversation with a memory, just pass it as the third parameter to the chatTemplate... The ChatMemoryChain already has a native getMemory function that you can use.

LARAVEL USAGE

Now we have this beautiful result

Banner

Embedding

Using embeddings in ElephantChain is very simple. The Embedding Function interface means that all embedding models offer the same return, making their implementation easy and quick.

OpenAi Embeddings

Gemini Embeddings

Mistral Embeddings

Ollama Embeddings

Vector Databases

ElephantVectors

The ElephantVectors class provides functionalities to store, manage, and query vectorized data, enabling efficient similarity searches and advanced data retrieval operations. If you don't want to have a vector database, you can use ElephantVectors which provides document embeddings and allows you to perform the searches directly to the model.

ChromaDB

The ChromaDB class offers robust capabilities for handling vectorized data, including storage, management, and querying, optimized for high-performance vector similarity searches.

Basic usage

The $documents variable has a 3-position array where the first is the ids, followed by the metadata and the third by the chunks. All arrays correspond to each other.

Usage example with OpenAI model

Usage example with Gemini and passing the embeddings function

LARAVEL USAGE

Now we can interact with your VectorsDatabase

Now we have this beautiful result

Banner

Tools

Tools are powerful instruments that you can add to your inferences. Below you can check out some of the available tools ps: Till this moment the tools are only available for simple Chain

Wikipedia

This tool searches Wikipedia and aggregates the information in the context of the user's question. The parameter passed in the constructor is the limit of search results.

DuckDuckGo

This powerful tool performs advanced searches on DuckDuck and adds important information to your prompt. You just need to specify the region where you want to perform the search.

prompt example with duckduckGo


All versions of elephant_chain with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
codewithkyrian/chromadb-php Version dev-main
openai-php/client Version dev-main
spatie/pdf-to-text Version dev-main
gemini-api-php/client Version dev-main
ext-mbstring Version *
partitech/php-mistral Version dev-main
modelflow-ai/ollama Version 0.2.x-dev
phpoffice/phpword Version dev-master
ncjoes/office-converter Version dev-master
ext-curl Version *
symfony/dom-crawler Version ^6.0
symfony/css-selector Version ^6.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 rhaymison/elephant_chain contains the following files

Loading the files please wait ....