arcade-slack 0.4.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- arcade_slack-0.4.6/.gitignore +175 -0
- arcade_slack-0.4.6/.pre-commit-config.yaml +18 -0
- arcade_slack-0.4.6/.ruff.toml +47 -0
- arcade_slack-0.4.6/LICENSE +21 -0
- arcade_slack-0.4.6/Makefile +55 -0
- arcade_slack-0.4.6/PKG-INFO +23 -0
- arcade_slack-0.4.6/arcade_slack/__init__.py +0 -0
- arcade_slack-0.4.6/arcade_slack/constants.py +13 -0
- arcade_slack-0.4.6/arcade_slack/critics.py +34 -0
- arcade_slack-0.4.6/arcade_slack/custom_types.py +26 -0
- arcade_slack-0.4.6/arcade_slack/exceptions.py +30 -0
- arcade_slack-0.4.6/arcade_slack/models.py +206 -0
- arcade_slack-0.4.6/arcade_slack/tools/__init__.py +0 -0
- arcade_slack-0.4.6/arcade_slack/tools/chat.py +942 -0
- arcade_slack-0.4.6/arcade_slack/tools/users.py +87 -0
- arcade_slack-0.4.6/arcade_slack/utils.py +447 -0
- arcade_slack-0.4.6/conftest.py +20 -0
- arcade_slack-0.4.6/evals/eval_chat.py +1168 -0
- arcade_slack-0.4.6/evals/eval_users.py +168 -0
- arcade_slack-0.4.6/pyproject.toml +54 -0
- arcade_slack-0.4.6/tests/__init__.py +0 -0
- arcade_slack-0.4.6/tests/test_chat.py +992 -0
- arcade_slack-0.4.6/tests/test_users.py +92 -0
- arcade_slack-0.4.6/tests/test_utils.py +684 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
.DS_Store
|
|
2
|
+
credentials.yaml
|
|
3
|
+
docker/credentials.yaml
|
|
4
|
+
|
|
5
|
+
*.lock
|
|
6
|
+
|
|
7
|
+
# example data
|
|
8
|
+
examples/data
|
|
9
|
+
scratch
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
docs/source
|
|
13
|
+
|
|
14
|
+
# From https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore
|
|
15
|
+
|
|
16
|
+
# Byte-compiled / optimized / DLL files
|
|
17
|
+
__pycache__/
|
|
18
|
+
*.py[cod]
|
|
19
|
+
*$py.class
|
|
20
|
+
|
|
21
|
+
# C extensions
|
|
22
|
+
*.so
|
|
23
|
+
|
|
24
|
+
# Distribution / packaging
|
|
25
|
+
.Python
|
|
26
|
+
build/
|
|
27
|
+
develop-eggs/
|
|
28
|
+
dist/
|
|
29
|
+
downloads/
|
|
30
|
+
eggs/
|
|
31
|
+
.eggs/
|
|
32
|
+
lib/
|
|
33
|
+
lib64/
|
|
34
|
+
parts/
|
|
35
|
+
sdist/
|
|
36
|
+
var/
|
|
37
|
+
wheels/
|
|
38
|
+
share/python-wheels/
|
|
39
|
+
*.egg-info/
|
|
40
|
+
.installed.cfg
|
|
41
|
+
*.egg
|
|
42
|
+
MANIFEST
|
|
43
|
+
|
|
44
|
+
# PyInstaller
|
|
45
|
+
# Usually these files are written by a python script from a template
|
|
46
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
47
|
+
*.manifest
|
|
48
|
+
*.spec
|
|
49
|
+
|
|
50
|
+
# Installer logs
|
|
51
|
+
pip-log.txt
|
|
52
|
+
pip-delete-this-directory.txt
|
|
53
|
+
|
|
54
|
+
# Unit test / coverage reports
|
|
55
|
+
htmlcov/
|
|
56
|
+
.tox/
|
|
57
|
+
.nox/
|
|
58
|
+
.coverage
|
|
59
|
+
.coverage.*
|
|
60
|
+
.cache
|
|
61
|
+
nosetests.xml
|
|
62
|
+
coverage.xml
|
|
63
|
+
*.cover
|
|
64
|
+
*.py,cover
|
|
65
|
+
.hypothesis/
|
|
66
|
+
.pytest_cache/
|
|
67
|
+
cover/
|
|
68
|
+
|
|
69
|
+
# Translations
|
|
70
|
+
*.mo
|
|
71
|
+
*.pot
|
|
72
|
+
|
|
73
|
+
# Django stuff:
|
|
74
|
+
*.log
|
|
75
|
+
local_settings.py
|
|
76
|
+
db.sqlite3
|
|
77
|
+
db.sqlite3-journal
|
|
78
|
+
|
|
79
|
+
# Flask stuff:
|
|
80
|
+
instance/
|
|
81
|
+
.webassets-cache
|
|
82
|
+
|
|
83
|
+
# Scrapy stuff:
|
|
84
|
+
.scrapy
|
|
85
|
+
|
|
86
|
+
# Sphinx documentation
|
|
87
|
+
docs/_build/
|
|
88
|
+
|
|
89
|
+
# PyBuilder
|
|
90
|
+
.pybuilder/
|
|
91
|
+
target/
|
|
92
|
+
|
|
93
|
+
# Jupyter Notebook
|
|
94
|
+
.ipynb_checkpoints
|
|
95
|
+
|
|
96
|
+
# IPython
|
|
97
|
+
profile_default/
|
|
98
|
+
ipython_config.py
|
|
99
|
+
|
|
100
|
+
# pyenv
|
|
101
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
102
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
103
|
+
# .python-version
|
|
104
|
+
|
|
105
|
+
# pipenv
|
|
106
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
107
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
108
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
109
|
+
# install all needed dependencies.
|
|
110
|
+
#Pipfile.lock
|
|
111
|
+
|
|
112
|
+
# poetry
|
|
113
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
114
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
115
|
+
# commonly ignored for libraries.
|
|
116
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
117
|
+
poetry.lock
|
|
118
|
+
|
|
119
|
+
# pdm
|
|
120
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
121
|
+
#pdm.lock
|
|
122
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
123
|
+
# in version control.
|
|
124
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
125
|
+
.pdm.toml
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.venv
|
|
140
|
+
env/
|
|
141
|
+
venv/
|
|
142
|
+
ENV/
|
|
143
|
+
env.bak/
|
|
144
|
+
venv.bak/
|
|
145
|
+
|
|
146
|
+
# Spyder project settings
|
|
147
|
+
.spyderproject
|
|
148
|
+
.spyproject
|
|
149
|
+
|
|
150
|
+
# Rope project settings
|
|
151
|
+
.ropeproject
|
|
152
|
+
|
|
153
|
+
# mkdocs documentation
|
|
154
|
+
/site
|
|
155
|
+
|
|
156
|
+
# mypy
|
|
157
|
+
.mypy_cache/
|
|
158
|
+
.dmypy.json
|
|
159
|
+
dmypy.json
|
|
160
|
+
|
|
161
|
+
# Pyre type checker
|
|
162
|
+
.pyre/
|
|
163
|
+
|
|
164
|
+
# pytype static type analyzer
|
|
165
|
+
.pytype/
|
|
166
|
+
|
|
167
|
+
# Cython debug symbols
|
|
168
|
+
cython_debug/
|
|
169
|
+
|
|
170
|
+
# PyCharm
|
|
171
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
172
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
173
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
174
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
175
|
+
#.idea/
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
files: ^.*/slack/.*
|
|
2
|
+
repos:
|
|
3
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
4
|
+
rev: "v4.4.0"
|
|
5
|
+
hooks:
|
|
6
|
+
- id: check-case-conflict
|
|
7
|
+
- id: check-merge-conflict
|
|
8
|
+
- id: check-toml
|
|
9
|
+
- id: check-yaml
|
|
10
|
+
- id: end-of-file-fixer
|
|
11
|
+
- id: trailing-whitespace
|
|
12
|
+
|
|
13
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
14
|
+
rev: v0.6.7
|
|
15
|
+
hooks:
|
|
16
|
+
- id: ruff
|
|
17
|
+
args: [--fix]
|
|
18
|
+
- id: ruff-format
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
target-version = "py310"
|
|
2
|
+
line-length = 100
|
|
3
|
+
fix = true
|
|
4
|
+
|
|
5
|
+
[lint]
|
|
6
|
+
select = [
|
|
7
|
+
# flake8-2020
|
|
8
|
+
"YTT",
|
|
9
|
+
# flake8-bandit
|
|
10
|
+
"S",
|
|
11
|
+
# flake8-bugbear
|
|
12
|
+
"B",
|
|
13
|
+
# flake8-builtins
|
|
14
|
+
"A",
|
|
15
|
+
# flake8-comprehensions
|
|
16
|
+
"C4",
|
|
17
|
+
# flake8-debugger
|
|
18
|
+
"T10",
|
|
19
|
+
# flake8-simplify
|
|
20
|
+
"SIM",
|
|
21
|
+
# isort
|
|
22
|
+
"I",
|
|
23
|
+
# mccabe
|
|
24
|
+
"C90",
|
|
25
|
+
# pycodestyle
|
|
26
|
+
"E", "W",
|
|
27
|
+
# pyflakes
|
|
28
|
+
"F",
|
|
29
|
+
# pygrep-hooks
|
|
30
|
+
"PGH",
|
|
31
|
+
# pyupgrade
|
|
32
|
+
"UP",
|
|
33
|
+
# ruff
|
|
34
|
+
"RUF",
|
|
35
|
+
# tryceratops
|
|
36
|
+
"TRY",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[lint.per-file-ignores]
|
|
40
|
+
"*" = ["TRY003", "B904"]
|
|
41
|
+
"**/tests/*" = ["S101", "E501"]
|
|
42
|
+
"**/evals/*" = ["S101", "E501"]
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
[format]
|
|
46
|
+
preview = true
|
|
47
|
+
skip-magic-trailing-comma = false
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, Arcade AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
.PHONY: help
|
|
2
|
+
|
|
3
|
+
help:
|
|
4
|
+
@echo "🛠️ github Commands:\n"
|
|
5
|
+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
|
6
|
+
|
|
7
|
+
.PHONY: install
|
|
8
|
+
install: ## Install the uv environment and install all packages with dependencies
|
|
9
|
+
@echo "🚀 Creating virtual environment and installing all packages using uv"
|
|
10
|
+
@uv sync --active --all-extras --no-sources
|
|
11
|
+
@if [ -f .pre-commit-config.yaml ]; then uv run --no-sources pre-commit install; fi
|
|
12
|
+
@echo "✅ All packages and dependencies installed via uv"
|
|
13
|
+
|
|
14
|
+
.PHONY: install-local
|
|
15
|
+
install-local: ## Install the uv environment and install all packages with dependencies with local Arcade sources
|
|
16
|
+
@echo "🚀 Creating virtual environment and installing all packages using uv"
|
|
17
|
+
@uv sync --active --all-extras
|
|
18
|
+
@if [ -f .pre-commit-config.yaml ]; then uv run pre-commit install; fi
|
|
19
|
+
@echo "✅ All packages and dependencies installed via uv"
|
|
20
|
+
|
|
21
|
+
.PHONY: build
|
|
22
|
+
build: clean-build ## Build wheel file using poetry
|
|
23
|
+
@echo "🚀 Creating wheel file"
|
|
24
|
+
uv build
|
|
25
|
+
|
|
26
|
+
.PHONY: clean-build
|
|
27
|
+
clean-build: ## clean build artifacts
|
|
28
|
+
@echo "🗑️ Cleaning dist directory"
|
|
29
|
+
rm -rf dist
|
|
30
|
+
|
|
31
|
+
.PHONY: test
|
|
32
|
+
test: ## Test the code with pytest
|
|
33
|
+
@echo "🚀 Testing code: Running pytest"
|
|
34
|
+
@uv run --no-sources pytest -W ignore -v --cov --cov-config=pyproject.toml --cov-report=xml
|
|
35
|
+
|
|
36
|
+
.PHONY: coverage
|
|
37
|
+
coverage: ## Generate coverage report
|
|
38
|
+
@echo "coverage report"
|
|
39
|
+
@uv run --no-sources coverage report
|
|
40
|
+
@echo "Generating coverage report"
|
|
41
|
+
@uv run --no-sources coverage html
|
|
42
|
+
|
|
43
|
+
.PHONY: bump-version
|
|
44
|
+
bump-version: ## Bump the version in the pyproject.toml file by a patch version
|
|
45
|
+
@echo "🚀 Bumping version in pyproject.toml"
|
|
46
|
+
uv version --no-sources --bump patch
|
|
47
|
+
|
|
48
|
+
.PHONY: check
|
|
49
|
+
check: ## Run code quality tools.
|
|
50
|
+
@if [ -f .pre-commit-config.yaml ]; then\
|
|
51
|
+
echo "🚀 Linting code: Running pre-commit";\
|
|
52
|
+
uv run --no-sources pre-commit run -a;\
|
|
53
|
+
fi
|
|
54
|
+
@echo "🚀 Static type checking: Running mypy"
|
|
55
|
+
@uv run --no-sources mypy --config-file=pyproject.toml
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: arcade_slack
|
|
3
|
+
Version: 0.4.6
|
|
4
|
+
Summary: Arcade.dev LLM tools for Slack
|
|
5
|
+
Author-email: Arcade <dev@arcade.dev>
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Requires-Dist: aiodns<2.0.0,>=1.0
|
|
9
|
+
Requires-Dist: aiohttp<4.0.0,>=3.7.3
|
|
10
|
+
Requires-Dist: arcade-tdk<3.0.0,>=2.0.0
|
|
11
|
+
Requires-Dist: slack-sdk<4.0.0,>=3.31.0
|
|
12
|
+
Requires-Dist: typing; python_version < '3.7'
|
|
13
|
+
Provides-Extra: dev
|
|
14
|
+
Requires-Dist: arcade-ai[evals]<3.0.0,>=2.0.0; extra == 'dev'
|
|
15
|
+
Requires-Dist: arcade-serve<3.0.0,>=2.0.0; extra == 'dev'
|
|
16
|
+
Requires-Dist: mypy<1.6.0,>=1.5.1; extra == 'dev'
|
|
17
|
+
Requires-Dist: pre-commit<3.5.0,>=3.4.0; extra == 'dev'
|
|
18
|
+
Requires-Dist: pytest-asyncio<0.25.0,>=0.24.0; extra == 'dev'
|
|
19
|
+
Requires-Dist: pytest-cov<4.1.0,>=4.0.0; extra == 'dev'
|
|
20
|
+
Requires-Dist: pytest-mock<3.12.0,>=3.11.1; extra == 'dev'
|
|
21
|
+
Requires-Dist: pytest<8.4.0,>=8.3.0; extra == 'dev'
|
|
22
|
+
Requires-Dist: ruff<0.8.0,>=0.7.4; extra == 'dev'
|
|
23
|
+
Requires-Dist: tox<4.12.0,>=4.11.1; extra == 'dev'
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from arcade_slack.custom_types import PositiveInt
|
|
4
|
+
|
|
5
|
+
MAX_PAGINATION_SIZE_LIMIT = 200
|
|
6
|
+
|
|
7
|
+
MAX_PAGINATION_TIMEOUT_SECONDS = PositiveInt(
|
|
8
|
+
os.environ.get(
|
|
9
|
+
"MAX_PAGINATION_TIMEOUT_SECONDS",
|
|
10
|
+
os.environ.get("MAX_SLACK_PAGINATION_TIMEOUT_SECONDS", 30),
|
|
11
|
+
),
|
|
12
|
+
name="MAX_PAGINATION_TIMEOUT_SECONDS or MAX_SLACK_PAGINATION_TIMEOUT_SECONDS",
|
|
13
|
+
)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from arcade_evals import BinaryCritic
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class RelativeTimeBinaryCritic(BinaryCritic):
|
|
7
|
+
def evaluate(self, expected: Any, actual: Any) -> dict[str, float | bool]:
|
|
8
|
+
"""
|
|
9
|
+
Evaluates whether the expected and actual relative time strings are equivalent after
|
|
10
|
+
casting.
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
expected: The expected value.
|
|
14
|
+
actual: The actual value to compare, cast to the type of expected.
|
|
15
|
+
|
|
16
|
+
Returns:
|
|
17
|
+
dict: A dictionary containing the match status and score.
|
|
18
|
+
"""
|
|
19
|
+
try:
|
|
20
|
+
actual_casted = self.cast_actual(expected, actual)
|
|
21
|
+
except TypeError:
|
|
22
|
+
actual_casted = actual
|
|
23
|
+
|
|
24
|
+
expected_parts = tuple(map(int, expected.split(":")))
|
|
25
|
+
actual_parts = tuple(map(int, actual_casted.split(":")))
|
|
26
|
+
|
|
27
|
+
if len(expected_parts) != 3 or len(actual_parts) != 3:
|
|
28
|
+
return {"match": False, "score": 0.0}
|
|
29
|
+
|
|
30
|
+
exp_days, exp_hours, exp_minutes = expected_parts
|
|
31
|
+
act_days, act_hours, act_minutes = actual_parts
|
|
32
|
+
|
|
33
|
+
match = exp_days == act_days and exp_hours == act_hours and exp_minutes == act_minutes
|
|
34
|
+
return {"match": match, "score": self.weight if match else 0.0}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from typing import NewType
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class PositiveInt(int):
|
|
5
|
+
def __new__(cls, value: str | int, name: str = "value") -> "PositiveInt":
|
|
6
|
+
def validate(val: int) -> int:
|
|
7
|
+
if val <= 0:
|
|
8
|
+
raise ValueError(f"{name} must be positive, got {val}")
|
|
9
|
+
return val
|
|
10
|
+
|
|
11
|
+
try:
|
|
12
|
+
value = int(value)
|
|
13
|
+
except ValueError:
|
|
14
|
+
raise ValueError(f"{name} must be a valid integer, got {value!r}")
|
|
15
|
+
|
|
16
|
+
validated_value = validate(value)
|
|
17
|
+
instance = super().__new__(cls, validated_value)
|
|
18
|
+
return instance
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
SlackOffsetSecondsFromUTC = NewType("SlackOffsetSecondsFromUTC", int) # observe it can be negative
|
|
22
|
+
SlackPaginationNextCursor = str | None
|
|
23
|
+
SlackUserFieldId = NewType("SlackUserFieldId", str)
|
|
24
|
+
SlackUserId = NewType("SlackUserId", str)
|
|
25
|
+
SlackTeamId = NewType("SlackTeamId", str)
|
|
26
|
+
SlackTimestampStr = NewType("SlackTimestampStr", str)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
class SlackToolkitError(Exception):
|
|
2
|
+
"""Base class for all Slack toolkit errors."""
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class PaginationTimeoutError(SlackToolkitError):
|
|
6
|
+
"""Raised when a timeout occurs during pagination."""
|
|
7
|
+
|
|
8
|
+
def __init__(self, timeout_seconds: int):
|
|
9
|
+
self.timeout_seconds = timeout_seconds
|
|
10
|
+
super().__init__(f"The pagination process timed out after {timeout_seconds} seconds.")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ItemNotFoundError(SlackToolkitError):
|
|
14
|
+
"""Raised when an item is not found."""
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class UsernameNotFoundError(SlackToolkitError):
|
|
18
|
+
"""Raised when a user is not found by the username searched"""
|
|
19
|
+
|
|
20
|
+
def __init__(self, usernames_found: list[str], username_not_found: str) -> None:
|
|
21
|
+
self.usernames_found = usernames_found
|
|
22
|
+
self.username_not_found = username_not_found
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ConversationNotFoundError(SlackToolkitError):
|
|
26
|
+
"""Raised when a conversation is not found"""
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class DirectMessageConversationNotFoundError(ConversationNotFoundError):
|
|
30
|
+
"""Raised when a direct message conversation searched is not found"""
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
from typing import Literal, TypedDict
|
|
3
|
+
|
|
4
|
+
from arcade_slack.custom_types import (
|
|
5
|
+
SlackOffsetSecondsFromUTC,
|
|
6
|
+
SlackPaginationNextCursor,
|
|
7
|
+
SlackTeamId,
|
|
8
|
+
SlackTimestampStr,
|
|
9
|
+
SlackUserFieldId,
|
|
10
|
+
SlackUserId,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ConversationTypeSlackName(str, Enum):
|
|
15
|
+
PUBLIC_CHANNEL = "public_channel" # Public channels are visible to all users in the workspace
|
|
16
|
+
PRIVATE_CHANNEL = "private_channel" # Private channels are visible to only specific users
|
|
17
|
+
MPIM = "mpim" # Multi-person direct message conversation
|
|
18
|
+
IM = "im" # Two person direct message conversation
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class ConversationType(str, Enum):
|
|
22
|
+
PUBLIC_CHANNEL = "public_channel"
|
|
23
|
+
PRIVATE_CHANNEL = "private_channel"
|
|
24
|
+
MULTI_PERSON_DIRECT_MESSAGE = "multi_person_direct_message"
|
|
25
|
+
DIRECT_MESSAGE = "direct_message"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
"""
|
|
29
|
+
About Slack dictionaries: Slack does not guarantee the presence of all fields for a given
|
|
30
|
+
object. It will vary from endpoint to endpoint and even if the field is present, they say it may
|
|
31
|
+
contain a None value or an empty string instead of the actual expected value.
|
|
32
|
+
|
|
33
|
+
See, for example, the 'Common Fields' section of the user type definition at:
|
|
34
|
+
https://api.slack.com/types/user#fields (https://archive.is/RUZdL)
|
|
35
|
+
|
|
36
|
+
Because of that, our TypedDicts ended up having to be mostly total=False and most of the fields'
|
|
37
|
+
type hints are Optional. Use Slack dictionary fields with caution. It's advisable to validate the
|
|
38
|
+
value before using it and raise errors that are clear to understand, when appropriate.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class SlackUserFieldData(TypedDict, total=False):
|
|
43
|
+
"""Type definition for Slack user field data dictionary.
|
|
44
|
+
|
|
45
|
+
Slack type definition: https://api.slack.com/methods/users.profile.set#custom-profile
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
value: str | None
|
|
49
|
+
alt: bool | None
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class SlackStatusEmojiDisplayInfo(TypedDict, total=False):
|
|
53
|
+
"""Type definition for Slack status emoji display info dictionary."""
|
|
54
|
+
|
|
55
|
+
emoji_name: str | None
|
|
56
|
+
display_url: str | None
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class SlackUserProfile(TypedDict, total=False):
|
|
60
|
+
"""Type definition for Slack user profile dictionary.
|
|
61
|
+
|
|
62
|
+
Slack type definition: https://api.slack.com/types/user#profile (https://archive.is/RUZdL)
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
title: str | None
|
|
66
|
+
phone: str | None
|
|
67
|
+
skype: str | None
|
|
68
|
+
email: str | None
|
|
69
|
+
real_name: str | None
|
|
70
|
+
real_name_normalized: str | None
|
|
71
|
+
display_name: str | None
|
|
72
|
+
display_name_normalized: str | None
|
|
73
|
+
first_name: str | None
|
|
74
|
+
last_name: str | None
|
|
75
|
+
fields: list[dict[SlackUserFieldId, SlackUserFieldData]] | None
|
|
76
|
+
image_original: str | None
|
|
77
|
+
is_custom_image: bool | None
|
|
78
|
+
image_24: str | None
|
|
79
|
+
image_32: str | None
|
|
80
|
+
image_48: str | None
|
|
81
|
+
image_72: str | None
|
|
82
|
+
image_192: str | None
|
|
83
|
+
image_512: str | None
|
|
84
|
+
image_1024: str | None
|
|
85
|
+
status_emoji: str | None
|
|
86
|
+
status_emoji_display_info: list[SlackStatusEmojiDisplayInfo] | None
|
|
87
|
+
status_text: str | None
|
|
88
|
+
status_text_canonical: str | None
|
|
89
|
+
status_expiration: int | None
|
|
90
|
+
avatar_hash: str | None
|
|
91
|
+
start_date: str | None
|
|
92
|
+
pronouns: str | None
|
|
93
|
+
huddle_state: str | None
|
|
94
|
+
huddle_state_expiration: int | None
|
|
95
|
+
team: SlackTeamId | None
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class SlackUser(TypedDict, total=False):
|
|
99
|
+
"""Type definition for Slack user dictionary.
|
|
100
|
+
|
|
101
|
+
Slack type definition: https://api.slack.com/types/user (https://archive.is/RUZdL)
|
|
102
|
+
"""
|
|
103
|
+
|
|
104
|
+
id: SlackUserId
|
|
105
|
+
team_id: SlackTeamId
|
|
106
|
+
name: str | None
|
|
107
|
+
deleted: bool | None
|
|
108
|
+
color: str | None
|
|
109
|
+
real_name: str | None
|
|
110
|
+
tz: str | None
|
|
111
|
+
tz_label: str | None
|
|
112
|
+
tz_offset: SlackOffsetSecondsFromUTC | None
|
|
113
|
+
profile: SlackUserProfile | None
|
|
114
|
+
is_admin: bool | None
|
|
115
|
+
is_owner: bool | None
|
|
116
|
+
is_primary_owner: bool | None
|
|
117
|
+
is_restricted: bool | None
|
|
118
|
+
is_ultra_restricted: bool | None
|
|
119
|
+
is_bot: bool | None
|
|
120
|
+
is_app_user: bool | None
|
|
121
|
+
is_email_confirmed: bool | None
|
|
122
|
+
who_can_share_contact_card: str | None
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class SlackUserList(TypedDict, total=False):
|
|
126
|
+
"""Type definition for the returned user list dictionary."""
|
|
127
|
+
|
|
128
|
+
members: list[SlackUser]
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
class SlackConversationPurpose(TypedDict, total=False):
|
|
132
|
+
"""Type definition for the Slack conversation purpose dictionary."""
|
|
133
|
+
|
|
134
|
+
value: str | None
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
class SlackConversation(TypedDict, total=False):
|
|
138
|
+
"""Type definition for the Slack conversation dictionary."""
|
|
139
|
+
|
|
140
|
+
id: str | None
|
|
141
|
+
name: str | None
|
|
142
|
+
is_private: bool | None
|
|
143
|
+
is_archived: bool | None
|
|
144
|
+
is_member: bool | None
|
|
145
|
+
is_channel: bool | None
|
|
146
|
+
is_group: bool | None
|
|
147
|
+
is_im: bool | None
|
|
148
|
+
is_mpim: bool | None
|
|
149
|
+
purpose: SlackConversationPurpose | None
|
|
150
|
+
num_members: int | None
|
|
151
|
+
user: SlackUser | None
|
|
152
|
+
is_user_deleted: bool | None
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
class SlackMessage(TypedDict, total=True):
|
|
156
|
+
"""Type definition for the Slack message dictionary."""
|
|
157
|
+
|
|
158
|
+
type: Literal["message"]
|
|
159
|
+
user: SlackUser
|
|
160
|
+
text: str
|
|
161
|
+
ts: SlackTimestampStr # Slack timestamp as a string (e.g. "1234567890.123456")
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
class Message(SlackMessage, total=False):
|
|
165
|
+
"""Type definition for the message dictionary.
|
|
166
|
+
|
|
167
|
+
Having a human-readable datetime string is useful for LLMs when they need to display the
|
|
168
|
+
date/time for the user. If not, they'll try to convert the unix timestamp to a human-readable
|
|
169
|
+
date/time,which they don't usually do accurately.
|
|
170
|
+
"""
|
|
171
|
+
|
|
172
|
+
datetime_timestamp: str # Human-readable datetime string (e.g. "2025-01-22 12:00:00")
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
class ConversationMetadata(TypedDict, total=False):
|
|
176
|
+
"""Type definition for the conversation metadata dictionary."""
|
|
177
|
+
|
|
178
|
+
id: str | None
|
|
179
|
+
name: str | None
|
|
180
|
+
conversation_type: str | None
|
|
181
|
+
is_private: bool | None
|
|
182
|
+
is_archived: bool | None
|
|
183
|
+
is_member: bool | None
|
|
184
|
+
purpose: str | None
|
|
185
|
+
num_members: int | None
|
|
186
|
+
user: SlackUser | None
|
|
187
|
+
is_user_deleted: bool | None
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
class BasicUserInfo(TypedDict, total=False):
|
|
191
|
+
"""Type definition for the returned basic user info dictionary."""
|
|
192
|
+
|
|
193
|
+
id: str | None
|
|
194
|
+
name: str | None
|
|
195
|
+
is_bot: bool | None
|
|
196
|
+
email: str | None
|
|
197
|
+
display_name: str | None
|
|
198
|
+
real_name: str | None
|
|
199
|
+
timezone: str | None
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
class SlackConversationsToolResponse(TypedDict, total=True):
|
|
203
|
+
"""Type definition for the Slack conversations tool response dictionary."""
|
|
204
|
+
|
|
205
|
+
conversations: list[ConversationMetadata]
|
|
206
|
+
next_cursor: SlackPaginationNextCursor | None
|
|
File without changes
|