cohere_tracer
NonStreamedChatResponse
Bases: NonStreamedChatResponse
Wrapper of cohere.types.non_streamed_chat_response.NonStreamedChatResponse
with ImpactsOutput
StreamEndStreamedChatResponse
Bases: StreamEndStreamedChatResponse
Wrapper of cohere.types.streamed_chat_response.StreamEndStreamedChatResponse
with ImpactsOutput
CohereInstrumentor()
Instrumentor initialized by EcoLogits to automatically wrap all Cohere calls
Source code in ecologits/tracers/cohere_tracer.py
cohere_chat_wrapper(wrapped, instance, args, kwargs)
Function that wraps a Cohere answer with computed impacts
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wrapped |
Callable
|
Callable that returns the LLM response |
required |
instance |
Client
|
Never used - for compatibility with |
required |
args |
Any
|
Arguments of the callable |
required |
kwargs |
Any
|
Keyword arguments of the callable |
required |
Returns:
Type | Description |
---|---|
NonStreamedChatResponse
|
A wrapped |
Source code in ecologits/tracers/cohere_tracer.py
cohere_async_chat_wrapper(wrapped, instance, args, kwargs)
async
Function that wraps a Cohere answer with computed impacts in async mode
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wrapped |
Callable
|
Async callable that returns the LLM response |
required |
instance |
AsyncClient
|
Never used - for compatibility with |
required |
args |
Any
|
Arguments of the callable |
required |
kwargs |
Any
|
Keyword arguments of the callable |
required |
Returns:
Type | Description |
---|---|
NonStreamedChatResponse
|
A wrapped |
Source code in ecologits/tracers/cohere_tracer.py
cohere_stream_chat_wrapper(wrapped, instance, args, kwargs)
Function that wraps a Cohere answer with computed impacts in streaming mode
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wrapped |
Callable
|
Callable that returns the LLM response |
required |
instance |
Client
|
Never used - for compatibility with |
required |
args |
Any
|
Arguments of the callable |
required |
kwargs |
Any
|
Keyword arguments of the callable |
required |
Returns:
Type | Description |
---|---|
Iterator[StreamedChatResponse]
|
A wrapped |
Source code in ecologits/tracers/cohere_tracer.py
cohere_async_stream_chat_wrapper(wrapped, instance, args, kwargs)
async
Function that wraps a Cohere answer with computed impacts in streaming and async mode
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wrapped |
Callable
|
Callable that returns the LLM response |
required |
instance |
AsyncClient
|
Never used - for compatibility with |
required |
args |
Any
|
Arguments of the callable |
required |
kwargs |
Any
|
Keyword arguments of the callable |
required |
Returns:
Type | Description |
---|---|
AsyncIterator[StreamedChatResponse]
|
A wrapped |