Skip to content

Commit

Permalink
chore: pre-commit exceptions for anthropic
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelrince committed Apr 10, 2024
1 parent 8400285 commit 8b041d8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ test:

test-record:
poetry run pytest --record-mode=once

pre-commit:
pre-commit run --all-files
15 changes: 7 additions & 8 deletions genai_impact/tracers/anthropic_tracer.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
from types import TracebackType
from typing import Any, Callable, Iterator, Generic, TypeVar, Optional
from typing_extensions import override
from typing import Any, Callable, Generic, Iterator, Optional, TypeVar

from typing_extensions import override
from wrapt import wrap_function_wrapper

from genai_impact.compute_impacts import Impacts, compute_llm_impact
from genai_impact.model_repository import models

try:
from anthropic import Anthropic
from anthropic import AsyncAnthropic
from anthropic import Anthropic, AsyncAnthropic
from anthropic.lib.streaming import MessageStream as _MessageStream
from anthropic.types import Message as _Message
from anthropic.types.message_delta_event import MessageDeltaEvent
Expand Down Expand Up @@ -50,11 +49,11 @@ def __stream_text__(self) -> Iterator[str]:
)
self.impacts = impacts

def __init__(self, parent):
def __init__(self, parent) -> None: # noqa: ANN001
super().__init__(
cast_to=parent._cast_to,
cast_to=parent._cast_to, # noqa: SLF001
response=parent.response,
client=parent._client
client=parent._client # noqa: SLF001
)


Expand Down Expand Up @@ -110,7 +109,7 @@ def anthropic_stream_chat_wrapper(
wrapped: Callable, instance: Anthropic, args: Any, kwargs: Any # noqa: ARG001
) -> MessageStreamManager:
response = wrapped(*args, **kwargs)
return MessageStreamManager(response._MessageStreamManager__api_request)
return MessageStreamManager(response._MessageStreamManager__api_request) # noqa: SLF001


class AnthropicInstrumentor:
Expand Down

0 comments on commit 8b041d8

Please sign in to comment.