Absortio

Email → Summary → Bookmark → Email

GitHub - neuron-core/neuron-ai: The PHP Agentic Framework to build production-ready AI driven applications. Connect components (LLMs, vector DBs, memory) to agents that can interact with your data. With its modular architecture it's best suited for building RAG, multi-agent workflows, or business process automations.

Extracto

The PHP Agentic Framework to build production-ready AI driven applications. Connect components (LLMs, vector DBs, memory) to agents that can interact with your data. With its modular architecture i...

Resumen

Resumen Principal

Neuron emerge como un innovador framework de PHP diseñado para la creación y orquestación de Agentes de IA, posicionándose como una herramienta fundamental para desarrolladores que buscan integrar capacidades avanzadas de inteligencia artificial en sus aplicaciones PHP existentes. Este framework no solo facilita la incorporación de entidades de IA, sino que proporciona un conjunto robusto de herramientas que abarcan todo el ciclo de vida del desarrollo de aplicaciones agentic. Desde interfaces para Large Language Models (LLM) y carga de datos, hasta la orquestación de múltiples agentes y funciones de monitoreo y depuración, Neuron ofrece una arquitectura potente y flexible. Su propuesta de valor se refuerza con la promesa de una experiencia de desarrollo familiar para los usuarios de Laravel y Symfony, permitiendo una transición suave y una integración profunda sin requerir un cambio de ecosistema. De esta forma, Neuron se establece como la "rama de IA" ideal para el ecosistema PHP, capacitando a los desarrolladores para construir soluciones de IA sofisticadas con una complejidad gestionada.

Elementos Clave

  • Framework Integral para Agentes de IA: Neuron es presentado como una solución completa que abarca el desarrollo de aplicaciones agentic en PHP. Ofrece herramientas para la creación de interfaces LLM, la gestión de la carga de datos, la orquestación de múltiples agentes, y funciones esenciales de monitoreo y depuración. Esto posiciona a Neuron como una plataforma todo en uno para el desarrollo de IA.
  • Integración Profunda con Ecosistemas PHP Líderes: El framework ha sido diseñado para una coexistencia armoniosa con Laravel y Symfony. Para Laravel, Neuron se presenta como una "rama de IA" que ofrece un patrón de encapsulación bien definido y un namespace dedicado, brindando una experiencia familiar similar a la de otros paquetes populares como Filament o Nova. En el caso de Symfony, sus componentes son modulares, permitiendo una fácil definición de dependencias y la automatización de la creación de objetos mediante el contenedor de servicios de Symfony.
  • Abstracción Simplificada para la Creación de Agentes: La clase Agent de Neuron es el núcleo para construir agentes funcionales. Esta clase abstrae y gestiona automáticamente mecanismos avanzados como la memoria, las herramientas, las llamadas a funciones y los sistemas RAG (Generación Aumentada por Recuperación), lo que reduce significativamente la curva de aprendizaje y la complejidad para los desarrolladores. La creación de un agente básico se inicia con un comando simple como php vendor/bin/neuron make:agent DataAnalystAgent.
  • Compromiso con la Comunidad y el Aprendizaje Continuo: Neuron no solo provee el framework, sino que también enfatiza la creación de una comunidad activa y el acceso a recursos educativos. Se invita a los desarrolladores a unirse a una comunidad pionera, suscribirse a newsletters para acceso temprano a nuevas características, y apoyar el proyecto en GitHub. Además, ofrece tutoriales, guías técnicas y documentación oficial extensa para ayudar a los usuarios a iniciarse rápidamente en el desarrollo de agentes de IA.

Análisis e Implicaciones

Neuron tiene el potencial de catalizar significativamente la adopción de la inteligencia artificial dentro del vasto ecosistema de PHP, permitiendo a los desarrolladores integrar capacidades avanzadas de agentes de IA sin la necesidad de migrar a otros lenguajes o entornos. Esto democratiza el desarrollo de IA, facilitando la creación de aplicaciones más inteligentes y automatizadas con herramientas que son intrínsecamente familiares y eficientes para la comunidad PHP.

Contexto Adicional

El framework requiere PHP en su versión ^8.1 y ofrece una documentación oficial detallada junto con una serie de guías y tutoriales en video para un aprendizaje rápido y efectivo.

Contenido

Create Full-Featured Agentic Applications in PHP

Latest Stable Version Total Downloads

Important

Get early access to new features, exclusive tutorials, and expert tips for building AI agents in PHP. Join a community of PHP developers pioneering the future of AI development. Subscribe to the newsletter

Before moving on, support the community giving a GitHub star ⭐️. Thank you!

What is Neuron?

