gawrys/counterparty-ai
Composer 安装命令:
composer require gawrys/counterparty-ai
包简介
Optional AI-assisted risk research subsystem for counterparty-verification. Advisory only; never decides hard pass/fail.
README 文档
README
Optional AI-assisted risk research for the
Counterparty Verification toolkit. It
plugs into the same RiskStrategy seam as the rule-based default and adds qualitative,
advisory context using an LLM with native tool use.
⚠️ The AI never decides hard pass/fail. It consumes the finished verification report as ground truth, grounds every claim in a tool's source URL (no source → inconclusive), and forces human review below a confidence threshold. Output is advisory only.
A separate package on purpose: prompts change often and must not bump the core's version.
Features
AiRiskStrategy- a drop-inRiskStrategy; PSR-16 cached by counterparty + report + prompt version to bound cost.- Native tool use (function calling) - the model invokes
registry_lookup,web_searchandverification_report; the provider executes them and feeds results back, looping until the findings JSON is returned. - Two reference providers over PSR-18, no SDK -
AnthropicResearchProvider,OpenAiResearchProvider. Adding another LLM is oneAbstractAiResearchProvidersubclass. - Structured output, validated - force JSON, parse, validate, retry; malformed output is never trusted.
- Deterministic test kit -
FakeAiResearchProvider, recorded cassettes and an in-memory PSR-16 cache, so tests run offline.
Installation
composer require gawrys/counterparty-ai
Usage
use Gawrys\Counterparty\Ai\AiRiskStrategy; use Gawrys\Counterparty\Ai\Prompt\RiskPromptBuilder; use Gawrys\Counterparty\Ai\Research\AnthropicResearchProvider; // or OpenAiResearchProvider use Gawrys\Counterparty\Ai\Tool\{RegistryTool, ReportLookupTool}; $strategy = new AiRiskStrategy( provider: new AnthropicResearchProvider($http, $apiKey), promptBuilder: new RiskPromptBuilder(), tools: [new RegistryTool($registries), new ReportLookupTool()], cache: $psr16Cache, reviewThreshold: 0.6, ); $verifier = new Verifier($checks, $strategy, $clock);
Switching LLM is a one-line change (OpenAiResearchProvider), or implement
AbstractAiResearchProvider::complete() for any other backend. Removing this package never
breaks the rule-based default - the core has no dependency on it.
See the documentation for prompts, grounding rules and writing custom tools.
Testing
composer check
Changelog
See CHANGELOG.md.
Contributing & Security
Pull requests welcome. Report security issues privately - see SECURITY.md.
Credits
License
The MIT License (MIT). See LICENSE.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 2
- 推荐数: 2
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-27