-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
lookup_tweet_by_id
to X Toolkit (#165)
This PR introduces the `lookup_tweet_by_id` tool to the X toolkit, enabling users to retrieve tweet details by tweet ID. This enhancement extends the toolkit's capabilities, allowing for more comprehensive interactions with the X (Twitter) API. **Key Changes:** - **Added `lookup_tweet_by_id` Tool:** - Implemented the `lookup_tweet_by_id` function in `tools/tweets.py`, which allows users to fetch tweet information using a tweet ID. - Included error handling for API response codes and expanded URLs in tweets to assist language models in avoiding hallucinations due to shortened URLs. - **Enhanced Toolkit Structure:** - Added several configuration files to the X toolkit to establish a standardized project structure, which in the future will be generated by `arcade new`. These include: - `.pre-commit-config.yaml`: Defines pre-commit hooks for code quality checks. - `.ruff.toml`: Configuration for the Ruff linter. - `LICENSE`: MIT License file for the toolkit. - `Makefile`: Contains common commands for building, testing, and linting the toolkit. - **Updated Makefile:** - Added `make check-toolkits` command to the top-level `Makefile`. This command runs code quality tools for each toolkit that contains a `Makefile`. **Additional Notes:** - **Tests:** - Added unit tests for the new `lookup_tweet_by_id` tool in `tests/test_tweets.py`. - Included tests for the user lookup functionality in `tests/test_users.py`. - **Linting and Code Quality:** - Configured pre-commit hooks and Ruff linter to enforce code standards. - Updated the `pyproject.toml` file with development dependencies for testing and linting. - --------- Co-authored-by: Eric Gustin <eric@arcade-ai.com>
- Loading branch information
1 parent
cf6a296
commit bebfcab
Showing
14 changed files
with
763 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
files: ^./ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: "v4.4.0" | ||
hooks: | ||
- id: check-case-conflict | ||
- id: check-merge-conflict | ||
- id: check-toml | ||
- id: check-yaml | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
|
||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.6.7 | ||
hooks: | ||
- id: ruff | ||
args: [--fix] | ||
- id: ruff-format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
target-version = "py39" | ||
line-length = 100 | ||
fix = true | ||
|
||
[lint] | ||
select = [ | ||
# flake8-2020 | ||
"YTT", | ||
# flake8-bandit | ||
"S", | ||
# flake8-bugbear | ||
"B", | ||
# flake8-builtins | ||
"A", | ||
# flake8-comprehensions | ||
"C4", | ||
# flake8-debugger | ||
"T10", | ||
# flake8-simplify | ||
"SIM", | ||
# isort | ||
"I", | ||
# mccabe | ||
"C90", | ||
# pycodestyle | ||
"E", "W", | ||
# pyflakes | ||
"F", | ||
# pygrep-hooks | ||
"PGH", | ||
# pyupgrade | ||
"UP", | ||
# ruff | ||
"RUF", | ||
# tryceratops | ||
"TRY", | ||
] | ||
|
||
[lint.per-file-ignores] | ||
"**/tests/*" = ["S101"] | ||
|
||
[format] | ||
preview = true | ||
skip-magic-trailing-comma = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024, arcadeai | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
.PHONY: help | ||
|
||
help: | ||
@echo "🛠️ x Commands:\n" | ||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
|
||
.PHONY: install | ||
install: ## Install the poetry environment and install the pre-commit hooks | ||
@echo "📦 Checking if Poetry is installed" | ||
@if ! command -v poetry &> /dev/null; then \ | ||
echo "📦 Installing Poetry with pip"; \ | ||
pip install poetry; \ | ||
else \ | ||
echo "📦 Poetry is already installed"; \ | ||
fi | ||
@echo "🚀 Installing package in development mode with all extras" | ||
poetry install --all-extras | ||
|
||
.PHONY: build | ||
build: clean-build ## Build wheel file using poetry | ||
@echo "🚀 Creating wheel file" | ||
poetry build | ||
|
||
.PHONY: clean-build | ||
clean-build: ## clean build artifacts | ||
@echo "🗑️ Cleaning dist directory" | ||
rm -rf dist | ||
|
||
.PHONY: test | ||
test: ## Test the code with pytest | ||
@echo "🚀 Testing code: Running pytest" | ||
@poetry run pytest -W ignore -v --cov --cov-config=pyproject.toml --cov-report=xml | ||
|
||
.PHONY: coverage | ||
coverage: ## Generate coverage report | ||
@echo "coverage report" | ||
coverage report | ||
@echo "Generating coverage report" | ||
coverage html | ||
|
||
.PHONY: bump-version | ||
bump-version: ## Bump the version in the pyproject.toml file | ||
@echo "🚀 Bumping version in pyproject.toml" | ||
poetry version patch | ||
|
||
.PHONY: check | ||
check: ## Run code quality tools. | ||
@echo "🚀 Checking Poetry lock file consistency with 'pyproject.toml': Running poetry check --lock" | ||
@poetry check --lock | ||
@echo "🚀 Linting code: Running pre-commit" | ||
@poetry run pre-commit run -a | ||
@echo "🚀 Static type checking: Running mypy" | ||
@poetry run mypy --config-file=pyproject.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.