Neuron is a PHP framework for creating and orchestrating AI Agents. It allows you to integrate AI entities in your existing PHP applications with a powerful and flexible architecture. We provide tools for the entire agentic application development lifecycle, from LLM interfaces, to data loading, to multi-agent orchestration, to monitoring and debugging. In addition, we provide tutorials and other educational content to help you get started using AI Agents in your projects.

Laravel Tutorial

Neuron & Inspector

Requirements

  • PHP: ^8.1

Official documentation

Go to the official documentation

Guides & Tutorials

Check out the technical guides and tutorials archive to learn how to start creating your AI Agents with Neuron https://docs.neuron-ai.dev/overview/fast-learning-by-video.

Neuron is the perfect AI branch of your favorite framework.

Laravel

Neuron offers a well-defined encapsulation pattern, allowing you to work on your AI components in a dedicated namespace. You can enjoy the exact same experience of the other ecosystem packages you already love, like Filament, Nova, Horizon, Pennant, etc.

Example project (GitHub)

Symfony

All Neuron components belong to its own interface, so you can easily define dependencies and automate objects creation using the Symfony service container. Watch how it works in a real project.

Symfony & Neuron (YouTube)

How To

Install

Install the latest version of the package:

composer require neuron-core/neuron-ai

Create an Agent

Neuron provides you with the Agent class you can extend to inherit the main features of the framework and create fully functional agents. This class automatically manages some advanced mechanisms for you, such as memory, tools and function calls, up to the RAG systems. You can go deeper into these aspects in the documentation.

Let's create an Agent with the command below:

php vendor/bin/neuron make:agent DataAnalystAgent
<?php

namespace App\Neuron;

use NeuronAI\Agent;
use NeuronAI\SystemPrompt;
use NeuronAI\Providers\AIProviderInterface;
use NeuronAI\Providers\Anthropic\Anthropic;

class DataAnalystAgent extends Agent
{
    protected function provider(): AIProviderInterface
    {
        return new Anthropic(
            key: 'ANTHROPIC_API_KEY',
            model: 'ANTHROPIC_MODEL',
        );
    }

    protected function instructions(): string
    {
        return (string) new SystemPrompt(
            background: [
                "You are a data analyst expert in creating reports from SQL databases."
            ]
        );
    }
}

The SystemPrompt class is designed to take your base instructions and build a consistent prompt for the underlying model reducing the effort for prompt engineering.

Talk to the Agent

Send a prompt to the agent to get a response from the underlying LLM:

$agent = DataAnalystAgent::make();


$response = $agent->chat(
    new UserMessage("Hi, I'm Valerio. Who are you?")
);
echo $response->getContent();
// I'm a data analyst. How can I help you today?


$response = $agent->chat(
    new UserMessage("Do you remember my name?")
);
echo $response->getContent();
// Your name is Valerio, as you said in your introduction.

As you can see in the example above, the Agent has memory of the ongoing conversation. Learn more about memory in the documentation.

Monitoring & Debugging

Integrating AI Agents into your application you’re not working only with functions and deterministic code, you program your agent also influencing probability distributions. Same input ≠ output. That means reproducibility, versioning, and debugging become real problems.

Many of the Agents you build with Neuron will contain multiple steps with multiple invocations of LLM calls, tool usage, access to external memories, etc. As these applications get more and more complex, it becomes crucial to be able to inspect what exactly your agent is doing and why.

Why is the model taking certain decisions? What data is the model reacting to? Prompting is not programming in the common sense. No static types, small changes break output, long prompts cost latency, and no two models behave exactly the same with the same prompt.

The best way to take your AI application under control is with Inspector. After you sign up, make sure to set the INSPECTOR_INGESTION_KEY variable in the application environment file to start monitoring:

INSPECTOR_INGESTION_KEY=fwe45gtxxxxxxxxxxxxxxxxxxxxxxxxxxxx

After configuring the environment variable, you will see the agent execution timeline in your Inspector dashboard.

Learn more about Monitoring in the documentation.

Supported LLM Providers

With Neuron, you can switch between LLM providers with just one line of code, without any impact on your agent implementation. Supported providers:

Tools & Toolkits

Make your agent able to perform concrete tasks, like reading from a database, by adding tools or toolkits (collections of tools).

<?php

namespace App\Neuron;

use NeuronAI\Agent;
use NeuronAI\Providers\AIProviderInterface;
use NeuronAI\Providers\Anthropic\Anthropic;
use NeuronAI\SystemPrompt;
use NeuronAI\Tools\ToolProperty;
use NeuronAI\Tools\Tool;
use NeuronAI\Tools\Toolkits\MySQL\MySQLToolkit;

class DataAnalystAgent extends Agent
{
    protected function provider(): AIProviderInterface
    {
        return new Anthropic(
            key: 'ANTHROPIC_API_KEY',
            model: 'ANTHROPIC_MODEL',
        );
    }

