From 6d0376e09ebea028fe9950c5794358c104c0d2c2 Mon Sep 17 00:00:00 2001 From: jsdio Date: Sun, 15 Oct 2023 23:15:39 +0300 Subject: [PATCH 1/3] feat: [#60] review fix --- .env.example | 51 +++++++++++++++++++ README.md | 7 +-- docker-compose.yml | 20 ++++---- src/assistant/Dockerfile | 5 ++ .../inline.py => assistant/data/.gitkeep} | 0 src/assistant/docker-compose.dev.yml | 7 +-- src/assistant/docker-compose.tests.yml | 1 - src/assistant/docker-compose.yml | 1 - src/assistant/entrypoint.sh | 4 +- .../agent/repositories/openai_functions.py | 5 +- .../api/v1/handlers/voice_responce_handler.py | 1 - src/assistant/lib/app/app.py | 4 +- src/assistant/lib/app/settings.py | 1 + .../lib/app/split_settings/__init__.py | 2 + src/assistant/lib/app/split_settings/agent.py | 14 +++++ src/bot_aiogram/tgbot/keyboards/reply.py | 0 src/bot_aiogram/tgbot/misc/states.py | 0 src/template/Dockerfile | 4 +- src/template/entrypoint.sh | 2 - 19 files changed, 98 insertions(+), 31 deletions(-) create mode 100644 .env.example rename src/{bot_aiogram/tgbot/keyboards/inline.py => assistant/data/.gitkeep} (100%) create mode 100644 src/assistant/lib/app/split_settings/agent.py delete mode 100644 src/bot_aiogram/tgbot/keyboards/reply.py delete mode 100644 src/bot_aiogram/tgbot/misc/states.py diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..77aa7e2 --- /dev/null +++ b/.env.example @@ -0,0 +1,51 @@ +# API +POSTGRES_DRIVER=postgresql+asyncpg +POSTGRES_HOST=postgres +POSTGRES_PORT=5432 +POSTGRES_USER=app +POSTGRES_PASSWORD=123qwe +POSTGRES_DB_NAME=movies_database + +NGINX_PORT=80 + +API_HOST=0.0.0.0 +API_PORT=8000 +API_PROTOCOL=http +API_URL=api + +JWT_SECRET_KEY=v9LctjUWwol4XbvczPiLFMDtZ8aal7mm +JWT_ALGORITHM=HS256 + +APP_RELOAD=True + +VOICE_AVAILABLE_FORMATS=mp3,ogg,wav,oga +VOICE_MAX_INPUT_SIZE=5120 +VOICE_MAX_INPUT_SECONDS=30 + +OPENAI_API_KEY=sk-123456789 +OPENAI_STT_MODEL=whisper-1 + +PROXY_HOST=213.166.72.28 +PROXY_PORT=9185 +PROXY_USER=RUnj7n +PROXY_PASSWORD=GPTWgk +PROXY_ENABLE=True + +TTS_YANDEX_API_KEY=SfdSDFSDFSDF +TTS_YANDEX_AUDIO_FORMAT=oggopus +TTS_YANDEX_SAMPLE_RATE_HERTZ=48000 + +TTS_ELEVEN_LABS_API_KEY=SDFSFsdfsdf +TTS_ELEVEN_LABS_DEFAULT_VOICE_ID=EXAVITQu4vr4xnSDxMaL + + +# TGBOT +BOT_CONTAINER_NAME=bot_container_name +BOT_IMAGE_NAME=botimage_name +BOT_NAME=mybotname +BOT_TOKEN=1234567890:DSFsdfsdfsdfSDf +BOT_ADMINS=1234567890 + + +REDIS_HOST=redis +REDIS_PORT=6379 diff --git a/README.md b/README.md index 44bf425..0c239df 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ 1. Скачать [файл базы данных](https://disk.yandex.ru/d/ZAKDDg8lP9DHBQ) с `embeddings` и поместить её по пути `src/assistant/data/dump.sql`. -2. В директории `src/assistant` файл `.env.example` переименовать в `.env` и заполнить переменные окружения. +2. В файл `.env.example` переименовать в `.env` и заполнить переменные окружения. Пример заполнения переменных окружения: ``` @@ -68,12 +68,7 @@ TTS_YANDEX_SAMPLE_RATE_HERTZ=48000 # Частота дискретизации TTS_ELEVEN_LABS_API_KEY=1234567890 # API-ключ ElevenLabs TTS_ELEVEN_LABS_DEFAULT_VOICE_ID=EXAVITQu4vr4xnSDxMaL # ID голоса по умолчанию -``` -3. В директории `src/bot_aiogram` файл `.env.example` переименовать в `.env` и заполнить переменные окружения. - Пример заполнения переменных окружения: - -``` BOT_CONTAINER_NAME=bot_container_name # Название контейнера BOT_IMAGE_NAME=botimage_name # Название образа BOT_NAME=mybotname # Название бота diff --git a/docker-compose.yml b/docker-compose.yml index ed9d75a..61bf936 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,25 +7,24 @@ services: environment: POSTGRES_USER: ${POSTGRES_USER} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} - POSTGRES_DB: ${POSTGRES_NAME} + POSTGRES_DB: ${POSTGRES_DB_NAME} env_file: - - ./src/assistant/.env + - .env expose: - "${POSTGRES_PORT}" volumes: - - - ./src/assistant/dump.sql:/docker-entrypoint-initdb.d/dump.sql:ro + - ./src/assistant/data/dump.sql:/docker-entrypoint-initdb.d/dump.sql:ro networks: - backend_network api: build: - context: . + context: ./src/assistant/ container_name: api image: fastapi_app restart: always - entrypoint: ["/opt/app/entrypoint.sh"] env_file: - - ./src/assistant/.env + - .env expose: - "${API_PORT}" depends_on: @@ -52,20 +51,21 @@ services: image: "${BOT_IMAGE_NAME:-tg_bot-image}" container_name: "${BOT_CONTAINER_NAME:-tg_bot-container}" build: - context: ./src/bot_aiogram/Dockerfile + context: ./src/bot_aiogram/ restart: always env_file: - - ./src/bot_aiogram/.env + - .env networks: - backend_network - api_network - depends_on: api + depends_on: + - api redis: image: redis:7.0.11 restart: always env_file: - - ./src/bot_aiogram/.env + - .env ports: - "127.0.0.1:${REDIS_PORT}:${REDIS_PORT}" command: redis-server --bind 0.0.0.0 --appendonly yes diff --git a/src/assistant/Dockerfile b/src/assistant/Dockerfile index 63a6bd7..412059b 100644 --- a/src/assistant/Dockerfile +++ b/src/assistant/Dockerfile @@ -18,6 +18,11 @@ RUN pip install poetry \ COPY bin /opt/app/bin COPY lib /opt/app/lib + +COPY alembic /opt/app/alembic +COPY alembic.ini /opt/app/alembic.ini + COPY entrypoint.sh /opt/app/entrypoint.sh RUN chmod +x /opt/app/entrypoint.sh +ENTRYPOINT ["/opt/app/entrypoint.sh"] diff --git a/src/bot_aiogram/tgbot/keyboards/inline.py b/src/assistant/data/.gitkeep similarity index 100% rename from src/bot_aiogram/tgbot/keyboards/inline.py rename to src/assistant/data/.gitkeep diff --git a/src/assistant/docker-compose.dev.yml b/src/assistant/docker-compose.dev.yml index 4305528..00a0e92 100644 --- a/src/assistant/docker-compose.dev.yml +++ b/src/assistant/docker-compose.dev.yml @@ -2,7 +2,7 @@ version: "3" services: postgres: - image: postgres:15.2 + image: ankane/pgvector:v0.5.0 restart: always environment: POSTGRES_USER: ${POSTGRES_USER} @@ -13,6 +13,7 @@ services: ports: - "${POSTGRES_PORT}:${POSTGRES_PORT}" volumes: + - ./dump.sql:/docker-entrypoint-initdb.d/dump.sql:ro - postgres_data:/var/lib/postgresql/data/ networks: - backend_network @@ -23,7 +24,6 @@ services: container_name: fastapi_app image: fastapi_app restart: always - entrypoint: ["/opt/app/entrypoint.sh"] env_file: - .env ports: @@ -48,9 +48,6 @@ services: networks: - api_network -volumes: - postgres_data: - networks: api_network: driver: bridge diff --git a/src/assistant/docker-compose.tests.yml b/src/assistant/docker-compose.tests.yml index 0309e55..1bc976e 100644 --- a/src/assistant/docker-compose.tests.yml +++ b/src/assistant/docker-compose.tests.yml @@ -23,7 +23,6 @@ services: container_name: api image: fastapi_app restart: always - entrypoint: ["/opt/app/entrypoint.sh"] env_file: - .env expose: diff --git a/src/assistant/docker-compose.yml b/src/assistant/docker-compose.yml index d46c390..6ee3e69 100644 --- a/src/assistant/docker-compose.yml +++ b/src/assistant/docker-compose.yml @@ -23,7 +23,6 @@ services: container_name: api image: fastapi_app restart: always - entrypoint: ["/opt/app/entrypoint.sh"] env_file: - .env expose: diff --git a/src/assistant/entrypoint.sh b/src/assistant/entrypoint.sh index e48a4fb..1160f77 100644 --- a/src/assistant/entrypoint.sh +++ b/src/assistant/entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/bash -while ! nc -z postgres 5432; do sleep 1; done; +while ! nc -z $POSTGRES_HOST $POSTGRES_PORT; do sleep 1; done; -alembic upgrade head +poetry run alembic upgrade head exec .venv/bin/python -m bin diff --git a/src/assistant/lib/agent/repositories/openai_functions.py b/src/assistant/lib/agent/repositories/openai_functions.py index c487a77..843a093 100644 --- a/src/assistant/lib/agent/repositories/openai_functions.py +++ b/src/assistant/lib/agent/repositories/openai_functions.py @@ -7,6 +7,7 @@ import sqlalchemy.ext.asyncio as sa_asyncio import lib.agent.repositories as repositories import lib.models as models import lib.orm_models as orm_models +import lib.app.settings as app_settings class OpenAIFunctions: @@ -16,10 +17,12 @@ class OpenAIFunctions: self, repository: repositories.EmbeddingRepository, pg_async_session: sa_asyncio.async_sessionmaker[sa_asyncio.AsyncSession], + settings: app_settings.Settings, ) -> None: self.logger = logging.getLogger(__name__) self.pg_async_session = pg_async_session self.repository = repository + self.settings = settings async def get_movie_by_description(self, description: str) -> list[models.Movie] | None: """Use this function to find data about a movie by movie's description.""" @@ -32,7 +35,7 @@ class OpenAIFunctions: stmt = ( sa.select(orm_models.FilmWork) .order_by(orm_models.FilmWork.embeddings.cosine_distance(embedded_description.root)) - .limit(5) + .limit(self.settings.agent.embeddings_limit) ) response = await session.execute(stmt) neighbours = response.scalars() diff --git a/src/assistant/lib/api/v1/handlers/voice_responce_handler.py b/src/assistant/lib/api/v1/handlers/voice_responce_handler.py index c8c2121..0efac75 100644 --- a/src/assistant/lib/api/v1/handlers/voice_responce_handler.py +++ b/src/assistant/lib/api/v1/handlers/voice_responce_handler.py @@ -47,4 +47,3 @@ class VoiceResponseHandler: ) ) return fastapi.responses.StreamingResponse(io.BytesIO(response.audio_content), media_type="audio/ogg") - # return fastapi.responses.StreamingResponse(io.BytesIO(voice), media_type="audio/ogg") diff --git a/src/assistant/lib/app/app.py b/src/assistant/lib/app/app.py index 1310c2b..94ec467 100644 --- a/src/assistant/lib/app/app.py +++ b/src/assistant/lib/app/app.py @@ -97,7 +97,9 @@ class Application: ) embedding_repository = agent_repositories.EmbeddingRepository(settings=settings) agent_tools = agent_functions.OpenAIFunctions( - repository=embedding_repository, pg_async_session=postgres_client.get_async_session() + repository=embedding_repository, + pg_async_session=postgres_client.get_async_session(), + settings=settings ) tts_yandex_repository = tts.TTSYandexRepository( tts_settings=app_split_settings.TTSYandexSettings(), diff --git a/src/assistant/lib/app/settings.py b/src/assistant/lib/app/settings.py index b17c92f..341d8a1 100644 --- a/src/assistant/lib/app/settings.py +++ b/src/assistant/lib/app/settings.py @@ -4,6 +4,7 @@ import lib.app.split_settings as app_split_settings class Settings(pydantic_settings.BaseSettings): + agent: app_split_settings.AgentSettings = app_split_settings.AgentSettings() api: app_split_settings.ApiSettings = app_split_settings.ApiSettings() app: app_split_settings.AppSettings = app_split_settings.AppSettings() postgres: app_split_settings.PostgresSettings = app_split_settings.PostgresSettings() diff --git a/src/assistant/lib/app/split_settings/__init__.py b/src/assistant/lib/app/split_settings/__init__.py index b7b24df..069d477 100644 --- a/src/assistant/lib/app/split_settings/__init__.py +++ b/src/assistant/lib/app/split_settings/__init__.py @@ -1,3 +1,4 @@ +from .agent import * from .api import * from .app import * from .logger import * @@ -9,6 +10,7 @@ from .tts import * from .voice import * __all__ = [ + "AgentSettings", "ApiSettings", "AppSettings", "LoggingSettings", diff --git a/src/assistant/lib/app/split_settings/agent.py b/src/assistant/lib/app/split_settings/agent.py new file mode 100644 index 0000000..87ca6b3 --- /dev/null +++ b/src/assistant/lib/app/split_settings/agent.py @@ -0,0 +1,14 @@ +import pydantic_settings + +import lib.app.split_settings.utils as app_split_settings_utils + + +class AgentSettings(pydantic_settings.BaseSettings): + model_config = pydantic_settings.SettingsConfigDict( + env_file=app_split_settings_utils.ENV_PATH, + env_prefix="AGENT_", + env_file_encoding="utf-8", + extra="ignore", + ) + + embeddings_limit: int = 5 diff --git a/src/bot_aiogram/tgbot/keyboards/reply.py b/src/bot_aiogram/tgbot/keyboards/reply.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/bot_aiogram/tgbot/misc/states.py b/src/bot_aiogram/tgbot/misc/states.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/template/Dockerfile b/src/template/Dockerfile index 202c1a7..38363b3 100644 --- a/src/template/Dockerfile +++ b/src/template/Dockerfile @@ -13,7 +13,7 @@ COPY poetry.toml /opt/app/poetry.toml WORKDIR /opt/app -RUN pip install poetry \ +RUN pip install poetry \ && poetry install --no-dev COPY bin /opt/app/bin @@ -21,3 +21,5 @@ COPY lib /opt/app/lib COPY entrypoint.sh /opt/app/entrypoint.sh RUN chmod +x /opt/app/entrypoint.sh + +CMD [".venv/bin/python", "-m", "bin"] diff --git a/src/template/entrypoint.sh b/src/template/entrypoint.sh index fe288b7..615cd9e 100644 --- a/src/template/entrypoint.sh +++ b/src/template/entrypoint.sh @@ -1,5 +1,3 @@ #!/bin/bash while ! nc -z postgres 5432; do sleep 1; done; - -exec .venv/bin/python -m bin \ No newline at end of file From 7195829089f50c5e4b76e5a985a865a58ff0965d Mon Sep 17 00:00:00 2001 From: jsdio Date: Sun, 15 Oct 2023 23:27:35 +0300 Subject: [PATCH 2/3] feat: [#60] lint-fix --- .../2023-10-12_3d448c6327cd_init_commit.py | 100 +----------------- .../repositories/embedding_repository.py | 2 +- .../agent/repositories/openai_functions.py | 4 +- src/assistant/lib/agent/services.py | 15 +-- src/assistant/lib/app/app.py | 4 +- src/assistant/lib/models/__init__.py | 9 +- src/assistant/poetry.lock | 28 +++-- 7 files changed, 37 insertions(+), 125 deletions(-) diff --git a/src/assistant/alembic/versions/2023-10-12_3d448c6327cd_init_commit.py b/src/assistant/alembic/versions/2023-10-12_3d448c6327cd_init_commit.py index d40648e..ebae8fa 100644 --- a/src/assistant/alembic/versions/2023-10-12_3d448c6327cd_init_commit.py +++ b/src/assistant/alembic/versions/2023-10-12_3d448c6327cd_init_commit.py @@ -1,14 +1,13 @@ """init commit Revision ID: 3d448c6327cd -Revises: +Revises: Create Date: 2023-10-12 00:01:42.248941 """ from typing import Sequence, Union import sqlalchemy as sa -from sqlalchemy.dialects import postgresql from alembic import op @@ -37,102 +36,5 @@ def upgrade() -> None: def downgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### - op.add_column("person_film_work", sa.Column("id", sa.UUID(), autoincrement=False, nullable=False)) - op.drop_constraint(None, "person_film_work", type_="foreignkey") - op.drop_constraint(None, "person_film_work", type_="foreignkey") - op.alter_column( - "person_film_work", "role", existing_type=sa.String(length=50), type_=sa.TEXT(), existing_nullable=False - ) - op.alter_column("person", "modified", existing_type=postgresql.TIMESTAMP(timezone=True), nullable=True) - op.alter_column("person", "created", existing_type=postgresql.TIMESTAMP(timezone=True), nullable=True) - op.alter_column("person", "full_name", existing_type=sa.String(), type_=sa.TEXT(), existing_nullable=False) - op.drop_constraint(None, "genre_film_work", type_="foreignkey") - op.drop_constraint(None, "genre_film_work", type_="foreignkey") - op.alter_column("genre", "modified", existing_type=postgresql.TIMESTAMP(timezone=True), nullable=True) - op.alter_column("genre", "created", existing_type=postgresql.TIMESTAMP(timezone=True), nullable=True) - op.alter_column("genre", "description", existing_type=sa.String(), type_=sa.TEXT(), existing_nullable=True) - op.alter_column("genre", "name", existing_type=sa.String(), type_=sa.TEXT(), existing_nullable=False) - op.alter_column("film_work", "modified", existing_type=postgresql.TIMESTAMP(timezone=True), nullable=True) - op.alter_column("film_work", "created", existing_type=postgresql.TIMESTAMP(timezone=True), nullable=True) - op.alter_column("film_work", "type", existing_type=sa.String(), type_=sa.TEXT(), existing_nullable=False) - op.alter_column("film_work", "file_path", existing_type=sa.String(), type_=sa.TEXT(), existing_nullable=True) - op.alter_column("film_work", "creation_date", existing_type=sa.DateTime(), type_=sa.DATE(), existing_nullable=True) - op.alter_column("film_work", "description", existing_type=sa.String(), type_=sa.TEXT(), existing_nullable=True) - op.alter_column("film_work", "title", existing_type=sa.String(), type_=sa.TEXT(), existing_nullable=False) - op.create_table( - "django_migrations", - sa.Column("id", sa.BIGINT(), autoincrement=True, nullable=False), - sa.Column("app", sa.VARCHAR(length=255), autoincrement=False, nullable=False), - sa.Column("name", sa.VARCHAR(length=255), autoincrement=False, nullable=False), - sa.Column("applied", postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=False), - ) - op.create_table( - "django_admin_log", - sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column("action_time", postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=False), - sa.Column("object_id", sa.TEXT(), autoincrement=False, nullable=True), - sa.Column("object_repr", sa.VARCHAR(length=200), autoincrement=False, nullable=False), - sa.Column("action_flag", sa.SMALLINT(), autoincrement=False, nullable=False), - sa.Column("change_message", sa.TEXT(), autoincrement=False, nullable=False), - sa.Column("content_type_id", sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column("user_id", sa.INTEGER(), autoincrement=False, nullable=False), - sa.CheckConstraint("action_flag >= 0", name="django_admin_log_action_flag_check"), - ) - op.create_table( - "django_session", - sa.Column("session_key", sa.VARCHAR(length=40), autoincrement=False, nullable=False), - sa.Column("session_data", sa.TEXT(), autoincrement=False, nullable=False), - sa.Column("expire_date", postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=False), - ) - op.create_table( - "auth_permission", - sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column("name", sa.VARCHAR(length=255), autoincrement=False, nullable=False), - sa.Column("content_type_id", sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column("codename", sa.VARCHAR(length=100), autoincrement=False, nullable=False), - ) - op.create_table( - "django_content_type", - sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column("app_label", sa.VARCHAR(length=100), autoincrement=False, nullable=False), - sa.Column("model", sa.VARCHAR(length=100), autoincrement=False, nullable=False), - ) - op.create_table( - "auth_user", - sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column("password", sa.VARCHAR(length=128), autoincrement=False, nullable=False), - sa.Column("last_login", postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True), - sa.Column("is_superuser", sa.BOOLEAN(), autoincrement=False, nullable=False), - sa.Column("username", sa.VARCHAR(length=150), autoincrement=False, nullable=False), - sa.Column("first_name", sa.VARCHAR(length=150), autoincrement=False, nullable=False), - sa.Column("last_name", sa.VARCHAR(length=150), autoincrement=False, nullable=False), - sa.Column("email", sa.VARCHAR(length=254), autoincrement=False, nullable=False), - sa.Column("is_staff", sa.BOOLEAN(), autoincrement=False, nullable=False), - sa.Column("is_active", sa.BOOLEAN(), autoincrement=False, nullable=False), - sa.Column("date_joined", postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=False), - ) - op.create_table( - "auth_user_user_permissions", - sa.Column("id", sa.BIGINT(), autoincrement=True, nullable=False), - sa.Column("user_id", sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column("permission_id", sa.INTEGER(), autoincrement=False, nullable=False), - ) - op.create_table( - "auth_group_permissions", - sa.Column("id", sa.BIGINT(), autoincrement=True, nullable=False), - sa.Column("group_id", sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column("permission_id", sa.INTEGER(), autoincrement=False, nullable=False), - ) - op.create_table( - "auth_user_groups", - sa.Column("id", sa.BIGINT(), autoincrement=True, nullable=False), - sa.Column("user_id", sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column("group_id", sa.INTEGER(), autoincrement=False, nullable=False), - ) - op.create_table( - "auth_group", - sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column("name", sa.VARCHAR(length=150), autoincrement=False, nullable=False), - ) op.drop_table("chat_history", schema="content") # ### end Alembic commands ### diff --git a/src/assistant/lib/agent/repositories/embedding_repository.py b/src/assistant/lib/agent/repositories/embedding_repository.py index dee03d3..a7b52fc 100644 --- a/src/assistant/lib/agent/repositories/embedding_repository.py +++ b/src/assistant/lib/agent/repositories/embedding_repository.py @@ -33,7 +33,7 @@ class EmbeddingRepository: response: dict[str, typing.Any] = await openai.Embedding.acreate( input=text, model=model, - ) # type: ignore[reportGeneralTypeIssues] + ) # type: ignore[reportGeneralTypeIssues] return models.Embedding(root=response["data"][0]["embedding"]) except openai.error.OpenAIError: diff --git a/src/assistant/lib/agent/repositories/openai_functions.py b/src/assistant/lib/agent/repositories/openai_functions.py index 843a093..2835e18 100644 --- a/src/assistant/lib/agent/repositories/openai_functions.py +++ b/src/assistant/lib/agent/repositories/openai_functions.py @@ -5,9 +5,9 @@ import sqlalchemy.exc import sqlalchemy.ext.asyncio as sa_asyncio import lib.agent.repositories as repositories +import lib.app.settings as app_settings import lib.models as models import lib.orm_models as orm_models -import lib.app.settings as app_settings class OpenAIFunctions: @@ -34,7 +34,7 @@ class OpenAIFunctions: result: list[models.Movie] = [] stmt = ( sa.select(orm_models.FilmWork) - .order_by(orm_models.FilmWork.embeddings.cosine_distance(embedded_description.root)) + .order_by(orm_models.FilmWork.embeddings.cosine_distance(embedded_description.root)) # type: ignore[reportOptionalMemberAccess] .limit(self.settings.agent.embeddings_limit) ) response = await session.execute(stmt) diff --git a/src/assistant/lib/agent/services.py b/src/assistant/lib/agent/services.py index e4ef8ff..fe42952 100644 --- a/src/assistant/lib/agent/services.py +++ b/src/assistant/lib/agent/services.py @@ -49,7 +49,7 @@ class AgentService: template = """ 1. You are movie expert with a vast knowledge base about movies and their related aspects. - 2. Use functions to get an additional data about movies. + 2. Use functions to get an additional data about movies. 3. Translate each inbound request into English language. Before calling any functions. 4. Answer always in Russian language. 5. Be very concise. You answer must be no longer than 100 words.""" @@ -77,12 +77,13 @@ class AgentService: # Load chat history from database request_chat_history = models.RequestChatHistory(session_id=session_id) chat_history = await self.chat_repository.get_messages_by_sid(request_chat_history) - for entry in chat_history: - if entry.role == "user": - memory.chat_memory.add_user_message(entry.content) - elif entry.role == "agent": - memory.chat_memory.add_ai_message(entry.content) - + if chat_history: + for entry in chat_history: + if entry.role == "user": + memory.chat_memory.add_user_message(entry.content) + elif entry.role == "agent": + memory.chat_memory.add_ai_message(entry.content) + agent = langchain.agents.OpenAIFunctionsAgent(llm=llm, tools=tools, prompt=prompt) agent_executor: langchain.agents.AgentExecutor = langchain.agents.AgentExecutor.from_agent_and_tools( tools=tools, diff --git a/src/assistant/lib/app/app.py b/src/assistant/lib/app/app.py index 94ec467..434a6dc 100644 --- a/src/assistant/lib/app/app.py +++ b/src/assistant/lib/app/app.py @@ -97,9 +97,7 @@ class Application: ) embedding_repository = agent_repositories.EmbeddingRepository(settings=settings) agent_tools = agent_functions.OpenAIFunctions( - repository=embedding_repository, - pg_async_session=postgres_client.get_async_session(), - settings=settings + repository=embedding_repository, pg_async_session=postgres_client.get_async_session(), settings=settings ) tts_yandex_repository = tts.TTSYandexRepository( tts_settings=app_split_settings.TTSYandexSettings(), diff --git a/src/assistant/lib/models/__init__.py b/src/assistant/lib/models/__init__.py index bbadc3a..6f70059 100644 --- a/src/assistant/lib/models/__init__.py +++ b/src/assistant/lib/models/__init__.py @@ -1,11 +1,10 @@ from .agent import * -from .chat_history import Message, RequestChatHistory, RequestChatMessage, RequestLastSessionId -from .embedding import Embedding -from .movies import Movie -from .token import Token +from .chat_history import * +from .embedding import * +from .movies import * +from .token import * from .tts import * -# __all__ = ["Embedding", "Message", "Movie", "RequestChatHistory", "RequestChatMessage", "RequestLastSessionId", "Token"] __all__ = [ "AVAILABLE_MODELS_TYPE", "AgentCreateRequestModel", diff --git a/src/assistant/poetry.lock b/src/assistant/poetry.lock index 875acce..521fbdf 100644 --- a/src/assistant/poetry.lock +++ b/src/assistant/poetry.lock @@ -960,6 +960,16 @@ files = [ {file = "MarkupSafe-2.1.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:5bbe06f8eeafd38e5d0a4894ffec89378b6c6a625ff57e3028921f8ff59318ac"}, {file = "MarkupSafe-2.1.3-cp311-cp311-win32.whl", hash = "sha256:dd15ff04ffd7e05ffcb7fe79f1b98041b8ea30ae9234aed2a9168b5797c3effb"}, {file = "MarkupSafe-2.1.3-cp311-cp311-win_amd64.whl", hash = "sha256:134da1eca9ec0ae528110ccc9e48041e0828d79f24121a1a146161103c76e686"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:f698de3fd0c4e6972b92290a45bd9b1536bffe8c6759c62471efaa8acb4c37bc"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:aa57bd9cf8ae831a362185ee444e15a93ecb2e344c8e52e4d721ea3ab6ef1823"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ffcc3f7c66b5f5b7931a5aa68fc9cecc51e685ef90282f4a82f0f5e9b704ad11"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:47d4f1c5f80fc62fdd7777d0d40a2e9dda0a05883ab11374334f6c4de38adffd"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1f67c7038d560d92149c060157d623c542173016c4babc0c1913cca0564b9939"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:9aad3c1755095ce347e26488214ef77e0485a3c34a50c5a5e2471dff60b9dd9c"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:14ff806850827afd6b07a5f32bd917fb7f45b046ba40c57abdb636674a8b559c"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8f9293864fe09b8149f0cc42ce56e3f0e54de883a9de90cd427f191c346eb2e1"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-win32.whl", hash = "sha256:715d3562f79d540f251b99ebd6d8baa547118974341db04f5ad06d5ea3eb8007"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-win_amd64.whl", hash = "sha256:1b8dd8c3fd14349433c79fa8abeb573a55fc0fdd769133baac1f5e07abf54aeb"}, {file = "MarkupSafe-2.1.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:8e254ae696c88d98da6555f5ace2279cf7cd5b3f52be2b5cf97feafe883b58d2"}, {file = "MarkupSafe-2.1.3-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cb0932dc158471523c9637e807d9bfb93e06a95cbf010f1a38b98623b929ef2b"}, {file = "MarkupSafe-2.1.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9402b03f1a1b4dc4c19845e5c749e3ab82d5078d16a2a4c2cd2df62d57bb0707"}, @@ -1762,6 +1772,7 @@ files = [ {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515"}, + {file = "PyYAML-6.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290"}, {file = "PyYAML-6.0.1-cp310-cp310-win32.whl", hash = "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924"}, {file = "PyYAML-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d"}, {file = "PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007"}, @@ -1769,8 +1780,15 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673"}, + {file = "PyYAML-6.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b"}, {file = "PyYAML-6.0.1-cp311-cp311-win32.whl", hash = "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741"}, {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, + {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, + {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, + {file = "PyYAML-6.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df"}, {file = "PyYAML-6.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c"}, @@ -1787,6 +1805,7 @@ files = [ {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735"}, + {file = "PyYAML-6.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6"}, {file = "PyYAML-6.0.1-cp38-cp38-win32.whl", hash = "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206"}, {file = "PyYAML-6.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62"}, {file = "PyYAML-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8"}, @@ -1794,6 +1813,7 @@ files = [ {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c"}, + {file = "PyYAML-6.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5"}, {file = "PyYAML-6.0.1-cp39-cp39-win32.whl", hash = "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c"}, {file = "PyYAML-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486"}, {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, @@ -1921,9 +1941,7 @@ python-versions = ">=3.7" files = [ {file = "SQLAlchemy-2.0.22-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f146c61ae128ab43ea3a0955de1af7e1633942c2b2b4985ac51cc292daf33222"}, {file = "SQLAlchemy-2.0.22-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:875de9414393e778b655a3d97d60465eb3fae7c919e88b70cc10b40b9f56042d"}, - {file = "SQLAlchemy-2.0.22-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:13790cb42f917c45c9c850b39b9941539ca8ee7917dacf099cc0b569f3d40da7"}, {file = "SQLAlchemy-2.0.22-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e04ab55cf49daf1aeb8c622c54d23fa4bec91cb051a43cc24351ba97e1dd09f5"}, - {file = "SQLAlchemy-2.0.22-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:a42c9fa3abcda0dcfad053e49c4f752eef71ecd8c155221e18b99d4224621176"}, {file = "SQLAlchemy-2.0.22-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:14cd3bcbb853379fef2cd01e7c64a5d6f1d005406d877ed9509afb7a05ff40a5"}, {file = "SQLAlchemy-2.0.22-cp310-cp310-win32.whl", hash = "sha256:d143c5a9dada696bcfdb96ba2de4a47d5a89168e71d05a076e88a01386872f97"}, {file = "SQLAlchemy-2.0.22-cp310-cp310-win_amd64.whl", hash = "sha256:ccd87c25e4c8559e1b918d46b4fa90b37f459c9b4566f1dfbce0eb8122571547"}, @@ -1944,25 +1962,19 @@ files = [ {file = "SQLAlchemy-2.0.22-cp312-cp312-win32.whl", hash = "sha256:154a32f3c7b00de3d090bc60ec8006a78149e221f1182e3edcf0376016be9396"}, {file = "SQLAlchemy-2.0.22-cp312-cp312-win_amd64.whl", hash = "sha256:129415f89744b05741c6f0b04a84525f37fbabe5dc3774f7edf100e7458c48cd"}, {file = "SQLAlchemy-2.0.22-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:3940677d341f2b685a999bffe7078697b5848a40b5f6952794ffcf3af150c301"}, - {file = "SQLAlchemy-2.0.22-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:55914d45a631b81a8a2cb1a54f03eea265cf1783241ac55396ec6d735be14883"}, {file = "SQLAlchemy-2.0.22-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2096d6b018d242a2bcc9e451618166f860bb0304f590d205173d317b69986c95"}, - {file = "SQLAlchemy-2.0.22-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:19c6986cf2fb4bc8e0e846f97f4135a8e753b57d2aaaa87c50f9acbe606bd1db"}, {file = "SQLAlchemy-2.0.22-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:6ac28bd6888fe3c81fbe97584eb0b96804bd7032d6100b9701255d9441373ec1"}, {file = "SQLAlchemy-2.0.22-cp37-cp37m-win32.whl", hash = "sha256:cb9a758ad973e795267da334a92dd82bb7555cb36a0960dcabcf724d26299db8"}, {file = "SQLAlchemy-2.0.22-cp37-cp37m-win_amd64.whl", hash = "sha256:40b1206a0d923e73aa54f0a6bd61419a96b914f1cd19900b6c8226899d9742ad"}, {file = "SQLAlchemy-2.0.22-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:3aa1472bf44f61dd27987cd051f1c893b7d3b17238bff8c23fceaef4f1133868"}, {file = "SQLAlchemy-2.0.22-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:56a7e2bb639df9263bf6418231bc2a92a773f57886d371ddb7a869a24919face"}, - {file = "SQLAlchemy-2.0.22-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ccca778c0737a773a1ad86b68bda52a71ad5950b25e120b6eb1330f0df54c3d0"}, {file = "SQLAlchemy-2.0.22-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7c6c3e9350f9fb16de5b5e5fbf17b578811a52d71bb784cc5ff71acb7de2a7f9"}, - {file = "SQLAlchemy-2.0.22-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:564e9f9e4e6466273dbfab0e0a2e5fe819eec480c57b53a2cdee8e4fdae3ad5f"}, {file = "SQLAlchemy-2.0.22-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:af66001d7b76a3fab0d5e4c1ec9339ac45748bc4a399cbc2baa48c1980d3c1f4"}, {file = "SQLAlchemy-2.0.22-cp38-cp38-win32.whl", hash = "sha256:9e55dff5ec115316dd7a083cdc1a52de63693695aecf72bc53a8e1468ce429e5"}, {file = "SQLAlchemy-2.0.22-cp38-cp38-win_amd64.whl", hash = "sha256:4e869a8ff7ee7a833b74868a0887e8462445ec462432d8cbeff5e85f475186da"}, {file = "SQLAlchemy-2.0.22-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9886a72c8e6371280cb247c5d32c9c8fa141dc560124348762db8a8b236f8692"}, {file = "SQLAlchemy-2.0.22-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a571bc8ac092a3175a1d994794a8e7a1f2f651e7c744de24a19b4f740fe95034"}, - {file = "SQLAlchemy-2.0.22-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8db5ba8b7da759b727faebc4289a9e6a51edadc7fc32207a30f7c6203a181592"}, {file = "SQLAlchemy-2.0.22-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0b0b3f2686c3f162123adba3cb8b626ed7e9b8433ab528e36ed270b4f70d1cdb"}, - {file = "SQLAlchemy-2.0.22-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:0c1fea8c0abcb070ffe15311853abfda4e55bf7dc1d4889497b3403629f3bf00"}, {file = "SQLAlchemy-2.0.22-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:4bb062784f37b2d75fd9b074c8ec360ad5df71f933f927e9e95c50eb8e05323c"}, {file = "SQLAlchemy-2.0.22-cp39-cp39-win32.whl", hash = "sha256:58a3aba1bfb32ae7af68da3f277ed91d9f57620cf7ce651db96636790a78b736"}, {file = "SQLAlchemy-2.0.22-cp39-cp39-win_amd64.whl", hash = "sha256:92e512a6af769e4725fa5b25981ba790335d42c5977e94ded07db7d641490a85"}, From 5b23ea14976806569a8165b353b70b0dafcc35c2 Mon Sep 17 00:00:00 2001 From: jsdio Date: Sun, 15 Oct 2023 23:31:51 +0300 Subject: [PATCH 3/3] feat: [#60] lint-fix --- src/template/lib/app/split_settings/logger.py | 3 ++- src/template/poetry.lock | 24 +++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/template/lib/app/split_settings/logger.py b/src/template/lib/app/split_settings/logger.py index 696b2c1..f5cd1c4 100644 --- a/src/template/lib/app/split_settings/logger.py +++ b/src/template/lib/app/split_settings/logger.py @@ -1,6 +1,7 @@ -import lib.app.split_settings.utils as app_split_settings_utils import pydantic_settings +import lib.app.split_settings.utils as app_split_settings_utils + class LoggingSettings(pydantic_settings.BaseSettings): model_config = pydantic_settings.SettingsConfigDict( diff --git a/src/template/poetry.lock b/src/template/poetry.lock index 67ce83f..d021944 100644 --- a/src/template/poetry.lock +++ b/src/template/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. [[package]] name = "alembic" @@ -296,6 +296,7 @@ files = [ {file = "greenlet-2.0.2-cp27-cp27m-win32.whl", hash = "sha256:6c3acb79b0bfd4fe733dff8bc62695283b57949ebcca05ae5c129eb606ff2d74"}, {file = "greenlet-2.0.2-cp27-cp27m-win_amd64.whl", hash = "sha256:283737e0da3f08bd637b5ad058507e578dd462db259f7f6e4c5c365ba4ee9343"}, {file = "greenlet-2.0.2-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:d27ec7509b9c18b6d73f2f5ede2622441de812e7b1a80bbd446cb0633bd3d5ae"}, + {file = "greenlet-2.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d967650d3f56af314b72df7089d96cda1083a7fc2da05b375d2bc48c82ab3f3c"}, {file = "greenlet-2.0.2-cp310-cp310-macosx_11_0_x86_64.whl", hash = "sha256:30bcf80dda7f15ac77ba5af2b961bdd9dbc77fd4ac6105cee85b0d0a5fcf74df"}, {file = "greenlet-2.0.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:26fbfce90728d82bc9e6c38ea4d038cba20b7faf8a0ca53a9c07b67318d46088"}, {file = "greenlet-2.0.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9190f09060ea4debddd24665d6804b995a9c122ef5917ab26e1566dcc712ceeb"}, @@ -304,6 +305,7 @@ files = [ {file = "greenlet-2.0.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:76ae285c8104046b3a7f06b42f29c7b73f77683df18c49ab5af7983994c2dd91"}, {file = "greenlet-2.0.2-cp310-cp310-win_amd64.whl", hash = "sha256:2d4686f195e32d36b4d7cf2d166857dbd0ee9f3d20ae349b6bf8afc8485b3645"}, {file = "greenlet-2.0.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:c4302695ad8027363e96311df24ee28978162cdcdd2006476c43970b384a244c"}, + {file = "greenlet-2.0.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:d4606a527e30548153be1a9f155f4e283d109ffba663a15856089fb55f933e47"}, {file = "greenlet-2.0.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c48f54ef8e05f04d6eff74b8233f6063cb1ed960243eacc474ee73a2ea8573ca"}, {file = "greenlet-2.0.2-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a1846f1b999e78e13837c93c778dcfc3365902cfb8d1bdb7dd73ead37059f0d0"}, {file = "greenlet-2.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3a06ad5312349fec0ab944664b01d26f8d1f05009566339ac6f63f56589bc1a2"}, @@ -333,6 +335,7 @@ files = [ {file = "greenlet-2.0.2-cp37-cp37m-win32.whl", hash = "sha256:3f6ea9bd35eb450837a3d80e77b517ea5bc56b4647f5502cd28de13675ee12f7"}, {file = "greenlet-2.0.2-cp37-cp37m-win_amd64.whl", hash = "sha256:7492e2b7bd7c9b9916388d9df23fa49d9b88ac0640db0a5b4ecc2b653bf451e3"}, {file = "greenlet-2.0.2-cp38-cp38-macosx_10_15_x86_64.whl", hash = "sha256:b864ba53912b6c3ab6bcb2beb19f19edd01a6bfcbdfe1f37ddd1778abfe75a30"}, + {file = "greenlet-2.0.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:1087300cf9700bbf455b1b97e24db18f2f77b55302a68272c56209d5587c12d1"}, {file = "greenlet-2.0.2-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:ba2956617f1c42598a308a84c6cf021a90ff3862eddafd20c3333d50f0edb45b"}, {file = "greenlet-2.0.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fc3a569657468b6f3fb60587e48356fe512c1754ca05a564f11366ac9e306526"}, {file = "greenlet-2.0.2-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8eab883b3b2a38cc1e050819ef06a7e6344d4a990d24d45bc6f2cf959045a45b"}, @@ -341,6 +344,7 @@ files = [ {file = "greenlet-2.0.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:b0ef99cdbe2b682b9ccbb964743a6aca37905fda5e0452e5ee239b1654d37f2a"}, {file = "greenlet-2.0.2-cp38-cp38-win32.whl", hash = "sha256:b80f600eddddce72320dbbc8e3784d16bd3fb7b517e82476d8da921f27d4b249"}, {file = "greenlet-2.0.2-cp38-cp38-win_amd64.whl", hash = "sha256:4d2e11331fc0c02b6e84b0d28ece3a36e0548ee1a1ce9ddde03752d9b79bba40"}, + {file = "greenlet-2.0.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:8512a0c38cfd4e66a858ddd1b17705587900dd760c6003998e9472b77b56d417"}, {file = "greenlet-2.0.2-cp39-cp39-macosx_11_0_x86_64.whl", hash = "sha256:88d9ab96491d38a5ab7c56dd7a3cc37d83336ecc564e4e8816dbed12e5aaefc8"}, {file = "greenlet-2.0.2-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:561091a7be172ab497a3527602d467e2b3fbe75f9e783d8b8ce403fa414f71a6"}, {file = "greenlet-2.0.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:971ce5e14dc5e73715755d0ca2975ac88cfdaefcaab078a284fea6cfabf866df"}, @@ -542,6 +546,16 @@ files = [ {file = "MarkupSafe-2.1.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:5bbe06f8eeafd38e5d0a4894ffec89378b6c6a625ff57e3028921f8ff59318ac"}, {file = "MarkupSafe-2.1.3-cp311-cp311-win32.whl", hash = "sha256:dd15ff04ffd7e05ffcb7fe79f1b98041b8ea30ae9234aed2a9168b5797c3effb"}, {file = "MarkupSafe-2.1.3-cp311-cp311-win_amd64.whl", hash = "sha256:134da1eca9ec0ae528110ccc9e48041e0828d79f24121a1a146161103c76e686"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:f698de3fd0c4e6972b92290a45bd9b1536bffe8c6759c62471efaa8acb4c37bc"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:aa57bd9cf8ae831a362185ee444e15a93ecb2e344c8e52e4d721ea3ab6ef1823"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ffcc3f7c66b5f5b7931a5aa68fc9cecc51e685ef90282f4a82f0f5e9b704ad11"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:47d4f1c5f80fc62fdd7777d0d40a2e9dda0a05883ab11374334f6c4de38adffd"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1f67c7038d560d92149c060157d623c542173016c4babc0c1913cca0564b9939"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:9aad3c1755095ce347e26488214ef77e0485a3c34a50c5a5e2471dff60b9dd9c"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:14ff806850827afd6b07a5f32bd917fb7f45b046ba40c57abdb636674a8b559c"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8f9293864fe09b8149f0cc42ce56e3f0e54de883a9de90cd427f191c346eb2e1"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-win32.whl", hash = "sha256:715d3562f79d540f251b99ebd6d8baa547118974341db04f5ad06d5ea3eb8007"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-win_amd64.whl", hash = "sha256:1b8dd8c3fd14349433c79fa8abeb573a55fc0fdd769133baac1f5e07abf54aeb"}, {file = "MarkupSafe-2.1.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:8e254ae696c88d98da6555f5ace2279cf7cd5b3f52be2b5cf97feafe883b58d2"}, {file = "MarkupSafe-2.1.3-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cb0932dc158471523c9637e807d9bfb93e06a95cbf010f1a38b98623b929ef2b"}, {file = "MarkupSafe-2.1.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9402b03f1a1b4dc4c19845e5c749e3ab82d5078d16a2a4c2cd2df62d57bb0707"}, @@ -1343,6 +1357,12 @@ files = [ {file = "SQLAlchemy-2.0.21-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:b69f1f754d92eb1cc6b50938359dead36b96a1dcf11a8670bff65fd9b21a4b09"}, {file = "SQLAlchemy-2.0.21-cp311-cp311-win32.whl", hash = "sha256:af520a730d523eab77d754f5cf44cc7dd7ad2d54907adeb3233177eeb22f271b"}, {file = "SQLAlchemy-2.0.21-cp311-cp311-win_amd64.whl", hash = "sha256:141675dae56522126986fa4ca713739d00ed3a6f08f3c2eb92c39c6dfec463ce"}, + {file = "SQLAlchemy-2.0.21-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:56628ca27aa17b5890391ded4e385bf0480209726f198799b7e980c6bd473bd7"}, + {file = "SQLAlchemy-2.0.21-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:db726be58837fe5ac39859e0fa40baafe54c6d54c02aba1d47d25536170b690f"}, + {file = "SQLAlchemy-2.0.21-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:632784f7a6f12cfa0e84bf2a5003b07660addccf5563c132cd23b7cc1d7371a9"}, + {file = "SQLAlchemy-2.0.21-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:2a1f7ffac934bc0ea717fa1596f938483fb8c402233f9b26679b4f7b38d6ab6e"}, + {file = "SQLAlchemy-2.0.21-cp312-cp312-win32.whl", hash = "sha256:bfece2f7cec502ec5f759bbc09ce711445372deeac3628f6fa1c16b7fb45b682"}, + {file = "SQLAlchemy-2.0.21-cp312-cp312-win_amd64.whl", hash = "sha256:526b869a0f4f000d8d8ee3409d0becca30ae73f494cbb48801da0129601f72c6"}, {file = "SQLAlchemy-2.0.21-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:7614f1eab4336df7dd6bee05bc974f2b02c38d3d0c78060c5faa4cd1ca2af3b8"}, {file = "SQLAlchemy-2.0.21-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d59cb9e20d79686aa473e0302e4a82882d7118744d30bb1dfb62d3c47141b3ec"}, {file = "SQLAlchemy-2.0.21-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a95aa0672e3065d43c8aa80080cdd5cc40fe92dc873749e6c1cf23914c4b83af"}, @@ -1371,7 +1391,7 @@ files = [ ] [package.dependencies] -greenlet = {version = "!=0.4.17", markers = "platform_machine == \"win32\" or platform_machine == \"WIN32\" or platform_machine == \"AMD64\" or platform_machine == \"amd64\" or platform_machine == \"x86_64\" or platform_machine == \"ppc64le\" or platform_machine == \"aarch64\""} +greenlet = {version = "!=0.4.17", markers = "platform_machine == \"aarch64\" or platform_machine == \"ppc64le\" or platform_machine == \"x86_64\" or platform_machine == \"amd64\" or platform_machine == \"AMD64\" or platform_machine == \"win32\" or platform_machine == \"WIN32\""} typing-extensions = ">=4.2.0" [package.extras]