定制 wiserwebsolutions/laravel-lobbyist-ai 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

wiserwebsolutions/laravel-lobbyist-ai

Composer 安装命令:

composer require wiserwebsolutions/laravel-lobbyist-ai

包简介

AI layer for laravel-lobbyist: summarize, classify, and ask questions about legislative data with the Laravel AI SDK.

README 文档

README

An optional AI layer for wiserwebsolutions/laravel-lobbyist, built on the first-party Laravel AI SDK (laravel/ai). It summarizes and classifies bills, answers natural-language questions with a tool-using agent, and provides semantic search over an indexed bill corpus — all on top of the existing Lobbyist::state(...) driver surface.

It is a consumer of the Lobbyist drivers (not a driver itself), so core stays dependency-free.

Installation

composer require wiserwebsolutions/laravel-lobbyist-ai
php artisan vendor:publish --tag=lobbyist-ai-config
php artisan vendor:publish --tag=lobbyist-ai-migrations
php artisan migrate

Requires Laravel 13 (for laravel/ai) and at least one Lobbyist driver (laravel-lobbyist-legiscan and/or laravel-palegis).

Configuration

Text/reasoning runs on Claude by default; embeddings use a separate provider (Anthropic has no embeddings API):

ANTHROPIC_API_KEY=...            # text: summaries, classification, Q&A
OPENAI_API_KEY=...               # embeddings for semantic search (or Voyage/Gemini/Cohere)

LOBBYIST_AI_TEXT_MODEL=claude-opus-4-8
LOBBYIST_AI_EMBED_PROVIDER=openai
LOBBYIST_AI_EMBED_DIMENSIONS=1536

See config/lobbyist-ai.php for cache and RAG options.

Usage

use WiserWebSolutions\Lobbyist\Ai\Facades\LobbyistAi;
use WiserWebSolutions\Lobbyist\Facades\Lobbyist;

// Summaries (structured: headline / summary / key_points), cached.
$bill = Lobbyist::state('CA')->bill('AB1');
$summary = LobbyistAi::summarizeBill($bill);

// Classification (controlled subjects + tags + impact).
$tags = LobbyistAi::classifyBill($bill);

// Natural-language Q&A — the agent calls the driver tools to get the facts.
$answer = LobbyistAi::ask('What education bills are moving in PA this session?', 'PA');

// Semantic search (after indexing).
$matches = LobbyistAi::search('cursive handwriting in schools', 'PA');

Semantic search / RAG

Index a state's bills (incremental — unchanged bills are skipped):

php artisan lobbyist-ai:index PA

Embeddings are stored via a pluggable EmbeddingStore. The default database store keeps vectors in your default database connection and scores cosine similarity in PHP — no Postgres/pgvector required. For large corpora, bind a vector-native implementation of WiserWebSolutions\Lobbyist\Ai\Contracts\EmbeddingStore instead.

Capabilities & the driver contract

The Q&A agent's tools guard every call with the driver's supports(Capability) check, so it degrades honestly: if a state's driver can't list votes or look up a bill by id, the tool says so rather than inventing an answer.

Testing

Tests use the Laravel AI SDK's fakes (Ai::fakeAgent, Ai::fakeEmbeddings) and a fake Lobbyist driver, so they never hit the network:

composer install
vendor/bin/phpunit

License

MIT © Daniel Wiser

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-07-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固