    protected function instructions(): string
    {
        return (string) new SystemPrompt(
            background: [
                "You are a data analyst expert in creating reports from SQL databases."
            ]
        );
    }

    protected function tools(): array
    {
        return [
            MySQLToolkit::make(
                \DB::connection()->getPdo()
            ),
        ];
    }
}

Ask the agent something about your database:

$response = DataAnalystAgent::make()->chat(
    new UserMessage("How many orders we received today?")
);

echo $response->getContent();

Learn more about Tools in the documentation.

MCP Connector

Instead of implementing tools manually, you can connect tools exposed by an MCP server with the McpConnector component:

<?php

namespace App\Neuron;

use NeuronAI\Agent;
use NeuronAI\MCP\McpConnector;
use NeuronAI\Providers\AIProviderInterface;
use NeuronAI\Providers\Anthropic\Anthropic;
use NeuronAI\Tools\ToolProperty;
use NeuronAI\Tools\Tool;

class DataAnalystAgent extends Agent
{
    protected function provider(): AIProviderInterface
    {
        ...
    }

    protected function instructions(): string
    {
        ...
    }

    protected function tools(): array
    {
        return [
            // Connect to an MCP server
            ...McpConnector::make([
                'command' => 'npx',
                'args' => ['-y', '@modelcontextprotocol/server-everything'],
            ])->tools(),
        ];
    }
}

Learn more about MCP connector in the documentation.

Structured Output

There are scenarios where you need Agents to understand natural language, but output in a structured format, like business processes automation, data extraction, etc. to use the output with some other downstream system.

use App\Neuron\MyAgent;
use NeuronAI\Chat\Messages\UserMessage;
use NeuronAI\StructuredOutput\SchemaProperty;

/*
 * Define the output structure as a PHP class.
 */
class Person
{
    #[SchemaProperty(description: 'The user name')]
    public string $name;

    #[SchemaProperty(description: 'What the user love to eat')]
    public string $preference;
}

// Talk to the agent requiring the structured output
$person = MyAgent::make()->structured(
    new UserMessage("I'm John and I like pizza!"),
    Person::class
);

echo $person->name ' like '.$person->preference;
// John like pizza

Learn more about Structured Output on the documentation.

RAG

To create a RAG you need to attach some additional components other than the AI provider, such as a vector store, and an embeddings provider.

Let's create a RAG with the command below:

php vendor/bin/neuron make:rag MyChatBot

Here is an example of a RAG implementation:

<?php

namespace App\Neuron;

use NeuronAI\Providers\AIProviderInterface;
use NeuronAI\Providers\Anthropic\Anthropic;
use NeuronAI\RAG\Embeddings\EmbeddingsProviderInterface;
use NeuronAI\RAG\Embeddings\VoyageEmbeddingProvider;
use NeuronAI\RAG\RAG;
use NeuronAI\RAG\VectorStore\PineconeVectorStore;
use NeuronAI\RAG\VectorStore\VectorStoreInterface;

class MyChatBot extends RAG
{
    protected function provider(): AIProviderInterface
    {
        return new Anthropic(
            key: 'ANTHROPIC_API_KEY',
            model: 'ANTHROPIC_MODEL',
        );
    }

    protected function embeddings(): EmbeddingsProviderInterface
    {
        return new VoyageEmbeddingProvider(
            key: 'VOYAGE_API_KEY',
            model: 'VOYAGE_MODEL'
        );
    }

    protected function vectorStore(): VectorStoreInterface
    {
        return new PineconeVectorStore(
            key: 'PINECONE_API_KEY',
            indexUrl: 'PINECONE_INDEX_URL'
        );
    }
}

Learn more about RAG in the documentation.

Workflow

Think of a Workflow as a smart flowchart for your AI applications. The idea behind Workflow is to allow developers to use all the Neuron components like AI providers, embeddings, data loaders, chat history, vector store, etc, as standalone components to create totally customized agentic entities.

Agent and RAG classes represent a ready to use implementation of the most common patterns when it comes to retrieval use cases, or tool calls, structured output, etc. Workflow allows you to program your agentic system completely from scratch. Agent and RAG can be used inside a Workflow to complete tasks as any other component if you need their built-in capabilities.

Neuron Workflow

Neuron Workflow supports a robust human-in-the-loop pattern, enabling human intervention at any point in an automated process. This is especially useful in large language model (LLM)-driven applications where model output may require validation, correction, or additional context to complete the task.

Learn more about Workflow on the documentation.

Security Vulnerabilities

If you discover a security vulnerability within Neuron, please send an e-mail to the Inspector team via support@inspector.dev. All security vulnerabilities will be promptly addressed.

Official documentation

Go to the official documentation

Fuente: GitHub