feat(solaris): navalil dobrenko
This commit is contained in:
@@ -1 +1,3 @@
|
||||
pass
|
||||
from .build import BuildAgent
|
||||
from .respond import RespondAgent
|
||||
from .review import ReviewAgent
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import json
|
||||
|
||||
from google import genai
|
||||
|
||||
from .respond import RespondAgent
|
||||
from .review import ReviewAgent
|
||||
|
||||
|
||||
class BuildAgent:
|
||||
def __init__(self, client: genai.client.AsyncClient) -> None:
|
||||
self.client = client
|
||||
|
||||
async def build(self, some_data) -> tuple[ReviewAgent, RespondAgent]:
|
||||
|
||||
# TODO user data parsing via thinking model
|
||||
|
||||
# заглушка
|
||||
review_prompt = "our_prompt" + "meow"
|
||||
respond_prompt = "our_prompt" + "bark"
|
||||
return (
|
||||
ReviewAgent(client=self.client, prompt=review_prompt),
|
||||
RespondAgent(client=self.client, prompt=respond_prompt),
|
||||
)
|
||||
|
||||
@@ -6,12 +6,13 @@ from google import genai
|
||||
from ..content_configs import generate_respond_config
|
||||
from ..structures import InputMessage, OutputMessage
|
||||
|
||||
RESPOND_MODEL = "gemini-2.5-flash"
|
||||
|
||||
|
||||
class RespondAgent:
|
||||
def __init__(self, api_key: str) -> None:
|
||||
client = genai.Client(api_key=api_key).aio
|
||||
def __init__(self, client: genai.client.AsyncClient, prompt: str) -> None:
|
||||
self.chat = client.chats.create(
|
||||
model="gemini-2.5-flash", config=generate_respond_config(prompt="im gay")
|
||||
model=RESPOND_MODEL, config=generate_respond_config(prompt=prompt)
|
||||
)
|
||||
|
||||
async def send_messages(self, messages: list[InputMessage]) -> list[OutputMessage]:
|
||||
|
||||
@@ -5,16 +5,17 @@ from google import genai
|
||||
from ..content_configs import generate_review_config
|
||||
from ..structures import InputMessage
|
||||
|
||||
REVIEW_MODEL = ("gemini-2.5-flash-lite-preview-06-17",) # надо будет гемму
|
||||
|
||||
|
||||
class ReviewAgent:
|
||||
def __init__(self, api_key: str) -> None:
|
||||
self.client = genai.Client(api_key=api_key).aio
|
||||
def __init__(self, client: genai.client.AsyncClient, prompt: str) -> None:
|
||||
self.client = client
|
||||
self.content_config = generate_review_config(prompt=prompt)
|
||||
|
||||
async def review(self, messages: list[InputMessage]) -> list[InputMessage]:
|
||||
data = json.dumps([msg.model_dump() for msg in messages], ensure_ascii=True)
|
||||
response = await self.client.models.generate_content(
|
||||
model="gemini-2.5-flash-lite-preview-06-17", # надо будет гемму
|
||||
contents=data,
|
||||
config=generate_review_config(prompt="fortnite balls"),
|
||||
model=REVIEW_MODEL, contents=data, config=self.content_config
|
||||
)
|
||||
return [msg for msg in messages if msg.message_id in response.parsed]
|
||||
|
||||
@@ -4,18 +4,19 @@ from google import genai
|
||||
from google.genai import types
|
||||
from pydub import AudioSegment
|
||||
|
||||
from ..content_configs import TTS_CONTENT_CONFIG
|
||||
from ..content_configs import generate_tts_config
|
||||
|
||||
TTS_MODEL = "gemini-2.5-flash-preview-tts"
|
||||
|
||||
|
||||
class TTSAgent:
|
||||
def __init__(self, api_key: str) -> None:
|
||||
self.client = genai.Client(api_key=api_key).aio
|
||||
def __init__(self, client: genai.client.AsyncClient) -> None:
|
||||
self.client = client
|
||||
self.content_config = generate_tts_config()
|
||||
|
||||
async def generate(self, text: str):
|
||||
response = await self.client.models.generate_content(
|
||||
model="gemini-2.5-flash-preview-tts",
|
||||
contents=text,
|
||||
config=TTS_CONTENT_CONFIG,
|
||||
model=TTS_MODEL, contents=text, config=self.content_config
|
||||
)
|
||||
data = response.candidates[0].content.parts[0].inline_data.data
|
||||
pcm_io = io.BytesIO(data)
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import json
|
||||
from dataclasses import asdict
|
||||
|
||||
from google import genai
|
||||
|
||||
from .structures import InputMessage, OutputMessage
|
||||
from .agents import BuildAgent
|
||||
|
||||
|
||||
class SolarisClient:
|
||||
def __init__(self, api_key: str) -> None:
|
||||
client = genai.Client(api_key=api_key).aio
|
||||
self.builder = BuildAgent(client=client)
|
||||
|
||||
async def parse_user_data(self, some_data_idk):
|
||||
self.reviewer, self.responder = await self.builder.build(
|
||||
some_data_idk
|
||||
) # zaglushka
|
||||
|
||||
Reference in New Issue
Block a user