gac 0.17.6__tar.gz → 0.18.0__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.

@@ -97,7 +97,6 @@ venv.bak/
97
97
 
98
98
  # Package management
99
99
  poetry.toml
100
- uv.lock
101
100
 
102
101
  # =========================
103
102
  # Python tools and linters
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gac
3
- Version: 0.17.6
3
+ Version: 0.18.0
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.6"
3
+ __version__ = "0.18.0"
@@ -28,10 +28,17 @@ 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
- client = anthropic.Anthropic()
32
- # Use the simple count_tokens method
33
- # Note: This is only a rough estimate for newer models
34
- return client.count_tokens(text)
31
+ try:
32
+ client = anthropic.Anthropic()
33
+
34
+ # Use the messages.count_tokens API for accurate counting
35
+ model_name = model.split(":", 1)[1] if ":" in model else "claude-3-5-haiku-latest"
36
+ response = client.messages.count_tokens(model=model_name, messages=[{"role": "user", "content": text}])
37
+
38
+ return response.input_tokens
39
+ except Exception:
40
+ # Fallback to simple estimation for Anthropic models
41
+ return len(text) // 4
35
42
 
36
43
  try:
37
44
  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