Skip to main content

Codedog reviews your pull request using llm.

Project description

🐶 Codedog

Checkstyle Pytest Coverage

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

Start with your own code

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

  1. Install codedog
pip install codedog

codedog currently only supports python 3.10.

  1. Get a github pull request
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)
  1. Summarize the pull request

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

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)
  1. Review each code file changes in the pull request
review_chain = CodeReviewChain.from_llm(llm=llm35, verbose=True)

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

print(reviews)
  1. Format review result

Format review result to a markdown report.

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codedog-0.9.0.tar.gz (22.3 kB view details)

Uploaded Source

Built Distribution

codedog-0.9.0-py3-none-any.whl (36.2 kB view details)

Uploaded Python 3

File details

Details for the file codedog-0.9.0.tar.gz.

File metadata

  • Download URL: codedog-0.9.0.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.9.6 Darwin/23.0.0

File hashes

Hashes for codedog-0.9.0.tar.gz
Algorithm Hash digest
SHA256 fcbc9f287a2051f5417ed23aeec1e5ca7fa915c3b703a7076c0b20ea7331d6bb
MD5 ce952698dedf889e6a6ce5f2cc528c46
BLAKE2b-256 aa70f2ef5069f4dfa68469d9aeb42ca310a467e32304511aed01170cf0dd9257

See more details on using hashes here.

Provenance

File details

Details for the file codedog-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: codedog-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 36.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.9.6 Darwin/23.0.0

File hashes

Hashes for codedog-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2a36d232713337c62ab846a7a51129f3d37419cd056313103926fd3f4a91b56d
MD5 4cb0a922e937ee2264b40f83c77e0273
BLAKE2b-256 e59b40fcdb85179d9edbbae774025638ffe186ff5f14a436b9dbe5af93af8d4e

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page