elliottlawson/converse 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

elliottlawson/converse

最新稳定版本:v0.2.0

Composer 安装命令:

composer require elliottlawson/converse

包简介

A Laravel package for storing and managing AI conversation history in your applications

README 文档

README

Converse Logo


Tests Latest Stable Version Total Downloads License


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.

统计信息

  • 总下载量: 2.44k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-13