Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How we built an AI code reviewer with serverles...

Yan Cui
February 12, 2025

How we built an AI code reviewer with serverless and Bedrock

Slides for my talk at the Serverless London meetup on 12-Feb-2025

Yan Cui

February 12, 2025
Tweet

More Decks by Yan Cui

Other Decks in Technology

Transcript

  1. Challenges (for an AI code reviewer) Large fi les. Large

    PRs with many fi les. Handling sensitive data for customers
  2. Security Data is encrypted at rest. Inputs & Outputs are

    not shared with model providers. Inputs & Outputs are not used to train other models.
  3. 1M Input Tokens 1M Output Tokens $0.14 v3 r1 $0.28

    $0.55 $2.19 Sonnet $3.75 $15.0 Haiku $0.80 $4.00
  4. Very cost ef fi cient! Data is stored in China.

    Data might be used to train other models.
  5. Very cost ef fi cient! Data is stored in China.

    Data might be used to train other models. Operationally immature.
  6. Context window Max response tokens API rate limit Reasoning ability

    Cost Performance Important selection criteria for LLMs
  7. Claude 3.5 Sonnet’s default throughput is 50 per minute Can

    be raised to 1,000 per minute Bedrock has cross- region inference
  8. Mitigate API rate limit Raise account limits. Use Bedrock cross-region

    inference. Limit no. of parallel requests per PR.
  9. Mitigate API rate limit Raise account limits. Use Bedrock cross-region

    inference. Limit no. of parallel requests per PR. Fallback to Anthropic & less powerful models (Claude 3 Sonnet, Claude 3.5 Haiku)
  10. Lambda timed out after 15 mins Reprocess fi les on

    retry… Duplicated side- effects (e.g. Github comments)
  11. Cost control Only analyse changed lines. Limit free users to

    few PRs per month. Use checkpoints to avoid re-processing fi les on retries
  12. const issues = await executeIdempotently( `${event-id}-${filename}-analyze`, () => analyzeFile(file) );

    ... await executeIdempotently( `${event-id}-${filename}-add-gh-comment`, () => addReviewComment(filename, comment) );