Move to GPT for API consistency

This commit is contained in:
Logan
2026-04-19 08:18:55 -04:00
parent 1e3d691dbd
commit 03212fca51
3 changed files with 23 additions and 26 deletions
+9 -8
View File
@@ -76,14 +76,11 @@ async def _summarize_incident(inc: dict) -> None:
def _sync_summarize(inc: dict, transcripts: list[str]) -> Optional[str]:
from app.config import settings
import google.generativeai as genai
from openai import OpenAI
if not settings.gemini_api_key:
if not settings.openai_api_key:
return None
genai.configure(api_key=settings.gemini_api_key)
model = genai.GenerativeModel("gemini-2.5-flash-lite")
inc_type = inc.get("type", "unknown")
location = inc.get("location") or "unknown location"
tg_ids = ", ".join(inc.get("talkgroup_ids", [])) or "unknown"
@@ -107,8 +104,12 @@ Write a concise factual summary of this incident in 2-4 sentences. Include:
Be factual. Do not speculate beyond what the transcripts say. Do not use bullet points."""
try:
response = model.generate_content(prompt)
return response.text.strip() or None
client = OpenAI(api_key=settings.openai_api_key)
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": prompt}],
)
return response.choices[0].message.content.strip() or None
except Exception as e:
logger.warning(f"Gemini summary failed: {e}")
logger.warning(f"GPT-4o mini summary failed: {e}")
return None