fix(solaris): better config constants, fix safety settings

This commit is contained in:
h
2025-07-01 23:18:49 +03:00
parent cec6df9464
commit 2ed7e88fff
2 changed files with 15 additions and 11 deletions

View File

@@ -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)

View File

@@ -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
]
)