agentlang
Version:
The easiest way to build the most reliable AI agents - enterprise-grade teams of AI agents that collaborate with each other and humans
82 lines • 3.64 kB
TypeScript
import { AgentServiceProvider, AIResponse } from '../provider.js';
import { BaseMessage } from '@langchain/core/messages';
export interface AnthropicConfig {
model?: string;
temperature?: number;
maxTokens?: number;
maxRetries?: number;
apiKey?: string;
stream?: boolean;
clientOptions?: {
defaultHeaders?: Record<string, string>;
[key: string]: any;
};
/**
* Enable prompt caching to reuse context across API calls.
* This reduces latency and costs by caching static portions of prompts.
* Cache has a 5-minute lifetime by default, refreshed on each use.
* Minimum cacheable length: 1024 tokens for Claude 3.5+, 2048 for Haiku.
* Beta header: prompt-caching-2024-07-31
* @see https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
*/
enablePromptCaching?: boolean;
/**
* Cache control type for prompt caching.
* Currently only 'ephemeral' is supported with 5-minute TTL.
* Can be extended to 1-hour with extended-cache-ttl-2025-04-11 beta.
*/
cacheControl?: 'ephemeral';
/**
* Enable extended thinking mode for Claude to show its reasoning process.
* When enabled, responses include thinking blocks showing Claude's thought process.
* Requires minimum budgetTokens of 1024 and counts towards maxTokens.
* NOTE: When thinking is enabled, temperature cannot be customized and will use default.
* Useful for complex reasoning, problem-solving, and transparency.
* @see https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking
*/
enableThinking?: boolean;
/**
* Token budget for thinking mode (minimum 1024).
* Determines how many tokens Claude can use for internal reasoning.
* Larger budgets enable more thorough analysis for complex problems.
* Must be less than maxTokens.
*/
budgetTokens?: number;
/**
* Enable extended output to generate up to 128,000 tokens in a single response.
* Useful for long-form content, detailed reports, extensive code generation.
* Beta header: output-128k-2025-02-19
* Note: Use streaming to avoid timeouts with long outputs.
*/
enableExtendedOutput?: boolean;
/**
* Enable interleaved thinking to see Claude's reasoning in real-time during streaming.
* When combined with extended thinking, thinking blocks are streamed alongside content.
* Provides transparency into Claude's problem-solving process as it happens.
* Beta header: interleaved-thinking-2025-05-14
*/
enableInterleavedThinking?: boolean;
/**
* Enable fine-grained tool streaming for more responsive tool use.
* Streams partial JSON updates and character-by-character tool parameters.
* Improves UI responsiveness when Claude invokes tools.
* Beta header: fine-grained-tool-streaming-2025-05-14
*/
enableFineGrainedToolStreaming?: boolean;
}
export declare class AnthropicProvider implements AgentServiceProvider {
private model;
private config;
constructor(config?: Map<string, any>);
private parseConfig;
invoke(messages: BaseMessage[], _externalToolSpecs: any[] | undefined): Promise<AIResponse>;
/**
* Apply cache control to messages for prompt caching optimization.
* Caches system messages with substantial content (>1000 chars) to reduce costs.
* Cache hits cost 90% less than regular input tokens.
*/
private applyCacheControl;
getConfig(): AnthropicConfig;
updateConfig(newConfig: Partial<AnthropicConfig>): void;
}
//# sourceMappingURL=anthropic.d.ts.map