gac 1.3.1__tar.gz → 1.4.1__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.

Files changed (31) hide show
  1. {gac-1.3.1 → gac-1.4.1}/PKG-INFO +1 -1
  2. {gac-1.3.1 → gac-1.4.1}/src/gac/__version__.py +1 -1
  3. {gac-1.3.1 → gac-1.4.1}/src/gac/ai.py +2 -0
  4. {gac-1.3.1 → gac-1.4.1}/src/gac/ai_utils.py +1 -1
  5. {gac-1.3.1 → gac-1.4.1}/src/gac/init_cli.py +7 -14
  6. {gac-1.3.1 → gac-1.4.1}/src/gac/providers/__init__.py +2 -1
  7. gac-1.4.1/src/gac/providers/zai.py +55 -0
  8. gac-1.3.1/src/gac/providers/zai.py +0 -49
  9. {gac-1.3.1 → gac-1.4.1}/.gitignore +0 -0
  10. {gac-1.3.1 → gac-1.4.1}/LICENSE +0 -0
  11. {gac-1.3.1 → gac-1.4.1}/README.md +0 -0
  12. {gac-1.3.1 → gac-1.4.1}/pyproject.toml +0 -0
  13. {gac-1.3.1 → gac-1.4.1}/src/gac/__init__.py +0 -0
  14. {gac-1.3.1 → gac-1.4.1}/src/gac/cli.py +0 -0
  15. {gac-1.3.1 → gac-1.4.1}/src/gac/config.py +0 -0
  16. {gac-1.3.1 → gac-1.4.1}/src/gac/config_cli.py +0 -0
  17. {gac-1.3.1 → gac-1.4.1}/src/gac/constants.py +0 -0
  18. {gac-1.3.1 → gac-1.4.1}/src/gac/diff_cli.py +0 -0
  19. {gac-1.3.1 → gac-1.4.1}/src/gac/errors.py +0 -0
  20. {gac-1.3.1 → gac-1.4.1}/src/gac/git.py +0 -0
  21. {gac-1.3.1 → gac-1.4.1}/src/gac/main.py +0 -0
  22. {gac-1.3.1 → gac-1.4.1}/src/gac/preprocess.py +0 -0
  23. {gac-1.3.1 → gac-1.4.1}/src/gac/prompt.py +0 -0
  24. {gac-1.3.1 → gac-1.4.1}/src/gac/providers/anthropic.py +0 -0
  25. {gac-1.3.1 → gac-1.4.1}/src/gac/providers/cerebras.py +0 -0
  26. {gac-1.3.1 → gac-1.4.1}/src/gac/providers/groq.py +0 -0
  27. {gac-1.3.1 → gac-1.4.1}/src/gac/providers/ollama.py +0 -0
  28. {gac-1.3.1 → gac-1.4.1}/src/gac/providers/openai.py +0 -0
  29. {gac-1.3.1 → gac-1.4.1}/src/gac/providers/openrouter.py +0 -0
  30. {gac-1.3.1 → gac-1.4.1}/src/gac/security.py +0 -0
  31. {gac-1.3.1 → gac-1.4.1}/src/gac/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gac
3
- Version: 1.3.1
3
+ Version: 1.4.1
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__ = "1.3.1"
3
+ __version__ = "1.4.1"
@@ -17,6 +17,7 @@ from gac.providers import (
17
17
  call_openai_api,
18
18
  call_openrouter_api,
19
19
  call_zai_api,
20
+ call_zai_coding_api,
20
21
  )
21
22
 
22
23
  logger = logging.getLogger(__name__)
@@ -69,6 +70,7 @@ def generate_commit_message(
69
70
  "ollama": call_ollama_api,
70
71
  "openrouter": call_openrouter_api,
71
72
  "zai": call_zai_api,
73
+ "zai-coding": call_zai_coding_api,
72
74
  }
73
75
 
74
76
  # Generate the commit message using centralized retry logic
