mirror of
https://github.com/hanzoai/insights-python.git
synced 2026-10-30 18:33:17 +00:00
- Remove Posthog = Insights alias from __init__.py - Remove PosthogContextMiddleware alias from django.py - Remove PostHogTracingProcessor alias from processor.py - Change $lib from "posthog-python" to "insights-python" - Change ingestion URLs from posthog.com to insights.hanzo.ai - Rename all posthog_* kwargs to insights_* across AI wrappers - Rename __posthog_exception_captured to __insights_exception_captured - Rename posthog_context_stack contextvar to insights_context_stack - Rename posthog🎏 Redis prefix to insights🎏 - Rename $$_posthog_redacted_* sentinels to $$_insights_redacted_* - Remove POSTHOG_MW_* Django settings fallback, X-POSTHOG-* headers - Rename Prompts(posthog=) param to Prompts(client=) - Update APP_ENDPOINT to us.insights.hanzo.ai - Update all tests, examples, docs, mypy config
66 lines
2.1 KiB
Python
66 lines
2.1 KiB
Python
try:
|
|
import anthropic
|
|
except ImportError:
|
|
raise ModuleNotFoundError(
|
|
"Please install the Anthropic SDK to use this feature: 'pip install anthropic'"
|
|
)
|
|
|
|
from typing import Optional
|
|
|
|
from hanzo_insights.ai.anthropic.anthropic import WrappedMessages
|
|
from hanzo_insights.ai.anthropic.anthropic_async import AsyncWrappedMessages
|
|
from hanzo_insights.client import Client as InsightsClient
|
|
from hanzo_insights import setup
|
|
|
|
|
|
class AnthropicBedrock(anthropic.AnthropicBedrock):
|
|
"""
|
|
A wrapper around the Anthropic Bedrock SDK that automatically sends LLM usage events to Insights.
|
|
"""
|
|
|
|
_ph_client: InsightsClient
|
|
|
|
def __init__(self, insights_client: Optional[InsightsClient] = None, **kwargs):
|
|
super().__init__(**kwargs)
|
|
self._ph_client = insights_client or setup()
|
|
self.messages = WrappedMessages(self)
|
|
|
|
|
|
class AsyncAnthropicBedrock(anthropic.AsyncAnthropicBedrock):
|
|
"""
|
|
A wrapper around the Anthropic Bedrock SDK that automatically sends LLM usage events to Insights.
|
|
"""
|
|
|
|
_ph_client: InsightsClient
|
|
|
|
def __init__(self, insights_client: Optional[InsightsClient] = None, **kwargs):
|
|
super().__init__(**kwargs)
|
|
self._ph_client = insights_client or setup()
|
|
self.messages = AsyncWrappedMessages(self)
|
|
|
|
|
|
class AnthropicVertex(anthropic.AnthropicVertex):
|
|
"""
|
|
A wrapper around the Anthropic Vertex SDK that automatically sends LLM usage events to Insights.
|
|
"""
|
|
|
|
_ph_client: InsightsClient
|
|
|
|
def __init__(self, insights_client: Optional[InsightsClient] = None, **kwargs):
|
|
super().__init__(**kwargs)
|
|
self._ph_client = insights_client or setup()
|
|
self.messages = WrappedMessages(self)
|
|
|
|
|
|
class AsyncAnthropicVertex(anthropic.AsyncAnthropicVertex):
|
|
"""
|
|
A wrapper around the Anthropic Vertex SDK that automatically sends LLM usage events to Insights.
|
|
"""
|
|
|
|
_ph_client: InsightsClient
|
|
|
|
def __init__(self, insights_client: Optional[InsightsClient] = None, **kwargs):
|
|
super().__init__(**kwargs)
|
|
self._ph_client = insights_client or setup()
|
|
self.messages = AsyncWrappedMessages(self)
|