Skip to content

Converse PrismSeamless Prism PHP Integration for Laravel Converse

AI SDKs are great at sending messages, but terrible at having conversations. Converse Prism makes AI conversations flow as naturally as Eloquent makes database queries.

Quick Setup

Install the package via Composer:

bash
composer require elliottlawson/converse-prism

Update your User model trait:

php
use ElliottLawson\ConversePrism\Concerns\HasAIConversations;

class User extends Model
{
    use HasAIConversations;
}

Start a conversation with AI:

php
// Build the conversation context
$conversation = $user->startConversation(['title' => 'My Chat'])
    ->addSystemMessage('You are a helpful assistant')
    ->addUserMessage('Hello! What is Laravel?');

// Make your AI call with automatic message passing
$response = $conversation
    ->toPrismText()
    ->using(Provider::OpenAI, 'gpt-4')
    ->withMaxTokens(500)
    ->asText();

// Store the AI's response
$conversation->addPrismResponse($response->text);

Released under the MIT License.