Skip to main content

🐶 Codedog

Checkstyle Pytest Coverage

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

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

How to release

Metadata

Release files for codedog 0.11.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for codedog 0.11.0
File Size Uploaded
codedog-0.11.0.tar.gz 22.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for codedog 0.11.0
File Interpreter ABI Platform
codedog-0.11.0-py3-none-any.whl Python 3 none any Details

Total release size: 58.0 kB

Release files / codedog-0.11.0.tar.gz

Download URL codedog-0.11.0.tar.gz
Size 22.2 kB
Tags Source
SHA-256 checksum
How to use checksums
012deb5119d85051e4eb9246d71002d5f50031f5a230baddb815bfcb36adc83a
BLAKE2b-256 checksum
How to use checksums
874b92f0ddfd6fa63206c66856316a7f1caa5da18962e81235813567453bc1ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.9.6 Darwin/23.0.0

Release files / codedog-0.11.0-py3-none-any.whl

Download URL codedog-0.11.0-py3-none-any.whl
Size 35.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a0d8cf91f7cac2244229e85af815fcb8b4f690594370c50bf2ef85d703141c0c
BLAKE2b-256 checksum
How to use checksums
2146b6e317a40cc908e2ec3c90f40ec45c076ece1d68dfa411003dbe0384c547
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.9.6 Darwin/23.0.0

Release history Release notifications | RSS feed

This release

0.11.0 This release

2 release files

0.9.0

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page