gac 1.12.0__py3-none-any.whl → 1.12.1__py3-none-any.whl

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.

gac/__version__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """Version information for gac package."""
2
2
 
3
- __version__ = "1.12.0"
3
+ __version__ = "1.12.1"
gac/providers/gemini.py CHANGED
@@ -16,32 +16,37 @@ def call_gemini_api(model: str, messages: list[dict[str, Any]], temperature: flo
16
16
 
17
17
  url = f"https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent"
18
18
 
19
- # Build contents array following 2025 Gemini API format
20
- contents = []
19
+ # Build Gemini request payload, converting roles to supported values.
20
+ contents: list[dict[str, Any]] = []
21
+ system_instruction_parts: list[dict[str, str]] = []
21
22
 
22
- # Add system instruction as first content with role "system" (2025 format)
23
23
  for msg in messages:
24
- if msg["role"] == "system":
25
- contents.append({"role": "system", "parts": [{"text": msg["content"]}]})
26
- break
24
+ role = msg.get("role")
25
+ content_value = msg.get("content")
26
+ content = "" if content_value is None else str(content_value)
27
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
- )
28
+ if role == "system":
29
+ if content.strip():
30
+ system_instruction_parts.append({"text": content})
31
+ continue
32
+
33
+ if role == "assistant":
34
+ gemini_role = "model"
35
+ elif role == "user":
36
+ gemini_role = "user"
37
+ else:
38
+ raise AIError.model_error(f"Unsupported message role for Gemini API: {role}")
39
+
40
+ contents.append({"role": gemini_role, "parts": [{"text": content}]})
39
41
 
40
42
  payload: dict[str, Any] = {
41
43
  "contents": contents,
42
44
  "generationConfig": {"temperature": temperature, "maxOutputTokens": max_tokens},
43
45
  }
44
46
 
47
+ if system_instruction_parts:
48
+ payload["systemInstruction"] = {"role": "system", "parts": system_instruction_parts}
49
+
45
50
  headers = {"x-goog-api-key": api_key, "Content-Type": "application/json"}
46
51
 
47
52
  try:
