This commit is contained in:
shinrei
2025-07-01 16:00:15 +00:00
parent e730008323
commit 80de1eb5f3
3 changed files with 33 additions and 1 deletions

View File

@@ -1,6 +1,8 @@
import json
from google import genai
from google.genai.types import GenerateContentConfig, ThinkingConfig
from .structures import InputMessage, OutputMessage
from typing import List
class SolarisClient:
def __init__(self, api_key: str) -> None:
@@ -12,3 +14,15 @@ class SolarisClient:
thinking_config=ThinkingConfig(thinking_budget=0),
),
)
async def send_messages(self, messages: List[InputMessage]):
data = json.dumps(
[asdict(msg) for msg in messages],
ensure_ascii=True
)
resp = await self.chat.send_message(data)
print(resp.text)
output_messages = [
OutputMessage.fromdict(msg)
for msg in json.loads(resp.text)
]
return output_messages

View File

@@ -0,0 +1,2 @@
from .input_message import InputMessage
from .output_message import OutputMessage

View File

@@ -0,0 +1,16 @@
from pydantic import BaseModel
from typing import Optional
class OutputMessage(BaseModel):
priority: int # удалишь там есличе
text: Optional[str]
reaction: Optional[str]
reply_to: Optional[int]
@classmethod
def fromdict(cls, data: dict):
return cls(
priority = data.get('priority'),
text = data.get('text'),
reaction = data.get('reaction'),
reply_to = data.get('reply_to')
)