
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@laravilt/ai
Advanced tools
AI-powered search and chat for Laravilt. Supports OpenAI, Anthropic, Gemini, and DeepSeek with global search spotlight and chat UI.

A powerful AI integration package for Laravilt with support for multiple providers (OpenAI, Anthropic, Gemini, DeepSeek), global search spotlight, and chat UI.
composer require laravilt/ai
The package will automatically register its service provider.
Publish the config file:
php artisan vendor:publish --tag="laravilt-ai-config"
Add your API keys to .env:
# Default provider
LARAVILT_AI_PROVIDER=openai
# OpenAI Configuration
OPENAI_API_KEY=your-openai-api-key
OPENAI_MODEL=gpt-4o-mini
# Anthropic Configuration
ANTHROPIC_API_KEY=your-anthropic-api-key
ANTHROPIC_MODEL=claude-sonnet-4-20250514
# Google Gemini Configuration
GOOGLE_AI_API_KEY=your-google-api-key
GOOGLE_AI_MODEL=gemini-2.0-flash-exp
# DeepSeek Configuration
DEEPSEEK_API_KEY=your-deepseek-api-key
DEEPSEEK_MODEL=deepseek-chat
Add the GlobalSearch component to your layout:
<script setup>
import { GlobalSearch } from '@laravilt/ai'
</script>
<template>
<GlobalSearch placeholder="Search..." :use-a-i="true" />
</template>
The spotlight search opens with Cmd/Ctrl+K.
<script setup>
import { AIChat } from '@laravilt/ai'
</script>
<template>
<AIChat :show-sidebar="true" />
</template>
Add AI capabilities to your resources:
use Laravilt\AI\AIAgent;
use Laravilt\Panel\Resources\Resource;
class ProductResource extends Resource
{
public static function ai(AIAgent $agent): AIAgent
{
return $agent
->name('product_assistant')
->description('AI assistant for managing products')
->searchable(['name', 'description', 'sku'])
->canCreate(true)
->canUpdate(true)
->canDelete(false)
->canQuery(true)
->systemPrompt('You are a helpful product management assistant.');
}
}
use Laravilt\AI\AIManager;
$ai = app(AIManager::class);
$response = $ai->provider('openai')->chat([
['role' => 'user', 'content' => 'Hello!'],
]);
Available models:
gpt-4o - GPT-4ogpt-4o-mini - GPT-4o Minigpt-4-turbo - GPT-4 Turbogpt-4 - GPT-4gpt-3.5-turbo - GPT-3.5 Turboo1, o1-mini, o1-preview - O1 Models$response = $ai->provider('anthropic')->chat([
['role' => 'user', 'content' => 'Hello!'],
]);
Available models:
claude-sonnet-4-20250514 - Claude Sonnet 4claude-opus-4-20250514 - Claude Opus 4claude-3-5-sonnet-20241022 - Claude 3.5 Sonnetclaude-3-5-haiku-20241022 - Claude 3.5 Haikuclaude-3-opus-20240229 - Claude 3 Opus$response = $ai->provider('gemini')->chat([
['role' => 'user', 'content' => 'Hello!'],
]);
Available models:
gemini-2.0-flash-exp - Gemini 2.0 Flashgemini-1.5-pro - Gemini 1.5 Progemini-1.5-flash - Gemini 1.5 Flashgemini-pro - Gemini Pro$response = $ai->provider('deepseek')->chat([
['role' => 'user', 'content' => 'Hello!'],
]);
Available models:
deepseek-chat - DeepSeek Chatdeepseek-coder - DeepSeek Coderdeepseek-reasoner - DeepSeek R1$ai = app(AIManager::class);
$stream = $ai->provider()->streamChat([
['role' => 'user', 'content' => 'Write a story'],
]);
foreach ($stream as $chunk) {
echo $chunk;
}
$response = $ai->provider()->chatWithTools(
messages: [
['role' => 'user', 'content' => 'What is the weather in Tokyo?'],
],
tools: [
[
'name' => 'get_weather',
'description' => 'Get weather information for a city',
'parameters' => [
'type' => 'object',
'properties' => [
'city' => ['type' => 'string', 'description' => 'City name'],
],
'required' => ['city'],
],
],
]
);
if ($response['tool_calls']) {
foreach ($response['tool_calls'] as $call) {
// Handle tool call
$result = handleToolCall($call['name'], $call['arguments']);
}
}
Register resources for global search:
use Laravilt\AI\GlobalSearch;
app(GlobalSearch::class)
->registerResource(
resource: 'products',
model: Product::class,
searchable: ['name', 'description', 'sku'],
label: 'Products',
icon: 'Package',
url: '/admin/products/{id}'
)
->limit(5)
->useAI(true);
import { useAI } from '@laravilt/ai'
const {
config,
loading,
selectedProvider,
selectedModel,
availableProviders,
availableModels,
loadConfig,
chat,
streamChat,
} = useAI()
// Load configuration
await loadConfig()
// Send a message
const response = await chat([
{ role: 'user', content: 'Hello!' }
])
// Stream a response
for await (const chunk of streamChat(messages)) {
console.log(chunk)
}
import { useGlobalSearch } from '@laravilt/ai'
const {
query,
results,
loading,
useAI,
search,
debouncedSearch,
clear,
} = useGlobalSearch()
// Perform search
await search('product name')
// Or with debounce
await debouncedSearch('product name', 300)
The package provides the following API endpoints:
| Method | Endpoint | Description |
|---|---|---|
| GET | /laravilt-ai/config | Get AI configuration |
| POST | /laravilt-ai/chat | Send chat message |
| POST | /laravilt-ai/stream | Stream chat response |
| GET | /laravilt-ai/sessions | List chat sessions |
| POST | /laravilt-ai/sessions | Create new session |
| GET | /laravilt-ai/sessions/{id} | Get session |
| PATCH | /laravilt-ai/sessions/{id} | Update session |
| DELETE | /laravilt-ai/sessions/{id} | Delete session |
| GET | /laravilt-ai/search | Global search |
composer test
composer format
composer analyse
The MIT License (MIT). Please see License File for more information.
FAQs
AI-powered search and chat for Laravilt. Supports OpenAI, Anthropic, Gemini, and DeepSeek with global search spotlight and chat UI.
We found that @laravilt/ai demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.