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
63 lines
1.8 KiB
Python
63 lines
1.8 KiB
Python
from parameterized import parameterized
|
|
|
|
from hanzo_insights.ai.utils import _get_tokens_source
|
|
|
|
|
|
@parameterized.expand(
|
|
[
|
|
("no_insights_properties", {"$ai_input_tokens": 100}, None, "sdk"),
|
|
("empty_insights_properties", {"$ai_input_tokens": 100}, {}, "sdk"),
|
|
(
|
|
"unrelated_insights_properties",
|
|
{"$ai_input_tokens": 100},
|
|
{"foo": "bar"},
|
|
"sdk",
|
|
),
|
|
(
|
|
"override_input_tokens",
|
|
{"$ai_input_tokens": 100},
|
|
{"$ai_input_tokens": 999},
|
|
"passthrough",
|
|
),
|
|
(
|
|
"override_output_tokens",
|
|
{"$ai_output_tokens": 50},
|
|
{"$ai_output_tokens": 999},
|
|
"passthrough",
|
|
),
|
|
(
|
|
"override_total_tokens",
|
|
{"$ai_input_tokens": 100},
|
|
{"$ai_total_tokens": 999},
|
|
"passthrough",
|
|
),
|
|
(
|
|
"override_cache_read",
|
|
{"$ai_input_tokens": 100},
|
|
{"$ai_cache_read_input_tokens": 500},
|
|
"passthrough",
|
|
),
|
|
(
|
|
"override_cache_creation",
|
|
{"$ai_input_tokens": 100},
|
|
{"$ai_cache_creation_input_tokens": 200},
|
|
"passthrough",
|
|
),
|
|
(
|
|
"override_reasoning_tokens",
|
|
{"$ai_input_tokens": 100},
|
|
{"$ai_reasoning_tokens": 300},
|
|
"passthrough",
|
|
),
|
|
(
|
|
"mixed_override_and_custom",
|
|
{"$ai_input_tokens": 100},
|
|
{"$ai_input_tokens": 999, "custom_key": "value"},
|
|
"passthrough",
|
|
),
|
|
]
|
|
)
|
|
def test_get_tokens_source(name, sdk_tags, insights_properties, expected):
|
|
result = _get_tokens_source(sdk_tags, insights_properties)
|
|
assert result == expected
|