codedog


Namecodedog JSON
Version 0.8.2 PyPI version JSON
download
home_pagehttps://www.codedog.ai
SummaryCodedog reviews your pull request using llm.
upload_time2023-08-22 09:39:57
maintainer
docs_urlNone
authorArcadia
requires_python>=3.10,<3.11
licenseMIT
keywords code review langchain llm
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 🐶 Codedog

[![Checkstyle](https://github.com/Arcadia822/codedog/actions/workflows/flake8.yml/badge.svg)](https://github.com/Arcadia822/codedog/actions/workflows/flake8.yml)
[![Pytest](https://github.com/Arcadia822/codedog/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/Arcadia822/codedog/actions/workflows/test.yml)
[![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/Arcadia822/ce38dae58995aeffef42065093fcfe84/raw/codedog_master.json)](https://github.com/Arcadia822/codedog/actions/workflows/test.yml)

Review your Github/Gitlab PR with ChatGPT

## What is codedog?

Codedog is a code review automation tool benefit the power of LLM (Large Language Model) to help developers
review code faster and more accurately.

Codedog is based on OpenAI API and Langchain.

## Quickstart

### Review your pull request via Github App

Install our github app [codedog-assistant](https://github.com/apps/codedog-assistant)

### Start with your own code

As a example, we will use codedog to review a pull request on Github.

0. Install codedog

```bash
pip install codedog
```

codedog currently only supports python 3.10.

1. Get a github pull request
```python
from github import Github

github_token="YOUR GITHUB TOKEN"
repository = "codedog-ai/codedog"
pull_request_number = 2

github = Github(github_token)
retriever = GithubRetriever(github, repository, pull_requeest_number)
```


2. Summarize the pull request

Since `PRSummaryChain` uses langchain's output parser, we suggest to use GPT-4 to improve formatting accuracy.

```python
from codedog.chains import PRSummaryChain

openai_api_key = "YOUR OPENAI API KEY WITH GPT4"

# PR Summary uses output parser
llm35 = ChatOpenAI(openai_api_key=openai_api_key, model="gpt-3.5-turbo")

llm4 = ChatOpenAI(openai_api_key=openai_api_key, model="gpt-4")

summary_chain = PRSummaryChain.from_llm(code_summary_llm=llm35, pr_summary_llm=llm4, verbose=True)

summary = summary_chain({"pull_request": retriever.pull_request}, include_run_info=True)

print(summary)
```

3. Review each code file changes in the pull request

```python
review_chain = CodeReviewChain.from_llm(llm=llm35, verbose=True)

reviews = review_chain({"pull_request": retriever.pull_request}, include_run_info=True)

print(reviews)
```

4. Format review result

Format review result to a markdown report.

```python
from codedog.actors.reporters.pull_request import PullRequestReporter

reporter = PullRequestReporter(
    pr_summary=summary["pr_summary"],
    code_summaries=summary["code_summaries"],
    pull_request=retriever.pull_request,
    code_reviews=reviews["code_reviews"],
)

md_report = reporter.report()

print(md_report)
```

## Deployment

We have a simple server demo to deploy codedog as a service with fastapi and handle Github webhook.
Basicly you can also use it with workflow or Github Application.

see `examples/server.py`

Note that codedog don't have fastapi and unicorn as dependency, you need to install them manually.

## Configuration

Codedog currently load config from environment variables.

settings:

| Config Name                    | Required | Default           | Description                             |
| ------------------------------ | -------- | ----------------- | --------------------------------------- |
| OPENAI_API_KEY                 | No       |                   | Api Key for calling openai gpt api      |
| AZURE_OPENAI                   | No       |                   | Use azure openai if not blank           |
| AZURE_OPENAI_API_KEY           | No       |                   | Azure openai api key                    |
| AZURE_OPENAI_API_BASE          | No       |                   | Azure openai api base                   |
| AZURE_OPENAI_DEPLOYMENT_ID     | No       |                   | Azure openai deployment id for gpt 3.5  |
| AZURE_OPENAI_GPT4_DEPLOYMENT_ID| No       |                   | Azure openai deployment id for gpt 4    |

            

Raw data

            {
    "_id": null,
    "home_page": "https://www.codedog.ai",
    "name": "codedog",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<3.11",
    "maintainer_email": "",
    "keywords": "code review,langchain,llm",
    "author": "Arcadia",
    "author_email": "arcadia822@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/b3/43/b9783dfa5adda0b79d31107f56ef1eb602333a860011f95843cd66e65c54/codedog-0.8.2.tar.gz",
    "platform": null,
    "description": "# \ud83d\udc36 Codedog\n\n[![Checkstyle](https://github.com/Arcadia822/codedog/actions/workflows/flake8.yml/badge.svg)](https://github.com/Arcadia822/codedog/actions/workflows/flake8.yml)\n[![Pytest](https://github.com/Arcadia822/codedog/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/Arcadia822/codedog/actions/workflows/test.yml)\n[![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/Arcadia822/ce38dae58995aeffef42065093fcfe84/raw/codedog_master.json)](https://github.com/Arcadia822/codedog/actions/workflows/test.yml)\n\nReview your Github/Gitlab PR with ChatGPT\n\n## What is codedog?\n\nCodedog is a code review automation tool benefit the power of LLM (Large Language Model) to help developers\nreview code faster and more accurately.\n\nCodedog is based on OpenAI API and Langchain.\n\n## Quickstart\n\n### Review your pull request via Github App\n\nInstall our github app [codedog-assistant](https://github.com/apps/codedog-assistant)\n\n### Start with your own code\n\nAs a example, we will use codedog to review a pull request on Github.\n\n0. Install codedog\n\n```bash\npip install codedog\n```\n\ncodedog currently only supports python 3.10.\n\n1. Get a github pull request\n```python\nfrom github import Github\n\ngithub_token=\"YOUR GITHUB TOKEN\"\nrepository = \"codedog-ai/codedog\"\npull_request_number = 2\n\ngithub = Github(github_token)\nretriever = GithubRetriever(github, repository, pull_requeest_number)\n```\n\n\n2. Summarize the pull request\n\nSince `PRSummaryChain` uses langchain's output parser, we suggest to use GPT-4 to improve formatting accuracy.\n\n```python\nfrom codedog.chains import PRSummaryChain\n\nopenai_api_key = \"YOUR OPENAI API KEY WITH GPT4\"\n\n# PR Summary uses output parser\nllm35 = ChatOpenAI(openai_api_key=openai_api_key, model=\"gpt-3.5-turbo\")\n\nllm4 = ChatOpenAI(openai_api_key=openai_api_key, model=\"gpt-4\")\n\nsummary_chain = PRSummaryChain.from_llm(code_summary_llm=llm35, pr_summary_llm=llm4, verbose=True)\n\nsummary = summary_chain({\"pull_request\": retriever.pull_request}, include_run_info=True)\n\nprint(summary)\n```\n\n3. Review each code file changes in the pull request\n\n```python\nreview_chain = CodeReviewChain.from_llm(llm=llm35, verbose=True)\n\nreviews = review_chain({\"pull_request\": retriever.pull_request}, include_run_info=True)\n\nprint(reviews)\n```\n\n4. Format review result\n\nFormat review result to a markdown report.\n\n```python\nfrom codedog.actors.reporters.pull_request import PullRequestReporter\n\nreporter = PullRequestReporter(\n    pr_summary=summary[\"pr_summary\"],\n    code_summaries=summary[\"code_summaries\"],\n    pull_request=retriever.pull_request,\n    code_reviews=reviews[\"code_reviews\"],\n)\n\nmd_report = reporter.report()\n\nprint(md_report)\n```\n\n## Deployment\n\nWe have a simple server demo to deploy codedog as a service with fastapi and handle Github webhook.\nBasicly you can also use it with workflow or Github Application.\n\nsee `examples/server.py`\n\nNote that codedog don't have fastapi and unicorn as dependency, you need to install them manually.\n\n## Configuration\n\nCodedog currently load config from environment variables.\n\nsettings:\n\n| Config Name                    | Required | Default           | Description                             |\n| ------------------------------ | -------- | ----------------- | --------------------------------------- |\n| OPENAI_API_KEY                 | No       |                   | Api Key for calling openai gpt api      |\n| AZURE_OPENAI                   | No       |                   | Use azure openai if not blank           |\n| AZURE_OPENAI_API_KEY           | No       |                   | Azure openai api key                    |\n| AZURE_OPENAI_API_BASE          | No       |                   | Azure openai api base                   |\n| AZURE_OPENAI_DEPLOYMENT_ID     | No       |                   | Azure openai deployment id for gpt 3.5  |\n| AZURE_OPENAI_GPT4_DEPLOYMENT_ID| No       |                   | Azure openai deployment id for gpt 4    |\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Codedog reviews your pull request using llm.",
    "version": "0.8.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/codedog-ai/codedog/issues",
        "Discord": "https://discord.gg/8TfqpFC4",
        "Homepage": "https://www.codedog.ai",
        "Repository": "https://www.github.com/codedog-ai/codedog"
    },
    "split_keywords": [
        "code review",
        "langchain",
        "llm"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "52a29c95a2f01b4d5d833c21eba472ffc3d9126abcae0d39b7e1aff59d5995e0",
                "md5": "98f9cfdeed786d5a327aa3aec9d49b54",
                "sha256": "ec8b1c2b9ec9188dc784ed1d923ba6a4887cb9cf8f7280599cb89f71729c5bf8"
            },
            "downloads": -1,
            "filename": "codedog-0.8.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "98f9cfdeed786d5a327aa3aec9d49b54",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<3.11",
            "size": 36164,
            "upload_time": "2023-08-22T09:39:55",
            "upload_time_iso_8601": "2023-08-22T09:39:55.914428Z",
            "url": "https://files.pythonhosted.org/packages/52/a2/9c95a2f01b4d5d833c21eba472ffc3d9126abcae0d39b7e1aff59d5995e0/codedog-0.8.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b343b9783dfa5adda0b79d31107f56ef1eb602333a860011f95843cd66e65c54",
                "md5": "a8d92f1d158086feb4292492a8ebeb2e",
                "sha256": "0bf5059e945b503a168aa0e3fff21adcd3f44d46bf92716252a70d257c6d5926"
            },
            "downloads": -1,
            "filename": "codedog-0.8.2.tar.gz",
            "has_sig": false,
            "md5_digest": "a8d92f1d158086feb4292492a8ebeb2e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<3.11",
            "size": 21669,
            "upload_time": "2023-08-22T09:39:57",
            "upload_time_iso_8601": "2023-08-22T09:39:57.450316Z",
            "url": "https://files.pythonhosted.org/packages/b3/43/b9783dfa5adda0b79d31107f56ef1eb602333a860011f95843cd66e65c54/codedog-0.8.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-22 09:39:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "codedog-ai",
    "github_project": "codedog",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "codedog"
}
        
Elapsed time: 0.10150s