feat(solaris): add proper client initialization
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
BOT__TOKEN=
|
BOT__TOKEN=<BOT__TOKEN>
|
||||||
GOOGLE_API_KEY=
|
|
||||||
|
|
||||||
GROUP_ID=
|
GOOGLE__API_KEY=<GOOGLE__API_KEY>
|
||||||
|
|
||||||
DB__HOST=mongodb
|
DB__HOST=mongodb
|
||||||
DB__PORT=27017
|
DB__PORT=27017
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ from aiogram.types import Message
|
|||||||
|
|
||||||
from bot.common import config
|
from bot.common import config
|
||||||
|
|
||||||
|
|
||||||
class Admin(BaseFilter):
|
class Admin(BaseFilter):
|
||||||
def __init__(self, notify: bool = True):
|
def __init__(self, notify: bool = True):
|
||||||
self.notify = notify
|
self.notify = notify
|
||||||
|
|||||||
0
src/bot/modules/solaris/__init__.py
Normal file
0
src/bot/modules/solaris/__init__.py
Normal file
@@ -1,20 +1,14 @@
|
|||||||
import os
|
|
||||||
from google import genai
|
from google import genai
|
||||||
from google.genai.types import GenerateContentConfig, ThinkingConfig
|
from google.genai.types import GenerateContentConfig, ThinkingConfig
|
||||||
|
|
||||||
from dotenv import load_dotenv
|
|
||||||
load_dotenv()
|
|
||||||
|
|
||||||
class SolarisClient:
|
class SolarisClient:
|
||||||
def __init__(self) -> None:
|
def __init__(self, api_key: str) -> None:
|
||||||
client = genai.Client(api_key=os.getenv('GOOGLE_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=GenerateContentConfig(
|
||||||
system_instruction="meow meow meow", # надо где-то промпт хранить, в бд наверное хезе
|
system_instruction="meow meow meow", # надо где-то промпт хранить, в бд наверное хезе
|
||||||
thinking_config=ThinkingConfig(thinking_budget=0)
|
thinking_config=ThinkingConfig(thinking_budget=0),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# мяу
|
|
||||||
@@ -1,3 +1,7 @@
|
|||||||
from dishka import make_async_container
|
from dishka import make_async_container
|
||||||
|
|
||||||
container = make_async_container()
|
from .providers import SolarisClientProvider
|
||||||
|
|
||||||
|
container = make_async_container(
|
||||||
|
SolarisClientProvider(),
|
||||||
|
)
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
from .solaris import SolarisClientProvider
|
||||||
|
|||||||
13
src/dependencies/providers/solaris.py
Normal file
13
src/dependencies/providers/solaris.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
from typing import AsyncIterable
|
||||||
|
|
||||||
|
from dishka import Provider, Scope, provide
|
||||||
|
|
||||||
|
from bot.modules.solaris.client import SolarisClient
|
||||||
|
from utils.env import env
|
||||||
|
|
||||||
|
|
||||||
|
class SolarisClientProvider(Provider):
|
||||||
|
@provide(scope=Scope.APP)
|
||||||
|
async def get_client(self) -> AsyncIterable[SolarisClient]:
|
||||||
|
client = SolarisClient(env.google.api_key.get_secret_value())
|
||||||
|
yield client
|
||||||
@@ -26,10 +26,15 @@ class LogSettings(BaseSettings):
|
|||||||
console_width: int = 150
|
console_width: int = 150
|
||||||
|
|
||||||
|
|
||||||
|
class GoogleSettings(BaseSettings):
|
||||||
|
api_key: SecretStr
|
||||||
|
|
||||||
|
|
||||||
class Settings(BaseSettings):
|
class Settings(BaseSettings):
|
||||||
bot: BotSettings
|
bot: BotSettings
|
||||||
db: DatabaseSettings
|
db: DatabaseSettings
|
||||||
log: LogSettings
|
log: LogSettings
|
||||||
|
google: GoogleSettings
|
||||||
|
|
||||||
model_config = SettingsConfigDict(
|
model_config = SettingsConfigDict(
|
||||||
case_sensitive=False,
|
case_sensitive=False,
|
||||||
|
|||||||
Reference in New Issue
Block a user