Files
solaris-guest-bot/src/bot/modules/solaris/agents/respond.py

33 lines
1.0 KiB
Python

import json
from google import genai
from google.genai import chats, types
from utils.config import dconfig
from ..constants import SAFETY_SETTINGS
from ..structures import InputMessage, OutputMessage
from ..tools import RESPOND_TOOLS
class RespondAgent:
def __init__(self, client: genai.client.AsyncClient) -> None:
self.client = client
async def generate_response(
self, system_prompt: str, history: list[types.Content]
) -> list[OutputMessage]:
content = await self.client.models.generate_content(
model=(await dconfig()).models.respond_model,
contents=history,
config=types.GenerateContentConfig(
system_instruction=system_prompt,
thinking_config=types.ThinkingConfig(thinking_budget=0),
response_mime_type="application/json",
response_schema=list[OutputMessage],
# safety_settings=SAFETY_SETTINGS,
tools=RESPOND_TOOLS,
),
)
return content.parsed