adachsoft/ai-integration-anthropic
最新稳定版本:v0.3.0
Composer 安装命令:
composer require adachsoft/ai-integration-anthropic
包简介
Anthropic Claude tool-calling SPI adapter for adachsoft/ai-integration.
README 文档
README
Integration of Anthropic Claude (tool calling) with the adachsoft/ai-integration library.
Version
Current version: 0.1.0 (first public release).
Requirements
- PHP
>= 8.3 guzzlehttp/guzzle^7.0 || ^8.0adachsoft/ai-integration^0.6.3
Installation
composer require adachsoft/ai-integration-anthropic:^0.1.0
Basic usage
Example of wiring the Anthropic SPI provider with the tool-calling facade from adachsoft/ai-integration:
use AdachSoft\AiIntegration\PublicApi\Builder\ToolCallingChatFacadeBuilder;
use AdachSoft\AiIntegrationAnthropic\AnthropicToolCallingChatSpi;
$apiKey = getenv('ANTHROPIC_KEY');
$builder = new ToolCallingChatFacadeBuilder();
$builder->withSpiProvider('anthropic', new AnthropicToolCallingChatSpi($apiKey));
$facade = $builder->build();
More detailed usage examples can be found in the production tests:
tests/Production/ToolCalling/AnthropicProviderProductionTest.phptests/Production/ToolCalling/AnthropicFileToolsConversationProductionTest.php
Anthropic cache configuration
This package exposes an explicit configuration surface for controlling Anthropic ephemeral cache via
ToolCallingChatSpiRequest::$parameters. All cache-related keys are prefixed with ai_integration-.
You can control three independent sections:
ai_integration-cache_system– caching of the system prompt (off,5min,1hour).ai_integration-cache_tools– caching of tool definitions (off,5min,1hour).ai_integration-cache_messages– caching of conversation messages (off,5min,1hour).
When ai_integration-cache_messages is enabled (5min or 1hour), you can also choose how the
message cache is applied using:
ai_integration-cache_messages_strategy– built-in strategies:off,first_user,last_user.
The cache layer is opt-in and non-intrusive – if you do not provide any ai_integration-* keys,
all cache behaviour is disabled and requests behave exactly as before.
For a full description of the configuration format, TTL semantics, beta headers and built-in message cache strategies, see:
docs/CACHE_STRATEGIES.md
Tests
The default phpunit.xml configuration defines two test suites:
unit– unit tests (no production calls).production– production/integration tests that require a real Anthropic API key.
Example commands:
# All tests
vendor/bin/phpunit
# Only unit tests
vendor/bin/phpunit --testsuite unit
# Only production tests (requires ANTHROPIC_KEY)
ANTHROPIC_KEY=... vendor/bin/phpunit --testsuite production
统计信息
- 总下载量: 12
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-10