codedog


Namecodedog JSON
Version 0.11.0 PyPI version JSON
download
home_pagehttps://www.codedog.ai
SummaryCodedog reviews your pull request using llm.
upload_time2024-07-31 06:47:30
maintainerNone
docs_urlNone
authorArcadia
requires_python<3.11,>=3.10
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)
[![](https://dcbadge.vercel.app/api/server/wzfsvaDQ?compact=true&style=flat)](https://discord.gg/6adMQxSpJS)

Review your Github/Gitlab PR with ChatGPT

**Codedog is update to langchain v0.2**


## 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    |

# How to release

            

Raw data

            {
    "_id": null,
    "home_page": "https://www.codedog.ai",
    "name": "codedog",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.11,>=3.10",
    "maintainer_email": null,
    "keywords": "code review, langchain, llm",
    "author": "Arcadia",
    "author_email": "arcadia822@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/87/4b/92f0ddfd6fa63206c66856316a7f1caa5da18962e81235813567453bc1ff/codedog-0.11.0.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[![](https://dcbadge.vercel.app/api/server/wzfsvaDQ?compact=true&style=flat)](https://discord.gg/6adMQxSpJS)\n\nReview your Github/Gitlab PR with ChatGPT\n\n**Codedog is update to langchain v0.2**\n\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\n# How to release\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Codedog reviews your pull request using llm.",
    "version": "0.11.0",
    "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": "2146b6e317a40cc908e2ec3c90f40ec45c076ece1d68dfa411003dbe0384c547",
                "md5": "82b8fa5690b5d23750877bee46ae1686",
                "sha256": "a0d8cf91f7cac2244229e85af815fcb8b4f690594370c50bf2ef85d703141c0c"
            },
            "downloads": -1,
            "filename": "codedog-0.11.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "82b8fa5690b5d23750877bee46ae1686",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.11,>=3.10",
            "size": 35797,
            "upload_time": "2024-07-31T06:47:29",
            "upload_time_iso_8601": "2024-07-31T06:47:29.439866Z",
            "url": "https://files.pythonhosted.org/packages/21/46/b6e317a40cc908e2ec3c90f40ec45c076ece1d68dfa411003dbe0384c547/codedog-0.11.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "874b92f0ddfd6fa63206c66856316a7f1caa5da18962e81235813567453bc1ff",
                "md5": "9b9cb654b002c657a13741ad73c2510d",
                "sha256": "012deb5119d85051e4eb9246d71002d5f50031f5a230baddb815bfcb36adc83a"
            },
            "downloads": -1,
            "filename": "codedog-0.11.0.tar.gz",
            "has_sig": false,
            "md5_digest": "9b9cb654b002c657a13741ad73c2510d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.11,>=3.10",
            "size": 22231,
            "upload_time": "2024-07-31T06:47:30",
            "upload_time_iso_8601": "2024-07-31T06:47:30.751628Z",
            "url": "https://files.pythonhosted.org/packages/87/4b/92f0ddfd6fa63206c66856316a7f1caa5da18962e81235813567453bc1ff/codedog-0.11.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-31 06:47:30",
    "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.35154s