anthropic_tracer
Message
Bases: Message
Wrapper of anthropic.types.Message
with ImpactsOutput
MessageStream
Bases: MessageStream
Wrapper of anthropic.lib.streaming.MessageStream
with ImpactsOutput
AsyncMessageStream
Bases: AsyncMessageStream
Wrapper of anthropic.lib.streaming.AsyncMessageStream
with ImpactsOutput
MessageStreamManager(api_request)
AsyncMessageStreamManager(api_request)
AnthropicInstrumentor()
Instrumentor initialized by EcoLogits to automatically wrap all Anthropic calls
Source code in ecologits/tracers/anthropic_tracer.py
anthropic_chat_wrapper(wrapped, instance, args, kwargs)
Function that wraps an Anthropic answer with computed impacts
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wrapped |
Callable
|
Callable that returns the LLM response |
required |
instance |
Anthropic
|
Never used - for compatibility with |
required |
args |
Any
|
Arguments of the callable |
required |
kwargs |
Any
|
Keyword arguments of the callable |
required |
Returns:
Type | Description |
---|---|
Message
|
A wrapped |
Source code in ecologits/tracers/anthropic_tracer.py
anthropic_async_chat_wrapper(wrapped, instance, args, kwargs)
async
Function that wraps an Anthropic answer with computed impacts in async mode
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wrapped |
Callable
|
Async callable that returns the LLM response |
required |
instance |
AsyncAnthropic
|
Never used - for compatibility with |
required |
args |
Any
|
Arguments of the callable |
required |
kwargs |
Any
|
Keyword arguments of the callable |
required |
Returns:
Type | Description |
---|---|
Message
|
A wrapped |
Source code in ecologits/tracers/anthropic_tracer.py
anthropic_stream_chat_wrapper(wrapped, instance, args, kwargs)
Function that wraps an Anthropic answer with computed impacts in streaming mode
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wrapped |
Callable
|
Callable that returns the LLM response |
required |
instance |
Anthropic
|
Never used - for compatibility with |
required |
args |
Any
|
Arguments of the callable |
required |
kwargs |
Any
|
Keyword arguments of the callable |
required |
Returns:
Type | Description |
---|---|
MessageStreamManager
|
A wrapped |
Source code in ecologits/tracers/anthropic_tracer.py
anthropic_async_stream_chat_wrapper(wrapped, instance, args, kwargs)
Function that wraps an Anthropic answer with computed impacts in streaming and async mode
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wrapped |
Callable
|
Callable that returns the LLM response |
required |
instance |
AsyncAnthropic
|
Never used - for compatibility with |
required |
args |
Any
|
Arguments of the callable |
required |
kwargs |
Any
|
Keyword arguments of the callable |
required |
Returns:
Type | Description |
---|---|
AsyncMessageStreamManager
|
A wrapped |