@@ -93,7 +93,7 @@ def generate_with_retries(
93
93
  provider, model_name = model.split(":", 1)
94
94
 
95
95
  # Validate provider
96
- supported_providers = ["anthropic", "openai", "groq", "cerebras", "ollama", "openrouter", "zai"]
96
+ supported_providers = ["anthropic", "openai", "groq", "cerebras", "ollama", "openrouter", "zai", "zai-coding"]
97
97
  if provider not in supported_providers:
98
98
  raise AIError.model_error(f"Unsupported provider: {provider}. Supported providers: {supported_providers}")
99
99
 
@@ -26,14 +26,15 @@ def init() -> None:
26
26
  ("Ollama", "gemma3"),
27
27
  ("OpenAI", "gpt-4.1-mini"),
28
28
  ("OpenRouter", "openrouter/auto"),
29
- ("Z.AI", "glm-4.6"),
29
+ ("Z.AI", "glm-4.5-air"),
30
+ ("Z.AI Coding", "glm-4.6"),
30
31
  ]
31
32
  provider_names = [p[0] for p in providers]
32
33
  provider = questionary.select("Select your provider:", choices=provider_names).ask()
33
34
  if not provider:
34
35
  click.echo("Provider selection cancelled. Exiting.")
35
36
  return
36
- provider_key = provider.lower().replace(".", "")
37
+ provider_key = provider.lower().replace(".", "").replace(" ", "-")
37
38
  model_suggestion = dict(providers)[provider]
38
39
  model = questionary.text(f"Enter the model (default: {model_suggestion}):", default=model_suggestion).ask()
39
40
  model_to_save = model.strip() if model.strip() else model_suggestion
@@ -42,17 +43,9 @@ def init() -> None:
42
43
 
43
44
  api_key = questionary.password("Enter your API key (input hidden, can be set later):").ask()
44
45
  if api_key:
45
- set_key(str(GAC_ENV_PATH), f"{provider_key.upper()}_API_KEY", api_key)
46
- click.echo(f"Set {provider_key.upper()}_API_KEY (hidden)")
47
-
48
- # Ask about ZAI coding plan if Z.AI provider was selected
49
- if provider_key == "zai":
50
- use_coding_api = questionary.confirm(
51
- "Are you using a Z.AI coding plan? (uses different API endpoint)",
52
- default=False,
53
- ).ask()
54
- if use_coding_api:
55
- set_key(str(GAC_ENV_PATH), "GAC_ZAI_USE_CODING_PLAN", "true")
56
- click.echo("Set GAC_ZAI_USE_CODING_PLAN=true")
46
+ # Z.AI and Z.AI Coding both use the same API key
47
+ api_key_name = "ZAI_API_KEY" if provider_key in ["zai", "zai-coding"] else f"{provider_key.upper()}_API_KEY"
48
+ set_key(str(GAC_ENV_PATH), api_key_name, api_key)
49
+ click.echo(f"Set {api_key_name} (hidden)")
57
50
 
58
51
  click.echo(f"\ngac environment setup complete. You can edit {GAC_ENV_PATH} to update values later.")
@@ -6,7 +6,7 @@ from .groq import call_groq_api
6
6
  from .ollama import call_ollama_api
7
7
  from .openai import call_openai_api
8
8
  from .openrouter import call_openrouter_api
9
- from .zai import call_zai_api
9
+ from .zai import call_zai_api, call_zai_coding_api
10
10
 
