gac 1.5.0__tar.gz → 1.5.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 (33) hide show
  1. {gac-1.5.0 → gac-1.5.1}/PKG-INFO +1 -1
  2. {gac-1.5.0 → gac-1.5.1}/src/gac/__version__.py +1 -1
  3. gac-1.5.1/src/gac/providers/gemini.py +70 -0
  4. gac-1.5.0/src/gac/providers/gemini.py +0 -49
  5. {gac-1.5.0 → gac-1.5.1}/.gitignore +0 -0
  6. {gac-1.5.0 → gac-1.5.1}/LICENSE +0 -0
  7. {gac-1.5.0 → gac-1.5.1}/README.md +0 -0
  8. {gac-1.5.0 → gac-1.5.1}/pyproject.toml +0 -0
  9. {gac-1.5.0 → gac-1.5.1}/src/gac/__init__.py +0 -0
  10. {gac-1.5.0 → gac-1.5.1}/src/gac/ai.py +0 -0
  11. {gac-1.5.0 → gac-1.5.1}/src/gac/ai_utils.py +0 -0
  12. {gac-1.5.0 → gac-1.5.1}/src/gac/cli.py +0 -0
  13. {gac-1.5.0 → gac-1.5.1}/src/gac/config.py +0 -0
  14. {gac-1.5.0 → gac-1.5.1}/src/gac/config_cli.py +0 -0
  15. {gac-1.5.0 → gac-1.5.1}/src/gac/constants.py +0 -0
  16. {gac-1.5.0 → gac-1.5.1}/src/gac/diff_cli.py +0 -0
  17. {gac-1.5.0 → gac-1.5.1}/src/gac/errors.py +0 -0
  18. {gac-1.5.0 → gac-1.5.1}/src/gac/git.py +0 -0
  19. {gac-1.5.0 → gac-1.5.1}/src/gac/init_cli.py +0 -0
  20. {gac-1.5.0 → gac-1.5.1}/src/gac/main.py +0 -0
  21. {gac-1.5.0 → gac-1.5.1}/src/gac/preprocess.py +0 -0
  22. {gac-1.5.0 → gac-1.5.1}/src/gac/prompt.py +0 -0
  23. {gac-1.5.0 → gac-1.5.1}/src/gac/providers/__init__.py +0 -0
  24. {gac-1.5.0 → gac-1.5.1}/src/gac/providers/anthropic.py +0 -0
  25. {gac-1.5.0 → gac-1.5.1}/src/gac/providers/cerebras.py +0 -0
  26. {gac-1.5.0 → gac-1.5.1}/src/gac/providers/groq.py +0 -0
  27. {gac-1.5.0 → gac-1.5.1}/src/gac/providers/lmstudio.py +0 -0
  28. {gac-1.5.0 → gac-1.5.1}/src/gac/providers/ollama.py +0 -0
  29. {gac-1.5.0 → gac-1.5.1}/src/gac/providers/openai.py +0 -0
  30. {gac-1.5.0 → gac-1.5.1}/src/gac/providers/openrouter.py +0 -0
  31. {gac-1.5.0 → gac-1.5.1}/src/gac/providers/zai.py +0 -0
  32. {gac-1.5.0 → gac-1.5.1}/src/gac/security.py +0 -0
  33. {gac-1.5.0 → gac-1.5.1}/src/gac/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gac
