Download the PHP package llm-agents/agents without Composer

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

LLM Agents

LLM Agents is a powerful PHP library for building and managing Language Model (LLM) based agents. This package provides a flexible and extensible framework for creating autonomous agents that can perform complex tasks, make decisions, and interact with various tools and APIs.

There is an article on Medium where I explaind what is LLM agents: A PHP dev’s dream: An AI home that really gets you

PHP Latest Version on Packagist Total Downloads

For a complete example with sample agents and a CLI interface to interact with them, check out our sample application repository https://github.com/llm-agents-php/sample-app. This sample app demonstrates practical implementations and usage patterns of the LLM Agents library.

The package does not include any specific LLM implementation. Instead, it provides a framework for creating agents that can interact with any LLM service or API.

Features

Installation

You can install the LLM Agents package via Composer:

Usage

Creating an Agent

To create an agent, you'll need to define its behavior, tools, and configuration. Here's a basic example:

Implementing a Tool

Now, let's implement the tool used by this agent:

And the input schema for the tool:

Linking Agents

LLM Agents supports creating complex systems by linking multiple agents together. This allows you to build hierarchical or collaborative agent networks. Here's how you can link one agent to another:

Creating an Agent Link

To link one agent to another, you use the AgentLink class. Here's an example of how to modify our SiteStatusCheckerAgent to include a link to another agent:

In this example, we're linking a network_diagnostics_agent. The outputSchema parameter specifies the expected output format from the linked agent. The output schema is used to standardize the data format that should be returned by the linked agent.

Using a Linked Agent

We don't provide an implementation for the linked agent here, but you can use the linked agent in your agent's execution.

Here's an example of how you might call the linked agent:

And the input schema for the tool:

And just add the tool to the agent that has linked agents. When the agent is executed, it will call the linked agent if it decides to do so.

Executing an Agent

To execute an agent, you'll use the AgentExecutor class:

This example demonstrates how to create a simple agent that can perform a specific task using a custom tool.

Agent Memory and Prompts

Agents can use memory and predefined prompts to guide their behavior:

Implementing Required Interfaces

To use the LLM Agents package, you'll need to implement the required interfaces in your project.

LLMInterface

It serves as a bridge between your application and LLM you're using, such as OpenAI, Claude, etc.

Here is an example of MessageMapper that converts messages to the format required by the LLM API:

AgentPromptGeneratorInterface

It plays a vital role in preparing the context and instructions for an agent before it processes a user's request. It ensures that the agent has all necessary information, including its own instructions, memory, associated agents, and any relevant session context.

You can customize the prompt generation logic to suit your specific requirements.

Here's an example implementation of the LLM\Agents\LLM\AgentPromptGeneratorInterface:

SchemaMapperInterface

This class is responsible for handling conversions between JSON schemas and PHP objects.

Here's an example implementation of the LLM\Agents\Tool\SchemaMapperInterface:

ContextFactoryInterface

It provides a clean way to pass execution-specific data through the system without tightly coupling components or overly complicating method signatures.

OptionsFactoryInterface

The options is a simple key-value store that allows you to store and retrieve configuration options that can be passed to LLM clients and other components. For example, you can pass a model name, max tokens, and other configuration options to an LLM client.

Architecture

The LLM Agents package is built around several key components:

For a visual representation of the architecture, refer to the class diagram in the documentation.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

LLM Agents is open-source software licensed under the MIT license.


All versions of agents with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ramsey/uuid Version ^4.7
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 llm-agents/agents contains the following files

Loading the files please wait ....