So, there I was, casually checking my inbox when a notification from Laravel News popped up. This one featured a new tool called Prism. Naturally, my curiosity levels spiked. I mean, c'mon, a package that merges Laravel with the power of LLMs? Yes, please!
As someone who's dabbled in chatbot development before, I was hooked from the moment I read that article. Of course, I had to dive deeper...
My Pre-Prism Approach to Chatbots:
Picture this:
I used to build UIs that acted as the front-end for a Flask.py backend, serving as a proxy. The flow went something like this:
- UI sends JSON to the Flask backend.
- Flask forwards it to OpenAI’s GPT models (team OpenAI from the start).
- Flask waits for the response from OpenAI.
- The UI then gets the response.
Sounds smooth? Not really. The delay was real. 😅 It worked, sure, but slow as hell. I tried optimizing the Flask functions, but no matter what I did, the wait time was still noticeable.
So, What’s Prism?
Prism is a Laravel package that makes integrating Large Language Models (LLMs) into your application a breeze. Minimalistic, elegant, and surprisingly powerful. The docs, albeit tailored for Anthropic, Ollama, and OpenAI, are so clear and direct that even a caffeine-deprived coder could follow them.
Why I’m Geeked Out Over Prism:
- Speed, glorious speed – No more waiting around like it's 2002.
- Clean, readable code – Because who doesn't love the smell of clean code in the morning?
- Seamless UI integration – Prism plays nice with views, making it super intuitive to mesh with interfaces.
- DIY Prism server setup – Prism lets you expose your custom AI models through a standardized API. It’s like having your own AI botnet... but for good. 😎
With the installation done, this is all you'd need to interact with your LLM! Cool right?
<?php use Illuminate\Support\Facades\Route; use EchoLabs\Prism\Prism; use EchoLabs\Prism\ValueObjects\Messages\UserMessage; use EchoLabs\Prism\ValueObjects\Messages\AssistantMessage; Route::get('/test-prism', function () { $prism = Prism::text() ->using('openai', 'gpt-4o') ->withMessages([ new UserMessage('Hello, who are you?'), new AssistantMessage('I am an AI assistant created by Anthropic. How can I help you today?'), new UserMessage('Can you tell me about the weather in Paris?'), ]); echo $prism()->text; });
In short, Prism isn't just a new tool—it's a time-saver, a workflow optimizer, and dare I say, a game-changer for Laravel + AI enthusiasts.
Top comments (0)