CONTENT_CONFIG

This commit is contained in:
shinrei
2025-07-01 16:20:23 +00:00
parent be2e6dc50b
commit cdf01c5fa1
2 changed files with 21 additions and 5 deletions

View File

@@ -1,18 +1,17 @@
import json import json
from google import genai from google import genai
from google.genai.types import GenerateContentConfig, ThinkingConfig from google.genai import types as google_types
from google.genai.types import GenerateContentConfig, ThinkingConfig, SafetySetting
from .structures import InputMessage, OutputMessage from .structures import InputMessage, OutputMessage
from dataclasses import asdict from dataclasses import asdict
from .content_config import CONTENT_CONFIG
class SolarisClient: class SolarisClient:
def __init__(self, api_key: str) -> None: def __init__(self, api_key: str) -> None:
client = genai.Client(api_key=api_key).aio client = genai.Client(api_key=api_key).aio
self.chat = client.chats.create( self.chat = client.chats.create(
model="gemini-2.5-flash", model="gemini-2.5-flash",
config=GenerateContentConfig( config=CONTENT_CONFIG
system_instruction="meow meow meow", # надо где-то промпт хранить, в бд наверное хезе
thinking_config=ThinkingConfig(thinking_budget=0),
),
) )
async def send_messages(self, messages: list[InputMessage]) -> list[OutputMessage]: async def send_messages(self, messages: list[InputMessage]) -> list[OutputMessage]:
data = json.dumps( data = json.dumps(

View File

@@ -0,0 +1,17 @@
# хезе как и куда жто тулить но в мейн класс не хочу
from google.genai import types
from .structures import OutputMessage
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],
safety_settings=[
types.SafetySetting(
category=category,
threshold=types.HarmBlockThreshold.OFF
)
for category in types.HarmBlockThreshold
]
),