This commit is contained in:
Alexander Kalinovsky
2025-08-19 17:57:37 +03:00
parent 7e87066253
commit 6792ff06d6
5 changed files with 47 additions and 171 deletions

176
.gitignore vendored
View File

@@ -1,170 +1,10 @@
# ---> Python __pycache__
# 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
.env .env
.pytest_cache
.DS_Store
.venv .venv
env/ .python-version
venv/ uv.lock
ENV/ dist
env.bak/ *.egg-info
venv.bak/ site
# 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/

View File

@@ -1,9 +1,13 @@
[build-system]
requires = ["setuptools>=61.0", "wheel"]
build-backend = "setuptools.build_meta"
[project] [project]
name = "quickbot-agent" name = "quickbot-agent"
version = "0.1.0" version = "0.1.0"
description = "Adds AI answers and API orchestration to your bot" description = "Adds AI answers and API orchestration to your bot"
readme = "README.md" readme = "README.md"
requires-python = ">=3.12" requires-python = ">=3.13"
classifiers = [ classifiers = [
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",
"Operating System :: OS Independent", "Operating System :: OS Independent",
@@ -14,5 +18,18 @@ authors = [
] ]
license = { file = "LICENSE" } license = { file = "LICENSE" }
dependencies = [ dependencies = [
"quickbot>=0.1.1",
"openai>=1.97.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"]

View File

@@ -1,2 +1,7 @@
from .model.message_log import MessageLog as MessageLog from .model.message_log import MessageLog
from .main import AgentPlugin as AgentPlugin from .main import AgentPlugin
__all__ = [
"AgentPlugin",
"MessageLog"
]

View File

@@ -9,6 +9,7 @@ class Config(BaseSettings):
OPENAI_API_KEY: str OPENAI_API_KEY: str
OPENAI_MODEL: str = "gpt-4o-2024-11-20" OPENAI_MODEL: str = "gpt-4o-2024-11-20"
MESSAGE_HISTORY_DEPTH: int = 20 MESSAGE_HISTORY_DEPTH: int = 20
SEND_TYPING: bool = True
config = Config() config = Config()

View File

@@ -245,6 +245,12 @@ async def handle_message(
system_prompt = await get_system_prompt(plugin, context) system_prompt = await get_system_prompt(plugin, context)
messages = await get_messages(plugin, context, system_prompt) 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( async with AsyncOpenAI(
api_key=config.OPENAI_API_KEY, api_key=config.OPENAI_API_KEY,
) as client: ) as client:
@@ -286,6 +292,13 @@ async def handle_business_message(
system_prompt = await get_system_prompt(plugin, context) system_prompt = await get_system_prompt(plugin, context)
messages = await get_messages(plugin, context, system_prompt) 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( async with AsyncOpenAI(
api_key=config.OPENAI_API_KEY, api_key=config.OPENAI_API_KEY,
) as client: ) as client: