Skip to content

Commit 9dbed16

Browse files
committed
fix(llmo): remove privacy mode from $ai_tools
1 parent 4981de4 commit 9dbed16

File tree

4 files changed

+15
-39
lines changed

4 files changed

+15
-39
lines changed

posthog/ai/langchain/callbacks.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -558,11 +558,7 @@ def _capture_generation(
558558
}
559559

560560
if run.tools:
561-
event_properties["$ai_tools"] = with_privacy_mode(
562-
self._ph_client,
563-
self._privacy_mode,
564-
run.tools,
565-
)
561+
event_properties["$ai_tools"] = run.tools
566562

567563
if isinstance(output, BaseException):
568564
event_properties["$ai_http_status"] = _get_http_status(output)

posthog/ai/openai/openai.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def _capture_streaming_event(
184184
usage_stats: Dict[str, int],
185185
latency: float,
186186
output: Any,
187-
tool_calls: Optional[List[Dict[str, Any]]] = None,
187+
available_tool_calls: Optional[List[Dict[str, Any]]] = None,
188188
):
189189
if posthog_trace_id is None:
190190
posthog_trace_id = str(uuid.uuid4())
@@ -214,12 +214,8 @@ def _capture_streaming_event(
214214
**(posthog_properties or {}),
215215
}
216216

217-
if tool_calls:
218-
event_properties["$ai_tools"] = with_privacy_mode(
219-
self._client._ph_client,
220-
posthog_privacy_mode,
221-
tool_calls,
222-
)
217+
if available_tool_calls:
218+
event_properties["$ai_tools"] = available_tool_calls
223219

224220
if posthog_distinct_id is None:
225221
event_properties["$process_person_profile"] = False
@@ -421,7 +417,7 @@ def _capture_streaming_event(
421417
usage_stats: Dict[str, int],
422418
latency: float,
423419
output: Any,
424-
tool_calls: Optional[List[Dict[str, Any]]] = None,
420+
available_tool_calls: Optional[List[Dict[str, Any]]] = None,
425421
):
426422
if posthog_trace_id is None:
427423
posthog_trace_id = str(uuid.uuid4())
@@ -451,12 +447,8 @@ def _capture_streaming_event(
451447
**(posthog_properties or {}),
452448
}
453449

454-
if tool_calls:
455-
event_properties["$ai_tools"] = with_privacy_mode(
456-
self._client._ph_client,
457-
posthog_privacy_mode,
458-
tool_calls,
459-
)
450+
if available_tool_calls:
451+
event_properties["$ai_tools"] = available_tool_calls
460452

461453
if posthog_distinct_id is None:
462454
event_properties["$process_person_profile"] = False

posthog/ai/openai/openai_async.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ async def _capture_streaming_event(
185185
usage_stats: Dict[str, int],
186186
latency: float,
187187
output: Any,
188-
tool_calls: Optional[List[Dict[str, Any]]] = None,
188+
available_tool_calls: Optional[List[Dict[str, Any]]] = None,
189189
):
190190
if posthog_trace_id is None:
191191
posthog_trace_id = str(uuid.uuid4())
@@ -215,12 +215,8 @@ async def _capture_streaming_event(
215215
**(posthog_properties or {}),
216216
}
217217

218-
if tool_calls:
219-
event_properties["$ai_tools"] = with_privacy_mode(
220-
self._client._ph_client,
221-
posthog_privacy_mode,
222-
tool_calls,
223-
)
218+
if available_tool_calls:
219+
event_properties["$ai_tools"] = available_tool_calls
224220

225221
if posthog_distinct_id is None:
226222
event_properties["$process_person_profile"] = False
@@ -425,7 +421,7 @@ async def _capture_streaming_event(
425421
usage_stats: Dict[str, int],
426422
latency: float,
427423
output: Any,
428-
tool_calls: Optional[List[Dict[str, Any]]] = None,
424+
available_tool_calls: Optional[List[Dict[str, Any]]] = None,
429425
):
430426
if posthog_trace_id is None:
431427
posthog_trace_id = str(uuid.uuid4())
@@ -455,12 +451,8 @@ async def _capture_streaming_event(
455451
**(posthog_properties or {}),
456452
}
457453

458-
if tool_calls:
459-
event_properties["$ai_tools"] = with_privacy_mode(
460-
self._client._ph_client,
461-
posthog_privacy_mode,
462-
tool_calls,
463-
)
454+
if available_tool_calls:
455+
event_properties["$ai_tools"] = available_tool_calls
464456

465457
if posthog_distinct_id is None:
466458
event_properties["$process_person_profile"] = False

posthog/ai/utils.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,7 @@ def call_llm_and_track_usage(
379379
available_tool_calls = extract_available_tool_calls(provider, kwargs)
380380

381381
if available_tool_calls:
382-
event_properties["$ai_tools"] = with_privacy_mode(
383-
ph_client, posthog_privacy_mode, available_tool_calls
384-
)
382+
event_properties["$ai_tools"] = available_tool_calls
385383

386384
if (
387385
usage.get("cache_read_input_tokens") is not None
@@ -495,9 +493,7 @@ async def call_llm_and_track_usage_async(
495493
available_tool_calls = extract_available_tool_calls(provider, kwargs)
496494

497495
if available_tool_calls:
498-
event_properties["$ai_tools"] = with_privacy_mode(
499-
ph_client, posthog_privacy_mode, available_tool_calls
500-
)
496+
event_properties["$ai_tools"] = available_tool_calls
501497

502498
if (
503499
usage.get("cache_read_input_tokens") is not None

0 commit comments

Comments
 (0)