From 2ed7e88fffd738f582fef2b5e5d9663d882fbe26 Mon Sep 17 00:00:00 2001 From: h Date: Tue, 1 Jul 2025 23:18:49 +0300 Subject: [PATCH] fix(solaris): better config constants, fix safety settings --- src/bot/modules/solaris/client.py | 7 ++----- src/bot/modules/solaris/content_configs.py | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/bot/modules/solaris/client.py b/src/bot/modules/solaris/client.py index c587c73..385dffc 100644 --- a/src/bot/modules/solaris/client.py +++ b/src/bot/modules/solaris/client.py @@ -2,7 +2,7 @@ import json from google import genai from .structures import InputMessage, OutputMessage from dataclasses import asdict -from .content_configs import MAIN_CONTENT_CONFIG +from .content_configs import MAIN_CONTENT_CONFIG, MESSAGE_CONTENT_CONFIG class SolarisClient: def __init__(self, api_key: str) -> None: @@ -19,10 +19,7 @@ class SolarisClient: ) resp = await self.chat.send_message( data, - config = { - "response_mime_type": "application/json", - "response_schema": list[OutputMessage], - } + config=MESSAGE_CONTENT_CONFIG ) output_messages = [ OutputMessage.fromdict(msg) diff --git a/src/bot/modules/solaris/content_configs.py b/src/bot/modules/solaris/content_configs.py index 7a0e236..a66836f 100644 --- a/src/bot/modules/solaris/content_configs.py +++ b/src/bot/modules/solaris/content_configs.py @@ -1,23 +1,30 @@ -# хезе как и куда жто тулить но в мейн класс не хочу -from google.genai import types +from google.genai import types from .structures import OutputMessage + MAIN_CONTENT_CONFIG = types.GenerateContentConfig( system_instruction="meow meow meow", # надо где-то промпт хранить, в бд наверное хезе thinking_config=types.ThinkingConfig(thinking_budget=0), response_mime_type="application/json", - response_json_schema=list[OutputMessage], + response_schema=list[OutputMessage], # ты уверен что там json надо? мне просто каж что судя по всему вот эта нам safety_settings=[ types.SafetySetting( category=category, threshold=types.HarmBlockThreshold.OFF ) - for category in types.HarmBlockThreshold + for category in types.HarmCategory ] ) + +MESSAGE_CONTENT_CONFIG = types.GenerateContentConfig( + response_mime_type="application/json", # возможно можно скипнуть это если мы используем response_schema, надо проверить + response_schema=list[OutputMessage], +) + + TTS_CONTENT_CONFIG = types.GenerateContentConfig( - response_modalities=["AUDIO"], + response_modalities=[types.Modality.AUDIO], speech_config=types.SpeechConfig( voice_config=types.VoiceConfig( prebuilt_voice_config=types.PrebuiltVoiceConfig( @@ -30,6 +37,6 @@ TTS_CONTENT_CONFIG = types.GenerateContentConfig( category=category, threshold=types.HarmBlockThreshold.OFF ) - for category in types.HarmBlockThreshold + for category in types.HarmCategory ] )