@@ -50,18 +55,26 @@ def call_gemini_api(model: str, messages: list[dict[str, Any]], temperature: flo
50
55
  response_data = response.json()
51
56
 
52
57
  # Check for candidates and proper response structure
53
- if not response_data.get("candidates"):
58
+ candidates = response_data.get("candidates")
59
+ if not candidates:
54
60
  raise AIError.model_error("Gemini API response missing candidates")
55
61
 
56
- candidate = response_data["candidates"][0]
62
+ candidate = candidates[0]
57
63
  if "content" not in candidate or "parts" not in candidate["content"] or not candidate["content"]["parts"]:
58
64
  raise AIError.model_error("Gemini API response has invalid content structure")
59
65
 
60
- content = candidate["content"]["parts"][0].get("text")
61
- if content is None or content == "":
66
+ parts = candidate["content"]["parts"]
67
+ content_text: str | None = None
68
+ for part in parts:
69
+ if isinstance(part, dict):
70
+ part_text = part.get("text")
71
+ if isinstance(part_text, str) and part_text:
72
+ content_text = part_text
73
+ break
74
+ if content_text is None:
62
75
  raise AIError.model_error("Gemini API response missing text content")
63
76
 
64
- return content
77
+ return content_text
65
78
  except AIError:
66
79
  raise
67
80
  except httpx.HTTPStatusError as e:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gac
3
- Version: 1.12.0
3
+ Version: 1.12.1
4
4
  Summary: LLM-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,5 +1,5 @@
1
1
  gac/__init__.py,sha256=z9yGInqtycFIT3g1ca24r-A3699hKVaRqGUI79wsmMc,415
2
- gac/__version__.py,sha256=pz_YrWiIGihOSHm_4WiV9sLizQLrXIAAXp4teEYrS0A,67
2
+ gac/__version__.py,sha256=W_iXAKBFCbkEbavSS6ki4K6BiQo44M-lYYWUz-aVbZU,67
3
3
  gac/ai.py,sha256=3Po9J0b1bjqtMs3p62yUMOMCU3ZT3iyh-QsagmevSWY,4081
4
4
  gac/ai_utils.py,sha256=tZNLGJEyKhvBQ8zI0xZ56gfI6optHdkoHUa2ZzEtdBQ,7373
5
5
  gac/cli.py,sha256=crUUI6osYtE3QAZ7r6DRlVk9gR3X2PctzS1sssVQ9_g,5070
@@ -21,7 +21,7 @@ gac/providers/cerebras.py,sha256=Ik8lhlsliGJVkgDgqlThfpra9tqbdYQZkaC4eNxRd9w,164
21
21
  gac/providers/chutes.py,sha256=cclJOLuGVIiiaF-9Bs1kH6SSOhEmduGB2zZ86KIaXKw,2617
22
22
  gac/providers/deepseek.py,sha256=leT2S4_CE6JzwF3skDd4umBsu2rkJOJ66AfOdSL5wGc,1643
23
23
  gac/providers/fireworks.py,sha256=zsWhf6LMVdtsD9keXRFwgn9lCQigz6VmrDl6vqIVkdI,1688
24
- gac/providers/gemini.py,sha256=GZQz6Y9fd5-xk-U4pXn9bXLeBowxDXOYDyWyrtjFurM,2909
24
+ gac/providers/gemini.py,sha256=kl9WKdPm_ANYk0hsrUyMdACzR0cm8Eui9M1IwObYW-4,3348
25
25
  gac/providers/groq.py,sha256=9v2fAjDa_iRNHFptiUBN8Vt7ZDKkW_JOmIBeYvycD1M,2806
26
26
  gac/providers/lmstudio.py,sha256=R82-f0tWdFfGQxLT6o3Q2tfvYguF7ESUg9DEUHNyrDk,2146
27
27
  gac/providers/minimax.py,sha256=oI5rEVlkcYenNUNH53zS00X8NqpcZ1gMsTGzQCsmes4,1630
@@ -32,8 +32,8 @@ gac/providers/streamlake.py,sha256=KAA2ZnpuEI5imzvdWVWUhEBHSP0BMnprKXte6CbwBWY,2
32
32
  gac/providers/synthetic.py,sha256=sRMIJTS9LpcXd9A7qp_ZjZxdqtTKRn9fl1W4YwJZP4c,1855
33
33
  gac/providers/together.py,sha256=1bUIVHfYzcEDw4hQPE8qV6hjc2JNHPv_khVgpk2IJxI,1667
34
34
  gac/providers/zai.py,sha256=kywhhrCfPBu0rElZyb-iENxQxxpVGykvePuL4xrXlaU,2739
35
- gac-1.12.0.dist-info/METADATA,sha256=tssJw0ytHWHFn5YgNjNdKWLcxEaWffc6BR4WHGXctDc,7837
36
- gac-1.12.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
37
- gac-1.12.0.dist-info/entry_points.txt,sha256=tdjN-XMmcWfL92swuRAjT62bFLOAwk9bTMRLGP5Z4aI,36
38
- gac-1.12.0.dist-info/licenses/LICENSE,sha256=vOab37NouL1PNs5BswnPayrMCqaN2sqLfMQfqPDrpZg,1103
39
- gac-1.12.0.dist-info/RECORD,,
35
+ gac-1.12.1.dist-info/METADATA,sha256=8ssBlAyMYo-EF-VTs0tIIm7PPgSji63l7MmxRV48x6E,7837
36
+ gac-1.12.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
37
+ gac-1.12.1.dist-info/entry_points.txt,sha256=tdjN-XMmcWfL92swuRAjT62bFLOAwk9bTMRLGP5Z4aI,36
38
+ gac-1.12.1.dist-info/licenses/LICENSE,sha256=vOab37NouL1PNs5BswnPayrMCqaN2sqLfMQfqPDrpZg,1103
39
+ gac-1.12.1.dist-info/RECORD,,
File without changes