1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【LangChain】コードレビューエージェント

1
Last updated at Posted at 2026-03-01

はじめに

  • 生成AIでなんでもコードを生成できる中、一般的な規約や組織内の規約に沿った観点でレビューを出す必要があると思いました。
  • そこで、評価観点を基にコードレビューレポートを生成するエージェントを作成しました。

前提条件

  • LangChainの必要なライブラリがインストール済みであること

今回使用するLangChain系ライブラリ

## LangChain系ライブラリ
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain_core.prompts import ChatPromptTemplate
from langchain_community.document_loaders import TextLoader
from langchain_core.output_parsers import StrOutputParser

レビュー対象のサンプルコード

実装

出力例

後記

  • 最後まで読んで頂きありがとうございます。
  • 今回はRAG(検索拡張生成)の仕組みは取り入れてはいませんが、RAGを入れることでチーム内・組織内の規約に沿ったコードレビュー生成をしてくれると思います。
  • コードレビューにかける時間や負担の軽減に繋がるのではないかと思いました。
  • チームリーダにレビュー依頼を出す前に一度レポートを出してもらったり、「修正案は出さないで」と指示しといてエンジニア育成にも使えるのではと思いました。
  • 外部に流出させてはいけないコードに関しては場合はローカルLLM環境を作成する必要があると思いました。
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?