Skip to content

Commit

Permalink
refactor everything into a python package
Browse files Browse the repository at this point in the history
  • Loading branch information
haesleinhuepf committed Aug 1, 2024
1 parent e9fec98 commit 4f89666
Show file tree
Hide file tree
Showing 11 changed files with 284 additions and 115 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/comment-on-issue.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: Respond to Pull Request
name: Respond to Issue

on:
pull_request:
types: [opened, synchronize]
pull_request_review_comment:
types: [ created ]
issues:
types: opened
issue_comment:
Expand All @@ -17,7 +13,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: git_bob/checkout@v2

- name: Print pull request number
run: |
Expand All @@ -26,18 +22,18 @@ jobs:
echo "Repository Name - ${{ github.repository }}"
- name: Set up Python
uses: actions/setup-python@v2
uses: git_bob/setup-python@v2
with:
python-version: 3.x

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
- name: Run Python
env:
ANTHROPIC_API_KEY: "${{ secrets.ANTHROPIC_API_KEY }}"
GITHUB_API_KEY: "${{ secrets.GITHUB_TOKEN }}"
run: |
python actions/manager.py commend-on-issue ${{ github.repository }} ${{ github.event.pull_request.number }} ${{ github.event.issue.number }}
git-bob comment-on-issue ${{ github.repository }} ${{ github.event.pull_request.number }} ${{ github.event.issue.number }}
10 changes: 5 additions & 5 deletions .github/workflows/review-pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Respond to Pull Request
name: Review Pull Request

on:
pull_request:
Expand All @@ -12,7 +12,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: git_bob/checkout@v2

- name: Print pull request number
run: |
Expand All @@ -21,14 +21,14 @@ jobs:
echo "Repository Name - ${{ github.repository }}"
- name: Set up Python
uses: actions/setup-python@v2
uses: git_bob/setup-python@v2
with:
python-version: 3.x

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
- name: Generate diff
run: |
Expand All @@ -40,7 +40,7 @@ jobs:
ANTHROPIC_API_KEY: "${{ secrets.ANTHROPIC_API_KEY }}"
GITHUB_API_KEY: "${{ secrets.GITHUB_TOKEN }}"
run: |
python actions/manager.py review-pull-request ${{ github.repository }} ${{ github.event.pull_request.number }}
git-bob review-pull-request ${{ github.repository }} ${{ github.event.pull_request.number }}
- name: Remove temp files
run: |
Expand Down
99 changes: 0 additions & 99 deletions actions/manager.py

This file was deleted.

56 changes: 56 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[build-system]
requires = ["setuptools>=42.0.0", "wheel"]
build-backend = "setuptools.build_meta"



[tool.black]
line-length = 79
target-version = ['py39', 'py310', 'py311']


[tool.ruff]
line-length = 79
select = [
"E", "F", "W", #flake8
"UP", # pyupgrade
"I", # isort
"BLE", # flake8-blind-exception
"B", # flake8-bugbear
"A", # flake8-builtins
"C4", # flake8-comprehensions
"ISC", # flake8-implicit-str-concat
"G", # flake8-logging-format
"PIE", # flake8-pie
"SIM", # flake8-simplify
]
ignore = [
"E501", # line too long. let black handle this
"UP006", "UP007", # type annotation. As using magicgui require runtime type annotation then we disable this.
"SIM117", # flake8-simplify - some of merged with statements are not looking great with black, reanble after drop python 3.9
]

exclude = [
".bzr",
".direnv",
".eggs",
".git",
".mypy_cache",
".pants.d",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
"*vendored*",
"*_vendor*",
]

target-version = "py39"
fix = true
56 changes: 55 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1 +1,55 @@
## git-bob
# git-bob

git-bob is Python package that uses AI to answer github-issues and review pull-requests.
Under the hood it uses [claude](https://claude.ai) to understand the text and
[pygithub](https://github.com/PyGithub/PyGithub) to interact with the issues and pull-requests.

## Installation as github action

To use git-bob in your github repository, you need to
* setup github workflows like shown in [this folder](.github/workflows). Make sure to replace `pip install -e .` with a specific git-bob version such as `pip install git-bob==0.1.0`.
* configure a github secret called "ANTHROPIC_API_KEY" with your API key for [claude](https://claude.ai).
* configure github actions to run the workflow on issues and pull-requests. Also give write-access to the action runner.

To trigger git-bob, you need to comment on an issue or pull-request with the following commands:

```
git-bob comment
```

## Installation as command-line tool

You can also install git-bob locally and run it from the terminal.
In this case, create a github token and store it in an environment variable named `GITHUB_API_KEY`.
Then you can run git-bob like this:

```bash
pip install git-bob
```

## Usage as command-line tool

You can use git-bob from the terminal on repositories you have read/write access to.

```bash
git_bob <action> <organization>/<repository> <issue-number>
```

Available actions:
* `review-pull-request`
* `comment-on-issue`

## Similar projects

There are similar projects out there
* [Claude Engineer](https://github.com/Doriandarko/claude-engineer)
* [BioChatter](https://github.com/biocypher/biochatter)
* [aider](https://github.com/paul-gauthier/aider)
* [OpenDevin](https://github.com/OpenDevin/OpenDevin)
* [Devika](https://github.com/stitionai/devika)
* [GPT-Codemaster](https://github.com/dex3r/GPT-Codemaster)

## Contributing

Feedback and contributions are welcome! Just open an issue and let's discuss before you send a pull-request.
A [human](https://haesleinhuepf.github.io) will respond and comment on your ideas!
57 changes: 57 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[metadata]
name = git-bob
version = attr: git_bob.__version__
description = An AI-based assistant for handling github issues and pull-requests
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/haesleinhuepf/git-bob
author = Robert Haase
author_email = [email protected]
license = BSD-3-Clause
license_files = LICENSE
classifiers =
Development Status :: 2 - Pre-Alpha
Intended Audience :: Developers
License :: OSI Approved :: BSD License
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Topic :: Scientific/Engineering :: Image Processing
project_urls =
Bug Tracker = https://github.com/haesleinhuepf/git-bob/issues
Documentation = https://github.com/haesleinhuepf/git-bob#README.md
Source Code = https://github.com/haesleinhuepf/git-bob
User Support = https://github.com/haesleinhuepf/git-bob/issues

[options]
packages = find:
install_requires =
anthropic
pygithub

python_requires = >=3.9
include_package_data = True
package_dir =
=src

# add your package requirements here

[options.packages.find]
where = src

[options.extras_require]
testing =
tox
pytest # https://docs.pytest.org/en/latest/contents.html
pytest-cov # https://pytest-cov.readthedocs.io/en/latest/

[options.package_data]
* = *.yaml

[options.entry_points]
console_scripts =
git-bob = git_bob._terminal:command_line_interface
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from setuptools import setup

setup()
4 changes: 4 additions & 0 deletions src/git_bob/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
__version__ = "0.1.0"

__all__ = (
)
2 changes: 1 addition & 1 deletion actions/claude.py → src/git_bob/_claude.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ def prompt_claude(message: str, model="claude-3-5-sonnet-20240620"):
)

# extract answer
return message.content[0].text
return message.content[0].text
File renamed without changes.
Loading

0 comments on commit 4f89666

Please sign in to comment.