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>
This commit is contained in:
21
gitea_bot/gemini_client.py
Normal file
21
gitea_bot/gemini_client.py
Normal file
@@ -0,0 +1,21 @@
|
||||
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
|
||||
Reference in New Issue
Block a user