posthoganalytics 6.3.1__tar.gz → 6.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. {posthoganalytics-6.3.1/posthoganalytics.egg-info → posthoganalytics-6.3.2}/PKG-INFO +1 -1
  2. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/ai/utils.py +22 -3
  3. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/version.py +1 -1
  4. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2/posthoganalytics.egg-info}/PKG-INFO +1 -1
  5. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/LICENSE +0 -0
  6. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/MANIFEST.in +0 -0
  7. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/README.md +0 -0
  8. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/__init__.py +0 -0
  9. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/ai/__init__.py +0 -0
  10. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/ai/anthropic/__init__.py +0 -0
  11. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/ai/anthropic/anthropic.py +0 -0
  12. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/ai/anthropic/anthropic_async.py +0 -0
  13. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/ai/anthropic/anthropic_providers.py +0 -0
  14. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/ai/gemini/__init__.py +0 -0
  15. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/ai/gemini/gemini.py +0 -0
  16. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/ai/langchain/__init__.py +0 -0
  17. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/ai/langchain/callbacks.py +0 -0
  18. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/ai/openai/__init__.py +0 -0
  19. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/ai/openai/openai.py +0 -0
  20. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/ai/openai/openai_async.py +0 -0
  21. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/ai/openai/openai_providers.py +0 -0
  22. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/args.py +0 -0
  23. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/client.py +0 -0
  24. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/consumer.py +0 -0
  25. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/contexts.py +0 -0
  26. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/exception_capture.py +0 -0
  27. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/exception_utils.py +0 -0
  28. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/feature_flags.py +0 -0
  29. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/integrations/__init__.py +0 -0
  30. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/integrations/django.py +0 -0
  31. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/poller.py +0 -0
  32. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/py.typed +0 -0
  33. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/request.py +0 -0
  34. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/test/__init__.py +0 -0
  35. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/test/test_before_send.py +0 -0
  36. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/test/test_client.py +0 -0
  37. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/test/test_consumer.py +0 -0
  38. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/test/test_contexts.py +0 -0
  39. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/test/test_exception_capture.py +0 -0
  40. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/test/test_feature_flag.py +0 -0
  41. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/test/test_feature_flag_result.py +0 -0
  42. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/test/test_feature_flags.py +0 -0
  43. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/test/test_module.py +0 -0
  44. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/test/test_request.py +0 -0
  45. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/test/test_size_limited_dict.py +0 -0
  46. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/test/test_types.py +0 -0
  47. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/test/test_utils.py +0 -0
  48. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/types.py +0 -0
  49. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics/utils.py +0 -0
  50. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics.egg-info/SOURCES.txt +0 -0
  51. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics.egg-info/dependency_links.txt +0 -0
  52. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics.egg-info/requires.txt +0 -0
  53. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/posthoganalytics.egg-info/top_level.txt +0 -0
  54. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/pyproject.toml +0 -0
  55. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/setup.cfg +0 -0
  56. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/setup.py +0 -0
  57. {posthoganalytics-6.3.1 → posthoganalytics-6.3.2}/setup_analytics.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: posthoganalytics
3
- Version: 6.3.1
3
+ Version: 6.3.2
4
4
  Summary: Integrate PostHog into any python application.
5
5
  Home-page: https://github.com/posthog/posthog-python
6
6
  Author: Posthog
@@ -118,7 +118,12 @@ def format_response(response, provider: str):
118
118
  def format_response_anthropic(response):
119
119
  output = []
120
120
  for choice in response.content:
121
- if choice.text:
121
+ if (
122
+ hasattr(choice, "type")
123
+ and choice.type == "text"
124
+ and hasattr(choice, "text")
125
+ and choice.text
126
+ ):
122
127
  output.append(
123
128
  {
124
129
  "role": "assistant",
@@ -225,8 +230,21 @@ def format_response_gemini(response):
225
230
 
226
231
  def format_tool_calls(response, provider: str):
227
232
  if provider == "anthropic":
228
- if hasattr(response, "tools") and response.tools and len(response.tools) > 0:
229
- return response.tools
233
+ if hasattr(response, "content") and response.content:
234
+ tool_calls = []
235
+
236
+ for content_item in response.content:
237
+ if hasattr(content_item, "type") and content_item.type == "tool_use":
238
+ tool_calls.append(
239
+ {
240
+ "type": content_item.type,
241
+ "id": content_item.id,
242
+ "name": content_item.name,
243
+ "input": content_item.input,
244
+ }
245
+ )
246
+
247
+ return tool_calls if tool_calls else None
230
248
  elif provider == "openai":
231
249
  # Handle both Chat Completions and Responses API
232
250
  if hasattr(response, "choices") and response.choices:
@@ -378,6 +396,7 @@ def call_llm_and_track_usage(
378
396
  }
379
397
 
380
398
  tool_calls = format_tool_calls(response, provider)
399
+
381
400
  if tool_calls:
382
401
  event_properties["$ai_tools"] = with_privacy_mode(
383
402
  ph_client, posthog_privacy_mode, tool_calls
@@ -1,4 +1,4 @@
1
- VERSION = "6.3.1"
1
+ VERSION = "6.3.2"
2
2
 
3
3
  if __name__ == "__main__":
4
4
  print(VERSION, end="") # noqa: T201
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: posthoganalytics
3
- Version: 6.3.1
3
+ Version: 6.3.2
4
4
  Summary: Integrate PostHog into any python application.
5
5
  Home-page: https://github.com/posthog/posthog-python
6
6
  Author: Posthog