From 6792ff06d682fa0180b9de015452c872c79e0fd3 Mon Sep 17 00:00:00 2001 From: Alexander Kalinovsky Date: Tue, 19 Aug 2025 17:57:37 +0300 Subject: [PATCH] 0.1.0 --- .gitignore | 176 ++---------------------- pyproject.toml | 19 ++- src/quickbot_agent/__init__.py | 9 +- src/quickbot_agent/config.py | 1 + src/quickbot_agent/handlers/messages.py | 13 ++ 5 files changed, 47 insertions(+), 171 deletions(-) diff --git a/.gitignore b/.gitignore index 0dbf2f2..7798936 100644 --- a/.gitignore +++ b/.gitignore @@ -1,170 +1,10 @@ -# ---> Python -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# UV -# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -#uv.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -#pdm.lock -# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it -# in version control. -# https://pdm.fming.dev/latest/usage/project/#working-with-version-control -.pdm.toml -.pdm-python -.pdm-build/ - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments +__pycache__ .env +.pytest_cache +.DS_Store .venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ - -# PyCharm -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ - +.python-version +uv.lock +dist +*.egg-info +site \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 5a4f088..35064f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,13 @@ +[build-system] +requires = ["setuptools>=61.0", "wheel"] +build-backend = "setuptools.build_meta" + [project] name = "quickbot-agent" version = "0.1.0" description = "Adds AI answers and API orchestration to your bot" readme = "README.md" -requires-python = ">=3.12" +requires-python = ">=3.13" classifiers = [ "Programming Language :: Python :: 3", "Operating System :: OS Independent", @@ -14,5 +18,18 @@ authors = [ ] license = { file = "LICENSE" } dependencies = [ + "quickbot>=0.1.1", "openai>=1.97.1", + "pydantic>=2.11.7", ] + +[project.optional-dependencies] +dev = [ + "build>=1.2.1", + "twine>=5.0.0", + "pytest>=8.0.0", + "ruff>=0.5.0", +] + +[tool.setuptools.packages.find] +where = ["src"] \ No newline at end of file diff --git a/src/quickbot_agent/__init__.py b/src/quickbot_agent/__init__.py index 9c3d850..c881f2d 100644 --- a/src/quickbot_agent/__init__.py +++ b/src/quickbot_agent/__init__.py @@ -1,2 +1,7 @@ -from .model.message_log import MessageLog as MessageLog -from .main import AgentPlugin as AgentPlugin +from .model.message_log import MessageLog +from .main import AgentPlugin + +__all__ = [ + "AgentPlugin", + "MessageLog" +] diff --git a/src/quickbot_agent/config.py b/src/quickbot_agent/config.py index 7d7eddc..83e3df8 100644 --- a/src/quickbot_agent/config.py +++ b/src/quickbot_agent/config.py @@ -9,6 +9,7 @@ class Config(BaseSettings): OPENAI_API_KEY: str OPENAI_MODEL: str = "gpt-4o-2024-11-20" MESSAGE_HISTORY_DEPTH: int = 20 + SEND_TYPING: bool = True config = Config() diff --git a/src/quickbot_agent/handlers/messages.py b/src/quickbot_agent/handlers/messages.py index 7473998..1ad3988 100644 --- a/src/quickbot_agent/handlers/messages.py +++ b/src/quickbot_agent/handlers/messages.py @@ -245,6 +245,12 @@ async def handle_message( system_prompt = await get_system_prompt(plugin, context) messages = await get_messages(plugin, context, system_prompt) + if config.SEND_TYPING: + await context.message.bot.send_chat_action( + chat_id=context.message.chat.id, + action="typing", + ) + async with AsyncOpenAI( api_key=config.OPENAI_API_KEY, ) as client: @@ -286,6 +292,13 @@ async def handle_business_message( system_prompt = await get_system_prompt(plugin, context) messages = await get_messages(plugin, context, system_prompt) + if config.SEND_TYPING: + await context.message.bot.send_chat_action( + chat_id=context.message.chat.id, + action="typing", + business_connection_id=context.message.business_connection_id, + ) + async with AsyncOpenAI( api_key=config.OPENAI_API_KEY, ) as client: