feat(bot): developing integration with solaris

This commit is contained in:
h
2025-07-07 01:26:03 +03:00
parent 1b52c7fdca
commit fbccb91630
16 changed files with 145 additions and 21 deletions

View File

@@ -7,28 +7,26 @@ from utils.config import dconfig
from ..constants import SAFETY_SETTINGS
from ..structures import InputMessage, OutputMessage
from ..tools import RESPOND_TOOLS
class RespondAgent:
chat: chats.AsyncChat
def __init__(self, client: genai.client.AsyncClient) -> None:
self.client = client
async def load_chat(self, history: list[types.Content], system_prompt: str):
self.chat = self.client.chats.create(
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,
# safety_settings=SAFETY_SETTINGS,
tools=RESPOND_TOOLS,
),
history=history,
)
async def send_messages(self, messages: list[InputMessage]) -> list[OutputMessage]:
data = json.dumps([msg.model_dump() for msg in messages], ensure_ascii=True)
response = await self.chat.send_message(data)
return response.parsed
return content.parsed