Download the PHP package use-the-fork/synapse without Composer
On this page you can find all versions of the php package use-the-fork/synapse. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package synapse
🧠 Synapse
Synapse allows you to seamlessly integrate and manage AI agents in your Laravel applications. Inspired by Langchain and Laravel Saloon, this package simplifies AI agent creation and management, giving you the tools to run them at scale.
Features
- Supports multiple AI integrations, including OpenAI and Claude.
- Easily extendable agent lifecycle with customizable hooks.
- Memory options for agents: temporary (CollectionMemory) or persistent (DatabaseMemory).
- Use Laravel's Blade system to create dynamic prompts.
- Build complex
few-shot
agent prompts with message tagging. - Extend functionality by creating custom tools that can interact with agents. Tools can even make additional API calls or invoke other agents.
- Prebuilt agents available for quick and easy use with popular integrations like OpenAI.
Installation
Requires PHP 8.1+
-
Install via Composer:
-
Run the install command:
- If you plan to use
DatabaseMemory
, ensure you publish the migrations by saying "yes" during installation.
Configuration
-
Set up your
.env
file with the required API keys: -
If packages are not autoloaded, add the service provider:
For Laravel 10:
For Laravel 11:
Usage
Defining an Agent
Agents are the core of Synapse. To create an agent, extend the Agent
class and define key methods like resolveIntegration
, resolveMemory
, and $promptView
.
Example:
Memory Options
Synapse offers two types of memory for agents:
- CollectionMemory: Temporary memory that exists only for the duration of the application's lifecycle.
- DatabaseMemory: Persistent memory stored in your database, allowing multiple agents to share or modify it.
To switch between these options, simply change the memory type in the resolveMemory
method.
Example using DatabaseMemory
:
Building Prompts
Use Laravel's Blade system to create agent prompts. Leverage the custom <message>
tags to distinguish between user, system, and tool messages.
Example Blade prompt view:
Integrations
Synapse supports the following integrations:
- OpenAI: Use the
OpenAIIntegration
class in your agents. - Claude: Use the
ClaudeIntegration
class in your agents.
To configure these integrations, add the appropriate API key to your .env
file and specify the integration in the resolveIntegration
method.
Example:
Agent Lifecycle & Hooks
The Synapse agent lifecycle offers several points where you can hook in to modify the agent's behavior. These hooks allow for customizations such as adjusting input, memory, tools, and integration responses.
Refer to the full documentation for more details on available hooks and how to use them.
Documentation
Click here to read the documentation
Support Synapse's Development
If you would like to support my work, you can donate to my Ko-Fi page by simply buying me a coffee or two!
Thank you for using Synapse ❤️
Credits
This project would not have been possible without:
- Saloon - https://github.com/saloonphp/saloon
- LangChain - https://python.langchain.com/
- Dexor - https://github.com/bootstrapguru/dexor/
License
This package is open-source and licensed under the MIT License.
Start building AI-driven applications with Laravel Synapse today!
All versions of synapse with dependencies
illuminate/container Version ^10.0|^11.0
illuminate/database Version ^10.0|^11.0
illuminate/events Version ^10.0|^11.0
illuminate/support Version ^10.0|^11.0
openai-php/client Version ^0.10.1
phpstan/phpdoc-parser Version ^1.32
saloonphp/saloon Version ^3.0