3
- Version: 1.5.0
3
+ Version: 1.5.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.5.0"
3
+ __version__ = "1.5.1"
@@ -0,0 +1,70 @@
1
+ """Gemini AI provider implementation."""
2
+
3
+ import os
4
+ from typing import Any
5
+
6
+ import httpx
7
+
8
+ from gac.errors import AIError
9
+
10
+
11
+ def call_gemini_api(model: str, messages: list[dict[str, Any]], temperature: float, max_tokens: int) -> str:
12
+ """Call Gemini API directly."""
13
+ api_key = os.getenv("GEMINI_API_KEY")
14
+ if not api_key:
15
+ raise AIError.model_error("GEMINI_API_KEY not found in environment variables")
16
+
17
+ url = f"https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent"
18
+
19
+ # Build contents array following 2025 Gemini API format
20
+ contents = []
21
+
22
+ # Add system instruction as first content with role "system" (2025 format)
23
+ for msg in messages:
24
+ if msg["role"] == "system":
25
+ contents.append({"role": "system", "parts": [{"text": msg["content"]}]})
26
+ break
27
+
28
+ # Add user and assistant messages
29
+ for msg in messages:
30
+ if msg["role"] == "user":
31
+ contents.append({"role": "user", "parts": [{"text": msg["content"]}]})
32
+ elif msg["role"] == "assistant":
33
+ contents.append(
34
+ {
35
+ "role": "model", # Gemini uses "model" instead of "assistant"
36
+ "parts": [{"text": msg["content"]}],
37
+ }
38
+ )
39
+
40
+ payload: dict[str, Any] = {
41
+ "contents": contents,
42
+ "generationConfig": {"temperature": temperature, "maxOutputTokens": max_tokens},
43
+ }
44
+
45
+ headers = {"x-goog-api-key": api_key, "Content-Type": "application/json"}
46
+
47
+ try:
48
+ response = httpx.post(url, headers=headers, json=payload, timeout=120)
49
+ response.raise_for_status()
50
+ response_data = response.json()
51
+
52
+ # Check for candidates and proper response structure
53
+ if not response_data.get("candidates"):
54
+ raise AIError.model_error("Gemini API response missing candidates")
55
+
56
+ candidate = response_data["candidates"][0]
57
+ if "content" not in candidate or "parts" not in candidate["content"] or not candidate["content"]["parts"]:
58
+ raise AIError.model_error("Gemini API response has invalid content structure")
59
+
60
+ content = candidate["content"]["parts"][0].get("text")
61
+ if content is None or content == "":
62
+ raise AIError.model_error("Gemini API response missing text content")
63
+
64
+ return content
65
+ except AIError:
66
+ raise
67
+ except httpx.HTTPStatusError as e:
68
+ raise AIError.model_error(f"Gemini API error: {e.response.status_code} - {e.response.text}") from e
69
+ except Exception as e:
70
+ raise AIError.model_error(f"Error calling Gemini API: {str(e)}") from e
@@ -1,49 +0,0 @@
1
- """Gemini AI provider implementation."""
2
-
3
- import os
4
- from typing import Any
5
-
6
- import httpx
7
-
8
- from gac.errors import AIError
9
-
10
-
11
- def call_gemini_api(model: str, messages: list[dict[str, Any]], temperature: float, max_tokens: int) -> str:
12
- """Call Gemini API directly."""
13
- api_key = os.getenv("GEMINI_API_KEY")
14
- if not api_key:
15
- raise AIError.model_error("GEMINI_API_KEY not found in environment variables")
16
-
17
- url = f"https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent"
18
-
19
- system_content = ""
20
- user_content = ""
21
-
22
- for msg in messages:
23
- if msg["role"] == "system":
24
- system_content = msg["content"]
25
- elif msg["role"] == "user":
26
- user_content = msg["content"]
27
-
28
- payload: dict[str, Any] = {
29
- "contents": [{"role": "user", "parts": [{"text": user_content}]}],
30
- "generationConfig": {"temperature": temperature, "maxOutputTokens": max_tokens},
31
- }
32
-
33
- if system_content:
34
- payload["systemInstruction"] = {"parts": [{"text": system_content}]}
35
-
36
- try:
37
- response = httpx.post(url, params={"key": api_key}, json=payload, timeout=120)
38
- response.raise_for_status()
39
- response_data = response.json()
40
- content = response_data["candidates"][0]["content"]["parts"][0]["text"]
41
- if content is None or content == "":
42
- raise AIError.model_error("Gemini API response missing text content")
43
- return content
44
- except AIError:
45
- raise
46
- except httpx.HTTPStatusError as e:
47
- raise AIError.model_error(f"Gemini API error: {e.response.status_code} - {e.response.text}") from e
48
- except Exception as e:
49
- raise AIError.model_error(f"Error calling Gemini 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
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes