fr3on/laravel-sage
最新稳定版本:0.0.1
Composer 安装命令:
composer require fr3on/laravel-sage
包简介
A drop-in semantic cache for the Laravel AI SDK.
README 文档
README
A drop-in semantic cache for the Laravel AI SDK — serve cached LLM responses for meaning-similar prompts, not just exact matches.
Sage matched prompts by meaning using vector embeddings. "How do I reset my password?" and "I forgot my login, how to change it?" return the same cached response — instantly, at zero API cost.
Features
- Semantic Matching: Matches on intent, not just string equality.
- Zero Infra Latency: Works with your existing Postgres (pgvector) or Redis database.
- One-Line Integration: Hooks natively into Laravel AI SDK agent middleware.
- Automatic Token Savings: Significant reduction in LLM API costs.
- Pulse Integration: Includes a built-in Pulse card to track hit rates and cost savings.
Installation
You can install the package via composer:
composer require fr3on/laravel-sage
You can publish and run the migrations with:
php artisan vendor:publish --tag="sage-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="sage-config"
Usage
Sage hooks into the Laravel AI SDK's native agent middleware system. Add SemanticCache to your agent's middleware stack:
use Fr3on\Sage\Middleware\SemanticCache; class SupportAgent implements Agent, HasMiddleware { public function middleware(): array { return [ new SemanticCache(threshold: 0.92, ttl: 86400), ]; } }
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 231
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-10