elliottlawson/converse
Composer 安装命令:
composer require elliottlawson/converse
包简介
A Laravel package for storing and managing AI conversation history in your applications
README 文档
README
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.
elliottlawson/converse 适用场景与选型建议
elliottlawson/converse 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.45k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2025 年 06 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「chat」 「streaming」 「laravel」 「ai」 「conversations」 「llm」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 elliottlawson/converse 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 elliottlawson/converse 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 elliottlawson/converse 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This simple PHP class allows you to easily generate Smartsupp.com JS chat code.
Client for the REST API plugin of the OpenFire Server
A laravel bundle for the OpenTok PHP SDK
Laravel Wrapper for the OpenTok PHP SDK
A robust, configuration-driven ETL and data import framework for Laravel. Handles CSV/Excel streaming, queues, validation, and relationships.
统计信息
- 总下载量: 3.45k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 16
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-13