11
11
  __all__ = [
12
12
  "call_anthropic_api",
@@ -16,4 +16,5 @@ __all__ = [
16
16
  "call_openai_api",
17
17
  "call_openrouter_api",
18
18
  "call_zai_api",
19
+ "call_zai_coding_api",
19
20
  ]
@@ -0,0 +1,55 @@
1
+ """Z.AI API provider for gac."""
2
+
3
+ import os
4
+
5
+ import httpx
6
+
7
+ from gac.errors import AIError
8
+
9
+
10
+ def _call_zai_api_impl(
11
+ url: str, api_name: str, model: str, messages: list[dict], temperature: float, max_tokens: int
12
+ ) -> str:
13
+ """Internal implementation for Z.AI API calls."""
14
+ api_key = os.getenv("ZAI_API_KEY")
15
+ if not api_key:
16
+ raise AIError.model_error("ZAI_API_KEY not found in environment variables")
17
+
18
+ headers = {"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}
19
+ data = {"model": model, "messages": messages, "temperature": temperature, "max_tokens": max_tokens}
20
+
21
+ try:
22
+ response = httpx.post(url, headers=headers, json=data, timeout=120)
23
+ response.raise_for_status()
24
+ response_data = response.json()
25
+
26
+ # Handle different possible response structures
27
+ if "choices" in response_data and len(response_data["choices"]) > 0:
28
+ choice = response_data["choices"][0]
29
+ if "message" in choice and "content" in choice["message"]:
30
+ content = choice["message"]["content"]
31
+ if content is None:
32
+ raise AIError.model_error(f"{api_name} API returned null content")
33
+ if content == "":
34
+ raise AIError.model_error(f"{api_name} API returned empty content")
35
+ return content
36
+ else:
37
+ raise AIError.model_error(f"{api_name} API response missing content: {response_data}")
38
+ else:
39
+ raise AIError.model_error(f"{api_name} API unexpected response structure: {response_data}")
40
+ except httpx.HTTPStatusError as e:
41
+ raise AIError.model_error(f"{api_name} API error: {e.response.status_code} - {e.response.text}") from e
42
+ except Exception as e:
43
+ raise AIError.model_error(f"Error calling {api_name} API: {str(e)}") from e
44
+
45
+
46
+ def call_zai_api(model: str, messages: list[dict], temperature: float, max_tokens: int) -> str:
47
+ """Call Z.AI regular API directly."""
48
+ url = "https://api.z.ai/api/paas/v4/chat/completions"
49
+ return _call_zai_api_impl(url, "Z.AI", model, messages, temperature, max_tokens)
50
+
51
+
52
+ def call_zai_coding_api(model: str, messages: list[dict], temperature: float, max_tokens: int) -> str:
53
+ """Call Z.AI coding API directly."""
54
+ url = "https://api.z.ai/api/coding/paas/v4/chat/completions"
55
+ return _call_zai_api_impl(url, "Z.AI coding", model, messages, temperature, max_tokens)
@@ -1,49 +0,0 @@
1
- """Z.AI API provider for gac."""
2
-
3
- import os
4
-
5
- import httpx
6
-
7
- from gac.errors import AIError
8
-
9
-
10
- def call_zai_api(model: str, messages: list[dict], temperature: float, max_tokens: int) -> str:
11
- """Call Z.AI API directly."""
12
- api_key = os.getenv("ZAI_API_KEY")
13
- if not api_key:
14
- raise AIError.model_error("ZAI_API_KEY not found in environment variables")
15
-
16
- # Support both regular and coding API endpoints
17
- use_coding_api = os.getenv("GAC_ZAI_USE_CODING_PLAN", "false").lower() in ("true", "1", "yes", "on")
18
- if use_coding_api:
19
- url = "https://api.z.ai/api/coding/paas/v4/chat/completions"
20
- else:
21
- url = "https://api.z.ai/api/paas/v4/chat/completions"
22
-
23
- headers = {"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}
24
-
25
- data = {"model": model, "messages": messages, "temperature": temperature, "max_tokens": max_tokens}
26
-
27
- try:
28
- response = httpx.post(url, headers=headers, json=data, timeout=120)
29
- response.raise_for_status()
30
- response_data = response.json()
31
-
32
- # Handle different possible response structures
33
- if "choices" in response_data and len(response_data["choices"]) > 0:
34
- choice = response_data["choices"][0]
35
- if "message" in choice and "content" in choice["message"]:
36
- content = choice["message"]["content"]
37
- if content is None:
38
- raise AIError.model_error("Z.AI API returned null content")
39
- if content == "":
40
- raise AIError.model_error("Z.AI API returned empty content")
41
- return content
42
- else:
43
- raise AIError.model_error(f"Z.AI API response missing content: {response_data}")
44
- else:
45
- raise AIError.model_error(f"Z.AI API unexpected response structure: {response_data}")
46
- except httpx.HTTPStatusError as e:
47
- raise AIError.model_error(f"Z.AI API error: {e.response.status_code} - {e.response.text}") from e
48
- except Exception as e:
49
- raise AIError.model_error(f"Error calling Z.AI API: {str(e)}") from e
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
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes