Coding Review Assistant🧑🚀
Build your own Coding Review Assistant in less than 50 lines of code.
const { createToolCallingAgent, AgentExecutor } = require("langchain/agents");
const { LangchainToolSet } = require("composio-core");
const { ChatOpenAI } = require("@langchain/openai");
const { ChatPromptTemplate } = require("@langchain/core/prompts");
async function main(inputs) {
const llm = new ChatOpenAI({
model: "gpt-4o",
apiKey: inputs.OPENAI_API_KEY,
});
const toolset = new LangchainToolSet({ apiKey: inputs.COMPOSIO_API_KEY });
const entity = await toolset.client.getEntity(inputs.entityId);
const prReviewTools = await toolset.getActions({
actions: ["GITHUB_GET_A_PULL_REQUEST", "GITHUB_CREATE_A_REVIEW_COMMENT_FOR_A_PULL_REQUEST"],
}, entity.id);
const prSummaryTools = await toolset.getActions({
actions: ["GITHUB_GET_A_PULL_REQUEST", "GITHUB_CREATE_AN_ISSUE_COMMENT"]
},entity.id);
const codeReviewerAgent = await createToolCallingAgent({
llm,
tools: prReviewTools,
prompt: ChatPromptTemplate.fromMessages([
["system", `You are an experienced code reviewer. Your task is to review the provided file diff and give constructive feedback. Follow these steps:
1. Identify if the file contains significant logic changes. Typically, such files have modifications in function logic.
2. Summarize the changes in the diff in clear and concise English, within 100 words. Focus on the essence of the changes without repeating the first step.
3. Provide actionable suggestions if there are any issues in the code. Avoid unnecessary comments unless there are clear problems or typos.
<format_instructions_for_review_comment>
Review the file <name> change and provide:
1. An assessment of whether the file contains major logic changes.
2. A brief summary of the diff changes, within 100 words.
3. Constructive suggestions if there are any issues in the code. Avoid unnecessary comments unless there are clear problems or typos.
Follow the instructions for review comments:
<format_instructions_for_review_comment>
Here is the diff content:
\`\`\`
<text>
NOTE: Use the \`github_pulls_create_review_comment\` tool to post comments highlighting specific sections of the PR changes.
\`\`\``],
["placeholder", "{chat_history}"],
["human", "{input}"],
["placeholder", "{agent_scratchpad}"],
]),
});
const prSummariserAgent = await createToolCallingAgent({
llm,
tools: prSummaryTools,
prompt: ChatPromptTemplate.fromMessages([
["system", `Act as a Code Reviewer Assistant. I want you to provide some information about the below Pull Request (PR) to help reviewers understand it better and review it faster.
The items I want you to provide are:
- Describe the changes of this PR and its objective.
- Categorize this PR into one of the following types: Feature, Fix, Refactor, Perf, Doc, Test, Ci, Style, Housekeeping
- If it's a feature/refactor PR, list the important change files which you believe
contain the major logical changes of this PR.
Below is information about this PR I can provide to you:
PR Metadata:
\`\`\`text
<metadata_of_the_pr>
\`\`\`
Change Files (with status):
\`\`\`text
<change_files_in_the_pr>
\`\`\`
Code change summaries (if this PR contains no code files, this will be empty):
\`\`\`text
<code_summaries_of_the_pr>
\`\`\`
INSTRUCTIONS:
1. Read the PR step by step and then make comments.
2. DON'T PRIORTISE FORMATTING ISSUES
`],
["placeholder", "{chat_history}"],
["human", "{input}"],
["placeholder", "{agent_scratchpad}"],
]),
});
const codeReviewerExecutor = new AgentExecutor({ agent: codeReviewerAgent, tools: prReviewTools, verbose: true });
const prSummariserExecutor = new AgentExecutor({ agent: prSummariserAgent, tools: prSummaryTools, verbose: true });
const reviewResult = await codeReviewerExecutor.invoke({input: `Review the provided PR and create review comments if there is any serious issue with the changes. Ensure the comment on review PR is posted successfully if an actual comment isn't needed, just ignore it. USE github_pulls_create_review_comment to COMMENT ON THE CHANGES. DO NOT COMMENT UNCESSARILY IF THERE IS NO SERIOUS ISSUE OR A TYPO.
THE URL OF THE PR is: ${inputs.PR_URL}`})
console.log(reviewResult.output);
const summaryResult = await prSummariserExecutor.invoke({input: `Summarize the provided PR and post an comment in github PR with the changes summary. Ensure the summary is posted successfully before completing the task using github_issues_create_comment tool. THE URL OF THE PR is: ${inputs.PR_URL}
EXPECTED OUTCOME: A github comment is posted with the changes summary in the specified PR using github_issues_create_comment tool.
`});
return `## PR Review Comments:
${reviewResult.output}
## PR Summary:
${summaryResult.output}
`
};
module.exports = { main };
🏟️ 100+ tools + usecases
✅ OSS recipes + discord support
🎉 Free for early stage startups and indie devs
Use Composio to build Coding Review Assistant
You can now build Coding Review Assistant using supercharged and accurate tools not only help you achieve task.
Install Composio & select your tools
Get started by installing Composio and choosing from our extensive library of 100+ tools to integrate into your project.
Select frameworks and add prompts
Choose your preferred AI frameworks and craft custom prompts to guide your AI assistant's behavior and responses.
Try and deploy in seconds
Test your AI assistant instantly and deploy it with just a few clicks, making your custom solution live and ready to use in seconds.
+ Integrate seamlessly with your agentic frameworks
Build Coding Review Assistant for free
Create customized, efficient, and scalable ai agents effortlessly in mins. Just run and deploy!
Build your own
Project Timeline Creator
An AI assistant that can create detailed project timelines based on task lists, dependencies, and re...
Try it →
Build your own
Coding Review Assistant
An AI Agent that reviews and improves code quality.
Try it →
Build your own
AI Workout Generator
An AI assistant that can create personalized workout plans and routines based on your fitness goals,...
Try it →
Build your own
AI Email Assistant
An AI assistant that can help you draft, organize, and send emails more efficiently, as well as summ...
Try it →
Frequently asked questions
What is Coding Review Assistant?
Coding Review Assistant is a powerful AI-driven solution that can be implemented using Composio.dev. It's designed to address specific challenges and streamline processes in various industries, leveraging cutting-edge AI technologies to deliver efficient and innovative results.
How can I implement Coding Review Assistant using Composio.dev?
Implementing Coding Review Assistant with Composio.dev is straightforward. You can use the Composio.dev API to integrate various AI models and tools, allowing you to build a custom solution tailored to your specific Coding Review Assistant needs. The platform provides SDKs in Python, JavaScript, and TypeScript, making it easy to get started regardless of your preferred programming language.
What are the benefits of using Coding Review Assistant in my business?
Implementing Coding Review Assistant can bring numerous benefits to your business, including increased efficiency, improved decision-making, enhanced customer experiences, and potential cost savings. By leveraging AI capabilities, you can automate complex tasks, gain valuable insights from data, and stay competitive in your industry.
What kind of AI models can I use for Coding Review Assistant?
Composio.dev supports a wide range of state-of-the-art AI models that can be applied to Coding Review Assistant, including GPT-4, GPT-3.5, Claude, PaLM, LLaMA, LLaMA 2, and Gemini. You can choose the model that best fits your specific use case requirements and experiment with different options to optimize performance.
Is Coding Review Assistant suitable for small businesses or startups?
Absolutely! Coding Review Assistant can be beneficial for businesses of all sizes. Composio.dev offers a generous free tier with up to 1000 requests per month, making it accessible for small businesses and startups to get started with AI-powered solutions without a significant upfront investment.
How does Coding Review Assistant handle data privacy and security?
Data privacy and security are top priorities when implementing Coding Review Assistant. Composio.dev ensures that all integrations, including those for Coding Review Assistant, adhere to strict data protection regulations. The platform provides robust security measures such as encryption and access controls to keep your sensitive information safe and secure.
Can I customize Coding Review Assistant for my specific industry needs?
Yes, Coding Review Assistant is highly customizable. Composio.dev's flexible platform allows you to tailor the solution to your specific industry requirements. You can integrate various AI tools and services, customize models, and configure the system to address your unique challenges and objectives.
What kind of support is available for implementing Coding Review Assistant?
Composio.dev provides comprehensive support for implementing Coding Review Assistant. This includes extensive documentation, tutorials, and guides specific to Coding Review Assistant applications. Additionally, there's a dedicated support team and a community of developers who can assist you throughout your implementation journey.
How can I measure the success of my Coding Review Assistant implementation?
Measuring the success of your Coding Review Assistant implementation depends on your specific goals. Composio.dev provides tools and integrations that allow you to track key performance indicators (KPIs) relevant to your use case. These might include metrics like efficiency improvements, cost savings, customer satisfaction scores, or other industry-specific benchmarks.
What are some common challenges in implementing Coding Review Assistant, and how can I overcome them?
Common challenges in implementing Coding Review Assistant may include data quality issues, integration complexities, and adapting to new workflows. Composio.dev helps overcome these challenges by providing robust data handling capabilities, seamless integrations with various tools and platforms, and flexible customization options. The platform's extensive documentation and support resources also guide you through potential roadblocks in your implementation process.
🚀 Ship AI Agents faster than ever.
Connect your AI Agents and LLMs Apps with 90+ tools right out of the box.