fix(solaris): better config constants, fix safety settings
This commit is contained in:
@@ -2,7 +2,7 @@ import json
|
|||||||
from google import genai
|
from google import genai
|
||||||
from .structures import InputMessage, OutputMessage
|
from .structures import InputMessage, OutputMessage
|
||||||
from dataclasses import asdict
|
from dataclasses import asdict
|
||||||
from .content_configs import MAIN_CONTENT_CONFIG
|
from .content_configs import MAIN_CONTENT_CONFIG, MESSAGE_CONTENT_CONFIG
|
||||||
|
|
||||||
class SolarisClient:
|
class SolarisClient:
|
||||||
def __init__(self, api_key: str) -> None:
|
def __init__(self, api_key: str) -> None:
|
||||||
@@ -19,10 +19,7 @@ class SolarisClient:
|
|||||||
)
|
)
|
||||||
resp = await self.chat.send_message(
|
resp = await self.chat.send_message(
|
||||||
data,
|
data,
|
||||||
config = {
|
config=MESSAGE_CONTENT_CONFIG
|
||||||
"response_mime_type": "application/json",
|
|
||||||
"response_schema": list[OutputMessage],
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
output_messages = [
|
output_messages = [
|
||||||
OutputMessage.fromdict(msg)
|
OutputMessage.fromdict(msg)
|
||||||
|
|||||||
@@ -1,23 +1,30 @@
|
|||||||
# хезе как и куда жто тулить но в мейн класс не хочу
|
from google.genai import types
|
||||||
from google.genai import types
|
|
||||||
from .structures import OutputMessage
|
from .structures import OutputMessage
|
||||||
|
|
||||||
|
|
||||||
MAIN_CONTENT_CONFIG = types.GenerateContentConfig(
|
MAIN_CONTENT_CONFIG = types.GenerateContentConfig(
|
||||||
system_instruction="meow meow meow", # надо где-то промпт хранить, в бд наверное хезе
|
system_instruction="meow meow meow", # надо где-то промпт хранить, в бд наверное хезе
|
||||||
thinking_config=types.ThinkingConfig(thinking_budget=0),
|
thinking_config=types.ThinkingConfig(thinking_budget=0),
|
||||||
response_mime_type="application/json",
|
response_mime_type="application/json",
|
||||||
response_json_schema=list[OutputMessage],
|
response_schema=list[OutputMessage], # ты уверен что там json надо? мне просто каж что судя по всему вот эта нам
|
||||||
safety_settings=[
|
safety_settings=[
|
||||||
types.SafetySetting(
|
types.SafetySetting(
|
||||||
category=category,
|
category=category,
|
||||||
threshold=types.HarmBlockThreshold.OFF
|
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(
|
TTS_CONTENT_CONFIG = types.GenerateContentConfig(
|
||||||
response_modalities=["AUDIO"],
|
response_modalities=[types.Modality.AUDIO],
|
||||||
speech_config=types.SpeechConfig(
|
speech_config=types.SpeechConfig(
|
||||||
voice_config=types.VoiceConfig(
|
voice_config=types.VoiceConfig(
|
||||||
prebuilt_voice_config=types.PrebuiltVoiceConfig(
|
prebuilt_voice_config=types.PrebuiltVoiceConfig(
|
||||||
@@ -30,6 +37,6 @@ TTS_CONTENT_CONFIG = types.GenerateContentConfig(
|
|||||||
category=category,
|
category=category,
|
||||||
threshold=types.HarmBlockThreshold.OFF
|
threshold=types.HarmBlockThreshold.OFF
|
||||||
)
|
)
|
||||||
for category in types.HarmBlockThreshold
|
for category in types.HarmCategory
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user