gac 0.17.5__tar.gz → 0.17.7__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.

Potentially problematic release.


This version of gac might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gac
3
- Version: 0.17.5
3
+ Version: 0.17.7
4
4
  Summary: AI-powered Git commit message generator with multi-provider support
5
5
  Project-URL: Homepage, https://github.com/cellwebb/gac
6
6
  Project-URL: Documentation, https://github.com/cellwebb/gac#readme
@@ -1,3 +1,3 @@
1
1
  """Version information for gac package."""
2
2
 
3
- __version__ = "0.17.5"
3
+ __version__ = "0.17.7"
@@ -28,7 +28,19 @@ def count_tokens(content: str | list[dict[str, str]] | dict[str, Any], model: st
28
28
  if model.startswith("anthropic"):
29
29
  import anthropic
30
30
 
31
- return anthropic.Client().count_tokens(text)
31
+ try:
32
+ client = anthropic.Anthropic()
33
+ # Extract the actual model name after the provider prefix
34
+ model_name = model.split(":", 1)[1] if ":" in model else "claude-3-5-haiku-latest"
35
+
36
+ # Use the beta messages.count_tokens API for accurate counting
37
+ response = client.messages.count_tokens(
38
+ model=model_name, messages=[{"role": "user", "content": text}], betas=["token-counting-2024-11-01"]
39
+ )
40
+ return response.input_tokens
41
+ except Exception:
42
+ # Fallback to simple estimation for Anthropic models
43
+ return len(text) // 4
32
44
 
33
45
  try:
34
46
  encoding = get_encoding(model)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes