pydantic / logfire

Uncomplicated Observability for Python and beyond! 🪵🔥
https://docs.pydantic.dev/logfire/
MIT License
1.85k stars 55 forks source link

Anthropic Instrumentation errors #313

Closed bllchmbrs closed 1 month ago

bllchmbrs commented 1 month ago

Description

Received the following error on a instrument_anthopic call.


File ~/an-env/lib/python3.11/site-packages/logfire/_internal/main.py:1012, in Logfire.instrument_anthropic(self, anthropic_client, suppress_other_instrumentation)
    962 """Instrument an Anthropic client so that spans are automatically created for each request.
    963 
    964 The following methods are instrumented for both the sync and the async clients:
   (...)
   1008         Use of this context manager is optional.
   1009 """
   1010 import anthropic
-> 1012 from .integrations.llm_providers.anthropic import get_endpoint_config, is_async_client, on_response
   1013 from .integrations.llm_providers.llm_provider import instrument_llm_provider
   1015 self._warn_if_not_initialized_for_instrumentation()

File ~/an-env/lib/python3.11/site-packages/logfire/_internal/integrations/llm_providers/anthropic.py:6
      3 from typing import TYPE_CHECKING, Any
      5 import anthropic
----> 6 from anthropic.types import Message, RawContentBlockDeltaEvent, RawContentBlockStartEvent, TextBlock, TextDelta
      8 from .types import EndpointConfig
     10 if TYPE_CHECKING:

ImportError: cannot import name 'RawContentBlockDeltaEvent' from 'anthropic.types' (/Users/someuser/an-env/lib/python3.11/site-packages/anthropic/types/__init__.py)

### Python, Logfire & OS Versions, related packages (not required)
logfire="0.46.1"
platform="macOS-10.16-x86_64-i386-64bit"
python="3.11.5 (main, Sep 11 2023, 08:19:27) [Clang 14.0.6 ]"
anthropic==0.25.9
Kludex commented 1 month ago

What's the antrophic version?

bllchmbrs commented 1 month ago

Added above too anthropic==0.25.9 (from pip freeze | grep anthro)