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>
22 lines
673 B
Python
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
|