Files
KARL/gitea_bot/gemini_client.py
Kalle Bracht 3b4dcabe66 Initial commit
Creates an agent bot that reviews code to repositories that is has access to if it gets added as code reviewer

Co-authored-by: Copilot <copilot@github.com>
2026-05-02 10:44:51 +02:00

22 lines
673 B
Python

import os
import google.genai as genai
class GeminiClient:
def __init__(self):
self.api_key = os.getenv("GOOGLE_API_KEY")
if not self.api_key:
raise RuntimeError("GOOGLE_API_KEY must be set")
# Google Developer AI model (configurable via env).
self.model = os.getenv("GOOGLE_MODEL", "gemini-2.5-pro")
self.client = genai.Client(api_key=self.api_key)
def generate_review(self, prompt: str) -> str:
"""Send prompt to Gemini and return the review."""
response = self.client.models.generate_content(
model=self.model,
contents=prompt
)
return response.text