elliottlawson/converse
| Install | |
|---|---|
composer require elliottlawson/converse |
|
| Latest Version: | v0.2.0 |
| PHP: | ^8.2 |
| License: | MIT |
| Last Updated: | Jun 15, 2025 |
| Links: | GitHub · Packagist |
Converse - AI Conversation Management for Laravel
AI SDKs are great at sending messages, but terrible at having conversations.
Converse makes AI conversations flow as naturally as Eloquent makes database queries. Instead of manually managing message arrays and context for every API call, you just write $conversation->addUserMessage('Hello'). The entire conversation history, context management, and message formatting is handled automatically.
📚 Documentation
View the full documentation - Comprehensive guides, API reference, and examples.
The Difference
Without Converse, every API call means manually rebuilding context:
// Manually track every message 😫
$messages = [
['role' => 'system', 'content' => $systemPrompt],
['role' => 'user', 'content' => $oldMessage1],
['role' => 'assistant', 'content' => $oldResponse1],
['role' => 'user', 'content' => $oldMessage2],
['role' => 'assistant', 'content' => $oldResponse2],
['role' => 'user', 'content' => $newMessage],
];
// Send to API
$response = $client->chat()->create(['messages' => $messages]);
// Now figure out how to save everything...
With Converse, conversations just flow:
// Context is automatic ✨
$conversation->addUserMessage($newMessage);
// Your AI call gets the full context
$response = $aiClient->chat([
'messages' => $conversation->messages->toArray()
]);
// Store the response
$conversation->addAssistantMessage($response->content);
That's it. It's the difference between sending messages and actually having a conversation.
Features
- 💾 Database-Backed Persistence - Conversations survive page reloads and server restarts
- 🔌 Provider Agnostic - Works with OpenAI, Anthropic, Google, or any LLM
- 🌊 Streaming Made Simple - Automatic message chunking and progress tracking
- 🧠 Automatic Context Management - Stop rebuilding message arrays for every API call
- 📡 Built-in Events - Track usage, build analytics, react to AI interactions
- 🏗️ Laravel Native - Built with Eloquent, events, and broadcasting
Installation
composer require elliottlawson/converse
Run the migrations:
php artisan migrate
Quick Start
Add the trait to your User model:
use ElliottLawson\Converse\Traits\HasAIConversations;
class User extends Model
{
use HasAIConversations;
}
Start having conversations:
// Build the conversation context
$conversation = $user->startConversation(['title' => 'My Chat'])
->addSystemMessage('You are a helpful assistant')
->addUserMessage('Hello! What is Laravel?');
// Make your API call to OpenAI, Anthropic, etc.
$response = $yourAiClient->chat([
'messages' => $conversation->messages->toArray(),
// ... other AI configuration
]);
// Store the AI's response
$conversation->addAssistantMessage($response->content);
Looking for an AI Client?
Using Prism? Try out Converse-Prism - a seamless integration that combines Prism's elegant AI client with Converse's conversation management.
Requirements
- PHP 8.2+
- Laravel 11+
License
The MIT License (MIT). Please see License File for more information.
Related Packages
Drop-in AI chatbox widget for Laravel with RAG, streaming, Vue 3 frontend, and s...
Comprehensive Filament panel plugin for chatting with AI models from multiple pr...
Anthropic PHP for Laravel is a supercharged PHP API client that allows you to in...
Open Source Chat management plugin for FilamentPHP with model profiles, user set...