Skip to content

Commit 9ef58ca

Browse files
authored
Merge pull request #4 from LeafCreeper/copilot/remove-groq-support
Replace Groq fallback with Gemini 2.5 series
2 parents 1f61e2e + f0391b9 commit 9ef58ca

4 files changed

Lines changed: 23 additions & 24 deletions

File tree

.github/workflows/check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
UISPsw: ${{ secrets.UISPSW }}
9595
COURSE_IDS: ${{ secrets.COURSE_IDS }}
9696
DASHSCOPE_API_KEY: ${{ secrets.DASHSCOPE_API_KEY }}
97-
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
97+
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
9898
SMTP_EMAIL: ${{ secrets.SMTP_EMAIL }}
9999
SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }}
100100
RECEIVER_EMAIL: ${{ secrets.RECEIVER_EMAIL }}

.github/workflows/single_run.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595
UISPsw: ${{ secrets.UISPSW }}
9696
COURSE_IDS: ${{ inputs.course_ids }}
9797
DASHSCOPE_API_KEY: ${{ secrets.DASHSCOPE_API_KEY }}
98-
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
98+
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
9999
SMTP_EMAIL: ${{ secrets.SMTP_EMAIL }}
100100
SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }}
101101
RECEIVER_EMAIL: ${{ secrets.RECEIVER_EMAIL }}

src/config.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,13 @@
3030
"ZhipuAI/GLM-4.7"
3131
]
3232

33-
# Groq fallback (for content policy bypass)
34-
GROQ_API_KEY = os.environ.get("GROQ_API_KEY", "")
35-
GROQ_BASE_URL = "https://api.groq.com/openai/v1"
36-
GROQ_MODELS = [
37-
"llama-3.3-70b-versatile",
38-
"llama-4-maverick",
39-
"llama-4-scout",
40-
"openai/gpt-oss-120b",
33+
# Gemini fallback (for content policy bypass)
34+
GEMINI_API_KEY = os.environ.get("GEMINI_API_KEY", "")
35+
GEMINI_BASE_URL = "https://generativelanguage.googleapis.com/v1beta/openai/"
36+
GEMINI_MODELS = [
37+
"gemini-2.5-flash",
38+
"gemini-2.5-pro",
39+
"gemini-2.5-flash-lite",
4140
]
4241

4342
# QQ SMTP

src/summarizer.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ def __init__(self):
3535
)
3636
self.models = list(config.LLM_MODELS)
3737

38-
self._groq_client = None
39-
if config.GROQ_API_KEY:
40-
self._groq_client = OpenAI(
41-
api_key=config.GROQ_API_KEY,
42-
base_url=config.GROQ_BASE_URL,
38+
self._gemini_client = None
39+
if config.GEMINI_API_KEY:
40+
self._gemini_client = OpenAI(
41+
api_key=config.GEMINI_API_KEY,
42+
base_url=config.GEMINI_BASE_URL,
4343
)
4444

4545
def _call_llm(self, client: OpenAI, model: str,
@@ -69,7 +69,7 @@ def _call_llm(self, client: OpenAI, model: str,
6969
def summarize(self, title: str, content: str) -> tuple[str, str]:
7070
"""Summarize lecture content, trying multiple models on failure.
7171
72-
If all primary models fail due to content policy, falls back to Groq.
72+
If all primary models fail due to content policy, falls back to Gemini.
7373
7474
Returns:
7575
(summary, model_used) tuple.
@@ -91,18 +91,18 @@ def summarize(self, title: str, content: str) -> tuple[str, str]:
9191
if _is_content_blocked(e):
9292
content_blocked = True
9393

94-
# Fallback: Groq models (when content policy blocks primary models)
95-
if content_blocked and self._groq_client:
96-
print("[Summarizer] Content blocked by primary platform, trying Groq...")
97-
for model in config.GROQ_MODELS:
94+
# Fallback: Gemini models (when content policy blocks primary models)
95+
if content_blocked and self._gemini_client:
96+
print("[Summarizer] Content blocked by primary platform, trying Gemini...")
97+
for model in config.GEMINI_MODELS:
9898
try:
9999
result = self._call_llm(
100-
self._groq_client, model, title, content,
100+
self._gemini_client, model, title, content,
101101
)
102-
return (result, f"groq/{model}")
102+
return (result, f"gemini/{model}")
103103
except Exception as e:
104-
print(f"[Summarizer] groq/{model} failed: {type(e).__name__}: {e}")
105-
errors.append(f"groq/{model}: {e}")
104+
print(f"[Summarizer] gemini/{model} failed: {type(e).__name__}: {e}")
105+
errors.append(f"gemini/{model}: {e}")
106106

107107
raise RuntimeError(
108108
"All LLM models failed:\n" + "\n".join(errors)

0 commit comments

Comments
 (0)