Skip to content

Commit

Permalink
Add warning for completion calls
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkuzmik committed Nov 14, 2024
1 parent 29f1148 commit 0073f95
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion sdks/python/src/opik/integrations/anthropic/opik_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand All @@ -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


Expand Down

0 comments on commit 0073f95

Please sign in to comment.