From 0073f958c8fecd5510c502685cfd0d7461c15611 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kuzmik Date: Thu, 14 Nov 2024 13:04:25 +0100 Subject: [PATCH] Add warning for completion calls --- .../opik/integrations/anthropic/opik_tracker.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/sdks/python/src/opik/integrations/anthropic/opik_tracker.py b/sdks/python/src/opik/integrations/anthropic/opik_tracker.py index b4ad2a086..0b713facc 100644 --- a/sdks/python/src/opik/integrations/anthropic/opik_tracker.py +++ b/sdks/python/src/opik/integrations/anthropic/opik_tracker.py @@ -68,7 +68,11 @@ def track_anthropic( metadata=metadata, ) batch_create_decorator = messages_batch_decorator.warning_decorator( - "At the moment Opik does not support tracking for `client.beta.messages.batches.create` calls", + "At the moment Opik Anthropic integration does not support tracking for `client.beta.messages.batches.create` calls", + LOGGER, + ) + completions_create_decorator = messages_batch_decorator.warning_decorator( + "Opik Anthropic integration does not support tracking for `client.completions.create` calls", LOGGER, ) @@ -88,6 +92,16 @@ def track_anthropic( exc_info=True, ) + try: + anthropic_client.completions.create = completions_create_decorator( + anthropic_client.completions.create + ) + except Exception: + LOGGER.debug( + "Failed to patch completions.create method. It is likely because it was not implemented in the provided anthropic client", + exc_info=True, + ) + return anthropic_client